Skip to content

Commit

Permalink
added alphabetical ordering to models
Browse files Browse the repository at this point in the history
  • Loading branch information
dabslee committed Sep 7, 2021
1 parent fe3da80 commit c02f862
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 3 deletions.
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified forum/__pycache__/models.cpython-39.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions forum/migrations/0023_auto_20210907_1016.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.1.6 on 2021-09-07 15:16

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('forum', '0022_auto_20210906_1444'),
]

operations = [
migrations.AlterModelOptions(
name='assignment',
options={'ordering': ['end_datetime', 'title']},
),
]
Binary file not shown.
2 changes: 1 addition & 1 deletion forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Assignment(models.Model):
description = QuillField()
total_points = models.FloatField(null=True, blank=True)
class Meta:
ordering = ['end_datetime']
ordering = ['end_datetime', 'title']

def __str__(self):
return self.title
Expand Down
Binary file modified forum/views_folder/__pycache__/views_assignments.cpython-39.pyc
Binary file not shown.
Binary file modified forum/views_folder/__pycache__/views_courses.cpython-39.pyc
Binary file not shown.
Binary file modified forum/views_folder/__pycache__/views_modules.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion forum/views_folder/views_courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def courses(request):
return redirect("forum:courses")
else:
context["error"] = "Course not found."
context["courses"] = Course.objects.filter(Q(owner=request.user) | Q(students=request.user)).distinct()
context["courses"] = Course.objects.filter(Q(owner=request.user) | Q(students=request.user)).distinct().order_by("name")
context["form"] = forms.JoinCourseForm()
return render(request, "courses.html", context)

Expand Down
2 changes: 1 addition & 1 deletion forum/views_folder/views_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def modules(request):
assn.module = AssignmentModule.objects.get(id=moduleid)
assn.save()
context["modules"] = [ModuleWrapper("No module", 0, Assignment.objects.filter(course=course, module=None))]
for module in AssignmentModule.objects.filter(course=course):
for module in AssignmentModule.objects.filter(course=course).order_by("name"):
context["modules"].append(ModuleWrapper(module.name, module.id, Assignment.objects.filter(course=course, module=module).order_by("end_datetime")))
return render(request, "modules.html", context)

Expand Down

0 comments on commit c02f862

Please sign in to comment.