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