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): def subject_view(request, subject_url):
subject = get_object_or_404(Subject, url=subject_url) subject = get_object_or_404(Subject, url=subject_url)
return render(request, "subject.html", {"subject": subject, return render(request, "subject.html", {"subject": subject,
"courses": subject.courses.all()}) "courses": subject.courses.all().order_by("name")})
@login_required @login_required
def course_view(request, subject_url, course_url): 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) course = get_object_or_404(Course, url=course_url)
return render(request, "course.html", {"subject": subject, return render(request, "course.html", {"subject": subject,
"course": course, "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 @login_required
def tag_view(request, tag): def tag_view(request, tag):
tag = get_object_or_404(Tag, name=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 @login_required
def search_view(request): def search_view(request):

View File

@ -8,4 +8,4 @@ Course = apps.get_model("courses", "Course")
@login_required @login_required
def index_view(request): 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> </head>
<body id="page"> <body id="page">
<span class="bold size-4 my-2 josefin-sans text-center"> <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> </span>
<main> <main>
{% block disclaimer %}{% endblock %} {% block disclaimer %}{% endblock %}

View File

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