Added details view

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