Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 75 documenting APIs #79

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1 on 2025-01-22 08:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("quiz", "0005_questionattempt_student"),
]

operations = [
migrations.AlterField(
model_name="questionattempt",
name="answer_student",
field=models.IntegerField(default=None),
),
]
12 changes: 12 additions & 0 deletions server/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"api.users",
"api.quiz",
"api.team",
'drf_spectacular',
]

REST_FRAMEWORK = {
Expand All @@ -68,6 +69,9 @@
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.BasicAuthentication",
),


'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend']
}

Expand Down Expand Up @@ -196,3 +200,11 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

# DRF Spectacular settings
SPECTACULAR_SETTINGS = {
'TITLE': 'Your Project API',
'DESCRIPTION': 'Your project description',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
}
6 changes: 6 additions & 0 deletions server/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView

urlpatterns = [
path("admin/", admin.site.urls),
Expand All @@ -27,5 +28,10 @@
path("api/auth/", include("api.auth.urls")),
path("api/team/", include("api.team.urls")),
path("api/users/", include("api.users.urls")),
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
# Optional UI:
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),


]
5 changes: 5 additions & 0 deletions server/api/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class TeacherAdmin(admin.ModelAdmin):
class CustomUserAdmin(admin.ModelAdmin):
inlines = [StudentInline, TeacherInline]

def save_model(self, request, obj, form, change):
if form.cleaned_data["password"]:
obj.set_password(form.cleaned_data["password"])
super().save_model(request, obj, form, change)


admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)
Loading
Loading