diff --git a/studyguides/apps/courses/models.py b/studyguides/apps/courses/models.py index 2917eec..eeee663 100644 --- a/studyguides/apps/courses/models.py +++ b/studyguides/apps/courses/models.py @@ -1,8 +1,6 @@ from django.db import models from django.core.validators import RegexValidator, FileExtensionValidator -# Create your models here. - class Subject(models.Model): id = models.AutoField(primary_key=True) diff --git a/studyguides/apps/courses/urls.py b/studyguides/apps/courses/urls.py index df7665f..5218b3c 100644 --- a/studyguides/apps/courses/urls.py +++ b/studyguides/apps/courses/urls.py @@ -5,5 +5,6 @@ from . import views app_name = "courses" urlpatterns = [ - path("/", views.subject_view) + path("/", views.subject_view), + path("//", views.course_view), ] diff --git a/studyguides/apps/courses/views.py b/studyguides/apps/courses/views.py index db0d1c7..38e2d24 100644 --- a/studyguides/apps/courses/views.py +++ b/studyguides/apps/courses/views.py @@ -6,7 +6,15 @@ from django.shortcuts import render, redirect, reverse, get_object_or_404 from .models import Subject, Course, Guide -def subject_view(request, subject_name): - print(subject_name) - subject = get_object_or_404(Subject, url=subject_name) - return render(request, "subject.html", {"subject": subject, "courses": subject.courses.all()}) +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()}) + + +def course_view(request, subject_url, course_url): + subject = get_object_or_404(Subject, url=subject_url) + course = get_object_or_404(Course, url=course_url) + return render(request, "course.html", {"subject": subject, + "course": course, + "guides": Guide.objects.filter(course=course)}) diff --git a/studyguides/static/base.css b/studyguides/static/base.css index 5002eb9..79d4cf2 100644 --- a/studyguides/static/base.css +++ b/studyguides/static/base.css @@ -28,3 +28,11 @@ main { .color-primary { color: #568ea3; } + +h1 { + opacity: 0.5; + transition: all 0.2s ease; +} +h1:hover { + opacity: 1; +} diff --git a/studyguides/templates/course.html b/studyguides/templates/course.html index e69de29..dc9da96 100644 --- a/studyguides/templates/course.html +++ b/studyguides/templates/course.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} {% block main %} +
+

{{subject.name}} / {{ course.name }}

+ {% for guide in guides %} +

{{ guide.name }}

+ {% endfor %} +
+{% endblock %} diff --git a/studyguides/templates/home.html b/studyguides/templates/home.html index e802711..d566e1d 100644 --- a/studyguides/templates/home.html +++ b/studyguides/templates/home.html @@ -1,5 +1,7 @@ {% extends "base.html" %} {% block main %}
+

Subjects

+ {% for subject, courses in subjects %}

{{ subject.name }}

diff --git a/studyguides/templates/subject.html b/studyguides/templates/subject.html index a32e2b4..8e58ec0 100644 --- a/studyguides/templates/subject.html +++ b/studyguides/templates/subject.html @@ -1,9 +1,8 @@ {% extends "base.html" %} {% block main %}
+

{{ subject.name }}

{% for course in courses %} -

{{ course.name }}

- {% endfor %}
{% endblock %}