From cf875ed687f7e0f89ea00fe61b7fb15773e30cff Mon Sep 17 00:00:00 2001 From: Praneeth Bhandaru Date: Sun, 13 Dec 2020 12:38:18 -0500 Subject: [PATCH] Added specific class view --- site/frontend/urls.py | 1 + site/frontend/views.py | 9 +++- site/templates/frontend/class.html | 32 +++++++++++++ site/templates/frontend/temp.html | 77 +++++++++++++++++++++++++++--- 4 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 site/templates/frontend/class.html diff --git a/site/frontend/urls.py b/site/frontend/urls.py index 1c6fa86a..91b82cdc 100644 --- a/site/frontend/urls.py +++ b/site/frontend/urls.py @@ -35,4 +35,5 @@ urlpatterns = [ path("create_user/", register_view, name="create_user"), path("", home_view, name="home"), path("classes", class_form_view, name="classroom_form"), + path("classes/", classroom_view, name="class") ] diff --git a/site/frontend/views.py b/site/frontend/views.py index c3a6cfb7..0dc63133 100644 --- a/site/frontend/views.py +++ b/site/frontend/views.py @@ -1,7 +1,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.shortcuts import redirect, render - +from django.http import HttpResponseForbidden from api.models import * from .forms import * @@ -58,3 +58,10 @@ def class_form_view(request): form = ClassroomForm return render(request, "frontend/classroomForm.html", {"form": form}) + + +def classroom_view(request, id): + classroom = Classroom.objects.get(id=id) + if classroom.student.user.pk != request.user.pk: + return HttpResponseForbidden('You do not have access to this class') + return render(request, "frontend/class.html", {'class': classroom}) diff --git a/site/templates/frontend/class.html b/site/templates/frontend/class.html new file mode 100644 index 00000000..086c1cd2 --- /dev/null +++ b/site/templates/frontend/class.html @@ -0,0 +1,32 @@ +{% extends 'frontend/index.html' %} +{% load static %} + +{% block content %} +
+ + +
+
+
+

+ Your Class: {{ class.name }}

+
+
+
+

+
+

Teacher: {{ class.teacher }}

+
+
+
+{% endblock content %} +{% block head %} + +{% endblock %} \ No newline at end of file diff --git a/site/templates/frontend/temp.html b/site/templates/frontend/temp.html index 5d74e855..949e13cc 100644 --- a/site/templates/frontend/temp.html +++ b/site/templates/frontend/temp.html @@ -21,10 +21,11 @@ LEARN MORE +
+
- @@ -36,19 +37,83 @@

CLASSES

- -
- -
+
+
+
{% for user_class in classes %} - {{ user_class }} +
+
+
+

{{ user_class.name }}

+

{{ user_class.teacher }};   Period: {{ user_class.period }}

+
{% endfor %}
+ +
+
+
{% endblock content %} +{% block head %} + +{% endblock %} + {% block js %} {% endblock js %} \ No newline at end of file