Added details view

parent e50b2b2a
......@@ -5,18 +5,35 @@ from .models import Assignment, Course
# Create your views here.
def index(request):
heading = 'ASSIGNMENTS:<br><br>'
assignments = Assignment.objects.all()
body = ''
course_list = Course.objects.order_by("course_code")
assignments_list = Assignment.objects.order_by("name")
context = {
"course_list": course_list,
"assignments_list": assignments_list,
}
return render(request, "assignments/assignments_list.html", context)
for assignment in assignments:
courses = Course.objects.filter(course_code__exact=assignment.course_code)
body += 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>'.format(
assignment.name, assignment.description, assignment.max_points, assignment.passing_score
)
for course in courses:
body += 'Course/Section: {} {} {}<br><br>'.format(
course.course_code, course.course_title, course.section
)
# heading = 'ASSIGNMENTS:<br><br>'
# assignments = Assignment.objects.all()
# body = ''
#
# for assignment in assignments:
# courses = Course.objects.filter(course_code__exact=assignment.course_code)
# body += 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>'.format(
# assignment.name, assignment.description, assignment.max_points, assignment.passing_score
# )
# for course in courses:
# body += 'Course/Section: {} {} {}<br><br>'.format(
# course.course_code, course.course_title, course.section
# )
#
# return HttpResponse(heading + body)
return HttpResponse(heading + body)
def detail(request, pk):
assignment = Assignment.objects.get(pk=pk)
course = Course.objects.get(course_code__exact=assignment.course_code)
context = {
"assignment": assignment,
"course": course,
}
return render(request, "assignments/assignments_detail.html", context)
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