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 @@ ...@@ -5,7 +5,7 @@
{% for assignment in assignment_list %} {% for assignment in assignment_list %}
{% if assignment.course_code == course %} {% if assignment.course_code == course %}
<ul> <ul>
<li> <a href="/assignments/{{assignment.name}}/">{{assignment.name}}</a></li> <li> <a href="{% url 'detail' assignment.name%}">{{assignment.name}}</a></li>
</ul> </ul>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
......
from django.http import HttpResponse from django.http import HttpResponse, Http404
from assignments.models import Assignment, Course from assignments.models import Assignment, Course
from django.shortcuts import render from django.shortcuts import render
from django.template import loader from django.template import loader
...@@ -15,8 +15,15 @@ def index(request): ...@@ -15,8 +15,15 @@ def index(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def detail(request, name): def detail(request, name):
output = (str(Assignment.objects.get(name = name).course_code) + " ") try:
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).course_title) + " ") assignment = Assignment.objects.get(name = name)
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).section) + " ") 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