diff --git a/stude/api/urls.py b/stude/api/urls.py index dc63ab8..7fa8dcc 100644 --- a/stude/api/urls.py +++ b/stude/api/urls.py @@ -3,5 +3,6 @@ from django.urls import path, include urlpatterns = [ path('accounts/', include('accounts.urls')), - path('student_status/', include('student_status.urls')) + path('student_status/', include('student_status.urls')), + path('courses/', include('courses.urls')) ] diff --git a/stude/config/settings.py b/stude/config/settings.py index 83b4876..39016d6 100644 --- a/stude/config/settings.py +++ b/stude/config/settings.py @@ -63,6 +63,7 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', 'accounts', 'student_status', + 'courses', ] MIDDLEWARE = [ diff --git a/stude/courses/__init__.py b/stude/courses/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stude/courses/admin.py b/stude/courses/admin.py new file mode 100644 index 0000000..41f0dbf --- /dev/null +++ b/stude/courses/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import Course + + +admin.site.register(Course) diff --git a/stude/courses/apps.py b/stude/courses/apps.py new file mode 100644 index 0000000..019ba91 --- /dev/null +++ b/stude/courses/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoursesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'courses' diff --git a/stude/courses/migrations/0001_initial.py b/stude/courses/migrations/0001_initial.py new file mode 100644 index 0000000..29cd714 --- /dev/null +++ b/stude/courses/migrations/0001_initial.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.2 on 2023-06-27 05:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Course', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('course_name', models.CharField(max_length=64)), + ('course_shortname', models.CharField(max_length=16)), + ], + ), + ] diff --git a/stude/courses/migrations/__init__.py b/stude/courses/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stude/courses/models.py b/stude/courses/models.py new file mode 100644 index 0000000..4719c9e --- /dev/null +++ b/stude/courses/models.py @@ -0,0 +1,11 @@ +from django.db import models +from accounts.models import CustomUser as User +# Create your models here. + + +class Course(models.Model): + course_name = models.CharField(max_length=64) + course_shortname = models.CharField(max_length=16) + + def __str__(self): + return self.course_shortname diff --git a/stude/courses/serializers.py b/stude/courses/serializers.py new file mode 100644 index 0000000..7c7d419 --- /dev/null +++ b/stude/courses/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from .models import Course + + +class CourseSerializer(serializers.ModelSerializer): + class Meta: + model = Course + fields = '__all__' diff --git a/stude/courses/tests.py b/stude/courses/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/stude/courses/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/stude/courses/urls.py b/stude/courses/urls.py new file mode 100644 index 0000000..a0b193d --- /dev/null +++ b/stude/courses/urls.py @@ -0,0 +1,6 @@ +from django.urls import include, path +from .views import CourseListView + +urlpatterns = [ + path('', CourseListView.as_view()), +] diff --git a/stude/courses/views.py b/stude/courses/views.py new file mode 100644 index 0000000..3e596e5 --- /dev/null +++ b/stude/courses/views.py @@ -0,0 +1,8 @@ +from rest_framework import generics +from .models import Course +from .serializers import CourseSerializer + + +class CourseListView(generics.ListAPIView): + serializer_class = CourseSerializer + queryset = Course.objects.all()