Commit ab553878 authored by rachbit's avatar rachbit

created assignment-details, updated models and views

parent ed4e7984
from django.db import models
from django.urls import reverse
class Course(models.Model):
......@@ -21,3 +22,6 @@ class Assignment(models.Model):
def passing_score(self):
return (self.perfect_score * 60)//100
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk':self.pk})
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.name }} {% endblock %}
{% block content %}
<div style="text-transform:uppercase;">
<h1>{{ object.name }}</h1>
</div>
<h2>
{{ object.course.code }} {{ object.course.title }}-{{ object.course.section }}
</h2>
<div>
Description: {{ object.description }}<br>
Perfect Score: {{ object.perfect_score }}<br>
Passing Score: {{ object.passing_score }}<br>
</div>
<br>
<a href="../#/">
<button type="button"><p>Edit Assignment</p></button>
</a>
{% endblock %}
from django.urls import path
from .views import index
from .views import *
urlpatterns = [
path('', index, name='index'),
path('<int:pk>/details', AssignmentsDetailView.as_view(), name='assignment-details'),
]
# This might be needed, depending on your Django version
app_name = "assignments"
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import ListView, DetailView, CreateView, UpdateView
from .models import Assignment, Course
def index(request):
assignments = Assignment.objects.all()
args = {'assignments':assignments}
return render(request, 'assignments/assignments.html', args)
class AssignmentsView(ListView):
model = Assignment
template_name = 'assignments/assignments.html'
class AssignmentsDetailView(DetailView):
model = Assignment
template_name = 'assignments/assignment-details.html'
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