mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Added study_groups
This commit is contained in:
parent
c4bca9777c
commit
701dc55e31
16 changed files with 140 additions and 63 deletions
|
@ -1,9 +1,10 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 09:44
|
||||
# Generated by Django 4.2.2 on 2023-06-27 13:08
|
||||
|
||||
import accounts.models
|
||||
import django.contrib.auth.models
|
||||
import django.contrib.auth.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
|
@ -12,6 +13,10 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('courses', '0002_initial'),
|
||||
('semesters', '0001_initial'),
|
||||
('year_levels', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -34,6 +39,11 @@ class Migration(migrations.Migration):
|
|||
('is_banned', models.BooleanField(default=False)),
|
||||
('student_id_number', models.CharField(max_length=16, validators=[accounts.models.validate_student_id])),
|
||||
('avatar', models.ImageField(null=True, upload_to=accounts.models.CustomUser._get_upload_to)),
|
||||
('course', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='courses.course')),
|
||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
|
||||
('semester', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='semesters.semester')),
|
||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
|
||||
('year_level', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='year_levels.year_level')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'user',
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 09:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('year_levels', '0001_initial'),
|
||||
('semesters', '0001_initial'),
|
||||
('accounts', '0001_initial'),
|
||||
('courses', '0002_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='course',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='courses.course'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='groups',
|
||||
field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='semester',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='semesters.semester'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='user_permissions',
|
||||
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='customuser',
|
||||
name='year_level',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='year_levels.year_level'),
|
||||
),
|
||||
]
|
|
@ -1,15 +1,13 @@
|
|||
import time
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.text import slugify
|
||||
from django.db import models
|
||||
import os
|
||||
from courses.models import Course
|
||||
from year_levels.models import Year_Level
|
||||
from semesters.models import Semester
|
||||
from django.db.models.signals import post_migrate
|
||||
from django.dispatch import receiver
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
|
||||
def validate_student_id(value):
|
||||
|
|
|
@ -67,6 +67,7 @@ INSTALLED_APPS = [
|
|||
'year_levels',
|
||||
'semesters',
|
||||
'subjects',
|
||||
'study_groups',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 09:44
|
||||
# Generated by Django 4.2.2 on 2023-06-27 13:08
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
|
22
stude/student_status/migrations/0002_initial.py
Normal file
22
stude/student_status/migrations/0002_initial.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 13:08
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('study_groups', '0001_initial'),
|
||||
('student_status', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='studentstatus',
|
||||
name='study_group',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='study_groups.studygroup'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 13:10
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('subjects', '0001_initial'),
|
||||
('student_status', '0002_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='studentstatus',
|
||||
name='subject',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='subjects.subject'),
|
||||
),
|
||||
]
|
|
@ -1,26 +1,18 @@
|
|||
from django.db import models
|
||||
from accounts.models import CustomUser
|
||||
from study_groups.models import StudyGroup
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class StudentStatus(models.Model):
|
||||
YEAR_LEVELS = (
|
||||
('1st', '1st year'),
|
||||
('2nd', '2nd year'),
|
||||
('3rd', '3rd year'),
|
||||
('4th', '4th year'),
|
||||
('5th', '5th Year'),
|
||||
('Irreg', 'Irregular'),
|
||||
)
|
||||
SEMESTERS = (
|
||||
('1st', '1st semester'),
|
||||
('2nd', '2nd semester'),
|
||||
)
|
||||
user = models.OneToOneField(
|
||||
CustomUser, on_delete=models.CASCADE, primary_key=True)
|
||||
x = models.FloatField(null=True)
|
||||
y = models.FloatField(null=True)
|
||||
subject = models.CharField(max_length=100, null=True)
|
||||
subject = models.ForeignKey(
|
||||
'subjects.Subject', on_delete=models.CASCADE, null=True)
|
||||
active = models.BooleanField(default=False)
|
||||
timestamp = models.DateField(auto_now_add=True)
|
||||
study_group = models.ForeignKey(
|
||||
StudyGroup, on_delete=models.SET_NULL, null=True)
|
||||
|
|
0
stude/study_groups/__init__.py
Normal file
0
stude/study_groups/__init__.py
Normal file
6
stude/study_groups/admin.py
Normal file
6
stude/study_groups/admin.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.contrib import admin
|
||||
from .models import StudyGroup, StudyGroupMembership
|
||||
|
||||
|
||||
admin.site.register(StudyGroup)
|
||||
admin.site.register(StudyGroupMembership)
|
6
stude/study_groups/apps.py
Normal file
6
stude/study_groups/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class StudyGroupsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'study_groups'
|
41
stude/study_groups/migrations/0001_initial.py
Normal file
41
stude/study_groups/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Generated by Django 4.2.2 on 2023-06-27 13:08
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('student_status', '0001_initial'),
|
||||
('subjects', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='StudyGroup',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('x', models.FloatField(null=True)),
|
||||
('y', models.FloatField(null=True)),
|
||||
('active', models.BooleanField(default=False)),
|
||||
('timestamp', models.DateField(auto_now_add=True)),
|
||||
('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StudyGroupMembership',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('study_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='study_groups.studygroup')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='student_status.studentstatus')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='studygroup',
|
||||
name='users',
|
||||
field=models.ManyToManyField(through='study_groups.StudyGroupMembership', to='student_status.studentstatus'),
|
||||
),
|
||||
]
|
0
stude/study_groups/migrations/__init__.py
Normal file
0
stude/study_groups/migrations/__init__.py
Normal file
20
stude/study_groups/models.py
Normal file
20
stude/study_groups/models.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from django.db import models
|
||||
from subjects.models import Subject
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class StudyGroup(models.Model):
|
||||
users = models.ManyToManyField(
|
||||
'student_status.StudentStatus', through='StudyGroupMembership')
|
||||
x = models.FloatField(null=True)
|
||||
y = models.FloatField(null=True)
|
||||
subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
|
||||
active = models.BooleanField(default=False)
|
||||
timestamp = models.DateField(auto_now_add=True)
|
||||
|
||||
|
||||
class StudyGroupMembership(models.Model):
|
||||
user = models.ForeignKey(
|
||||
'student_status.StudentStatus', on_delete=models.CASCADE)
|
||||
study_group = models.ForeignKey(
|
||||
'study_groups.StudyGroup', on_delete=models.CASCADE)
|
3
stude/study_groups/tests.py
Normal file
3
stude/study_groups/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
stude/study_groups/views.py
Normal file
3
stude/study_groups/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in a new issue