Commit 6a309017 authored by kylemendozaa's avatar kylemendozaa

created assignment detail view

parent d942df4c
{% extends 'base.html' %}
{% load static %}
{% block title %}Assignments{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'assignments.css' %}">
{% endblock %}
{% block content %}
<h1>{{ assignment.course.course_code }} {{ assignment.course.course_title }} {{ assignment.course.section }}</h1>
<h2>{{ assignment.name }}</h2>
<p>{{ assignment.description }}</p>
{% if assignment.id == 1 %}
<img src="{% static 'assignment1.jpg' %}">
{% elif assignment.id == 2 %}
<img src="{% static 'assignment2.jpg' %}">
{% else %}
<img src="{% static 'code.jpg' %}">
{% endif %}
<p>Perfect Score: <span>{{ assignment.max_points }}</span></p>
<p>Passing Score: <span>{{ assignment.passing_score }}</span></p>
{% endblock %}
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<ul> <ul>
{% for assignment in course.assignments.all %} {% for assignment in course.assignments.all %}
<li> <li>
<a href="assignments/{{ assignment.id }}/details">{{ assignment.name }}</a> <a href="/assignments/{{ assignment.id }}/details">{{ assignment.name }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
from django.urls import path from django.urls import path
from .views import index from .views import index, AssignmentDetailView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-details')
] ]
app_name = 'assignments' app_name = 'assignments'
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.template import loader from django.template import loader
from django.views.generic.detail import DetailView
from .models import Assignment, Course from .models import Assignment, Course
...@@ -11,4 +12,7 @@ def index(request): ...@@ -11,4 +12,7 @@ def index(request):
"courses": Course.objects.order_by("course_code"), "courses": Course.objects.order_by("course_code"),
} }
template = loader.get_template("assignments/index.html") template = loader.get_template("assignments/index.html")
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
\ No newline at end of file
class AssignmentDetailView(DetailView):
model = 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