alphabetize

This commit is contained in:
lauren 2020-11-12 19:49:28 -05:00
parent b626fcae41
commit d131dccfb5
4 changed files with 6 additions and 13 deletions

View File

@ -13,7 +13,7 @@ from .models import Subject, Course, Guide, Tag
def subject_view(request, subject_url):
subject = get_object_or_404(Subject, url=subject_url)
return render(request, "subject.html", {"subject": subject,
"courses": subject.courses.all()})
"courses": subject.courses.all().order_by("name")})
@login_required
def course_view(request, subject_url, course_url):
@ -21,12 +21,12 @@ def course_view(request, subject_url, course_url):
course = get_object_or_404(Course, url=course_url)
return render(request, "course.html", {"subject": subject,
"course": course,
"guides": [[g, g.tags.all()] for g in Guide.objects.filter(course=course)]})
"guides": [[g, g.tags.all()] for g in Guide.objects.filter(course=course).order_by("name")]})
@login_required
def tag_view(request, tag):
tag = get_object_or_404(Tag, name=tag)
return render(request, "tag.html", {"tag": tag, "guides": [[g, g.tags.all()] for g in tag.guide.all()]})
return render(request, "tag.html", {"tag": tag, "guides": [[g, g.tags.all()] for g in tag.guide.all().order_by("name")]})
@login_required
def search_view(request):

View File

@ -8,4 +8,4 @@ Course = apps.get_model("courses", "Course")
@login_required
def index_view(request):
return render(request, "home.html", {"subjects": [(subject, Course.objects.filter(subject=subject)) for subject in Subject.objects.all()]})
return render(request, "home.html", {"subjects": Subject.objects.all().order_by("name")})

View File

@ -25,7 +25,7 @@
</head>
<body id="page">
<span class="bold size-4 my-2 josefin-sans text-center">
TJHSST Study Guide Collection
<a href="{% url 'home:index' %}">TJHSST Study Guide Collection</a>
</span>
<main>
{% block disclaimer %}{% endblock %}

View File

@ -11,20 +11,13 @@
{% block content %}
<div class="flex-col">
{% for subject, courses in subjects %}
{% for subject in subjects %}
<div class="subject">
<a
href="{% url 'courses:subject_view' subject.url %}"
class="bold size-3">
📚 {{ subject.name }}
</a>
<!-- {% for course in courses %}
<p class="item">
<a href="{% url 'courses:course_view' subject.url course.url %}">
{{ course.name }}
</a>
</p>
{% endfor %} -->
</div>
{% endfor %}
</div>