Add details of assignments in respective pages

parent 3f697072
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{assignment.name}} | {{assignment.course.course_code}}</title>
</head>
<body>
<h1>Course/Section: {{assignment.course.course_code}} | {{assignment.course.course_title}} - {{assignment.course.section}}</h1>
<h2>Assignment Name: {{assignment.name}}</h2>
<p>
Description: {{assignment.description}}<br>
Perfect Score: {{assignment.max_points}}<br>
Passing Score: {{assignment.passing_score}}<br>
</p>
</body>
</html>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
{% for assignment in assignment_list %} {% for assignment in assignment_list %}
{% if assignment.course.course_code == course.course_code %} {% if assignment.course.course_code == course.course_code %}
<ul> <ul>
<li><a href="/assignments/{{assignment.id}}/details">{{assignment.name}}</a></li> <li><a href="{% url 'assignments:details' assignment.id %}">{{assignment.name}}</a></li>
</ul> </ul>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
......
...@@ -2,7 +2,8 @@ from django.urls import path ...@@ -2,7 +2,8 @@ from django.urls import path
from . import views from . import views
app_name="assignments"
urlpatterns = [ urlpatterns = [
path('', views.index, name="indexAssignments"), path('', views.index, name="index"),
path('<int:assignment_id>/details', views.detail, name="detail") path('<int:assignment_id>/details', views.details, name="details")
] ]
\ No newline at end of file
from ast import Assign from ast import Assign
from django.http import HttpResponse from django.http import HttpResponse, Http404
from django.shortcuts import render from django.shortcuts import render
from .models import Assignment, Course from .models import Assignment, Course
...@@ -15,6 +15,10 @@ def index(request): ...@@ -15,6 +15,10 @@ def index(request):
return render(request, "assignments/index.html", context) return render(request, "assignments/index.html", context)
def detail(request, assignment_id): def details(request, assignment_id):
output = "These are the details for assignment #%s." % assignment_id try:
return HttpResponse(output) assignment = Assignment.objects.get(pk=assignment_id)
\ No newline at end of file except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
return render(request, "assignments/detail.html", {"assignment": assignment})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment