Commit 1e5668a8 authored by Paul Angelo Sy's avatar Paul Angelo Sy

Merge branch 'sy/assignments'

parents d2b1aecd 2bbb6db1
from django.urls import path from django.urls import path
from django.conf.urls.static import static from django.conf.urls.static import static
from . import views from . import views
from .views import AssignmentView
app_name="assignments" app_name="assignments"
urlpatterns = [ urlpatterns = [
path('', views.index, name="assignments"), path('', AssignmentView.as_view(), name="assignments"),
path("<int:assignment_id>/details", views.detail, name = "details"), path("<int:assignment_id>/details", views.detail, name = "details"),
path('newAssignment', views.newAssignment, name="newAssignment") path('newAssignment', views.newAssignment, name="newAssignment")
] ]
...@@ -3,17 +3,19 @@ from assignments.models import Assignment, Course ...@@ -3,17 +3,19 @@ from assignments.models import Assignment, Course
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.template import loader from django.template import loader
from .forms import AssignmentForm from .forms import AssignmentForm
from django.views import View
# Create your views here. # Create your views here.
def index(request): class AssignmentView(View):
course_list = Course.objects.order_by("course_code") def get(self, request):
assignment_list = Assignment.objects.all() course_list = Course.objects.order_by("course_code")
template = loader.get_template("assignments/index.html") assignment_list = Assignment.objects.all()
context = { # template = loader.get_template("assignments/index.html")
"course_list": course_list, context = {
"assignment_list": assignment_list "course_list": course_list,
} "assignment_list": assignment_list
return HttpResponse(template.render(context, request)) }
return render(request, "assignments/index.html", context)
def detail(request, assignment_id): def detail(request, assignment_id):
try: try:
......
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