Commit a13a56d8 authored by Paul Angelo Sy's avatar Paul Angelo Sy

Added HTML Template for detail view in Assignments

parent 46151edc
<h1> {{course}} {{course.course_title}}</h1>
<li> Name: {{assignment.name}} </li>
<li> Description: {{assignment.description}} </li>
<li> Perfect Score: {{assignment.max_points}} </li>
<li> Passing Score: {{assignment.passing_score}} </li>
......@@ -5,7 +5,7 @@
{% for assignment in assignment_list %}
{% if assignment.course_code == course %}
<ul>
<li> <a href="/assignments/{{assignment.name}}/">{{assignment.name}}</a></li>
<li> <a href="{% url 'detail' assignment.name%}">{{assignment.name}}</a></li>
</ul>
{% endif %}
{% endfor %}
......
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from assignments.models import Assignment, Course
from django.shortcuts import render
from django.template import loader
......@@ -15,8 +15,15 @@ def index(request):
return HttpResponse(template.render(context, request))
def detail(request, name):
output = (str(Assignment.objects.get(name = name).course_code) + " ")
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).course_title) + " ")
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).section) + " ")
try:
assignment = Assignment.objects.get(name = name)
course = Course.objects.get(course_code = assignment.course_code)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
return HttpResponse(output)
template = loader.get_template("assignments/detail.html")
context = {
"assignment": assignment,
"course": course
}
return HttpResponse (template.render(context, request))
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