Commit 1e5878cf authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

field "section" should've been in the course model

parent 21b7128b
...@@ -9,9 +9,9 @@ class AssignmentInline(admin.StackedInline): ...@@ -9,9 +9,9 @@ class AssignmentInline(admin.StackedInline):
class AssignmentAdmin(admin.ModelAdmin): class AssignmentAdmin(admin.ModelAdmin):
model = Assignment model = Assignment
list_display = ('assignment_name', 'section') list_display = ('assignment_name', 'course',)
search_fields = ('course',) search_fields = ('course',)
list_filter = ('section', 'perfect_score', 'passing_score') list_filter = ('course', 'perfect_score', 'passing_score')
class CourseAdmin(admin.ModelAdmin): class CourseAdmin(admin.ModelAdmin):
......
# Generated by Django 3.2 on 2023-05-12 05:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_auto_20230429_1712'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_name',
field=models.CharField(default='', max_length=50, unique=True, verbose_name='Name'),
),
]
# Generated by Django 3.2 on 2023-05-12 05:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0004_alter_assignment_assignment_name'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='courseDropDown',
field=models.CharField(default='', max_length=100),
),
]
# Generated by Django 3.2 on 2023-05-12 05:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0005_assignment_coursedropdown'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='courseDropDown',
field=models.CharField(blank=True, default='', max_length=100, unique=True),
),
]
# Generated by Django 3.2 on 2023-05-12 06:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0006_alter_assignment_coursedropdown'),
]
operations = [
migrations.RemoveField(
model_name='assignment',
name='section',
),
migrations.AddField(
model_name='course',
name='section',
field=models.CharField(default='', max_length=16),
),
]
...@@ -4,6 +4,7 @@ from django.db import models ...@@ -4,6 +4,7 @@ from django.db import models
class Course(models.Model): class Course(models.Model):
course_code = models.CharField(unique=True, default="", max_length=10,) course_code = models.CharField(unique=True, default="", max_length=10,)
course_title = models.CharField(unique=True, default="", max_length=50,) course_title = models.CharField(unique=True, default="", max_length=50,)
section = models.CharField(default="",max_length=16,)
def __str__(self): def __str__(self):
return '{} {}'.format(self.course_code, self.course_title,) return '{} {}'.format(self.course_code, self.course_title,)
...@@ -14,12 +15,12 @@ class Assignment(models.Model): ...@@ -14,12 +15,12 @@ class Assignment(models.Model):
description = models.TextField(default="") description = models.TextField(default="")
perfect_score = models.IntegerField(default=100) perfect_score = models.IntegerField(default=100)
passing_score = models.IntegerField(default=80) passing_score = models.IntegerField(default=80)
section = models.CharField(max_length=16,)
course = models.ForeignKey( course = models.ForeignKey(
Course, Course,
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name='subject' related_name='subject'
) )
courseDropDown = models.CharField(unique=True, default="", max_length=100, blank=True)
def __str__(self): def __str__(self):
return '{} {}-'.format(self.assignment_name, self.section,) return '{} {}-'.format(self.assignment_name, self.section,)
...@@ -27,6 +28,10 @@ class Assignment(models.Model): ...@@ -27,6 +28,10 @@ class Assignment(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return '{}'.format(self.pk) return '{}'.format(self.pk)
def save(self, *args, **kwargs):
self.courseDropDown = '{} - {}'.format(self.course.course_code, self.section)
super().save(*args, **kwargs) # Call the "real" save() method.
...@@ -20,7 +20,7 @@ class AssignmentsDetailView(DetailView): ...@@ -20,7 +20,7 @@ class AssignmentsDetailView(DetailView):
class AssignmentsUpdateView(UpdateView): class AssignmentsUpdateView(UpdateView):
model = Assignment model = Assignment
fields = ["assignment_name","description","course","perfect_score" ] fields = ["assignment_name","description","courseDropDown","perfect_score" ]
template_name = "assignments/assignment-edit.html" template_name = "assignments/assignment-edit.html"
success_url = "../details" success_url = "../details"
...@@ -28,7 +28,7 @@ class AssignmentsUpdateView(UpdateView): ...@@ -28,7 +28,7 @@ class AssignmentsUpdateView(UpdateView):
class AssignmentsCreateView(CreateView): class AssignmentsCreateView(CreateView):
model = Assignment model = Assignment
fields = ["assignment_name","description","course","perfect_score" ] fields = ["assignment_name","description","courseDropDown","perfect_score" ]
template_name = "assignments/assignment-add.html" template_name = "assignments/assignment-add.html"
def get_success_url(self): def get_success_url(self):
......
# Generated by Django 3.2 on 2023-05-12 05:00
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0002_reply_post'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 0, 44, 600788), editable=False),
),
migrations.AlterField(
model_name='reply',
name='post',
field=models.ForeignKey(default=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='forum.forumpost'),
),
]
# Generated by Django 3.2 on 2023-05-12 05:16
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0003_auto_20230512_1300'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 16, 35, 558089), editable=False),
),
]
# Generated by Django 3.2 on 2023-05-12 05:26
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0004_alter_forumpost_pub_datetime'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 26, 27, 568329), editable=False),
),
]
# Generated by Django 3.2 on 2023-05-12 05:33
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0005_alter_forumpost_pub_datetime'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 33, 51, 594255), editable=False),
),
]
# Generated by Django 3.2 on 2023-05-12 06:28
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0006_alter_forumpost_pub_datetime'),
]
operations = [
migrations.AlterField(
model_name='forumpost',
name='pub_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 14, 28, 15, 198274), editable=False),
),
]
# Generated by Django 3.2 on 2023-05-12 05:00
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0008_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 0, 44, 602793)),
),
]
# Generated by Django 3.2 on 2023-05-12 05:16
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0009_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 16, 35, 560192)),
),
]
# Generated by Django 3.2 on 2023-05-12 05:26
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0010_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 26, 27, 570448)),
),
]
# Generated by Django 3.2 on 2023-05-12 05:33
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0011_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 13, 33, 51, 596255)),
),
]
# Generated by Django 3.2 on 2023-05-12 06:28
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widget_calendar', '0012_alter_event_target_datetime'),
]
operations = [
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(default=datetime.datetime(2023, 5, 12, 14, 28, 15, 200372)),
),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment