Removed unnecessary imports and updated the FBV implementation for /assignments/

parent d3fcdca9
from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment, Course from .models import Assignment
from .forms import AssignmentForm, CourseForm from .forms import AssignmentForm
class AssignmentDetailsView(DetailView): class AssignmentDetailsView(DetailView):
...@@ -27,16 +24,8 @@ class EditAssignmentView(UpdateView): ...@@ -27,16 +24,8 @@ class EditAssignmentView(UpdateView):
def index(request): def index(request):
output = f"Widget's assignments Page<br><br>" assignments = Assignment.objects.all()
count = Assignment.objects.all().count() context = {
'assignments': assignments
for i in range(1, count + 1): }
assignments = Assignment.objects.get(id=i) return render(request, 'assignments/assignments.html', context)
output += f"""Assignment Name: {assignments.name}<br>
Description: {assignments.description}<br>
Perfect Score: {assignments.perfect_score}<br>
Passing Score: {assignments.passing_score}<br>
Course/Section: {assignments.course.code} {assignments.course.title}-{assignments.course.section}<br>
<br>"""
return HttpResponse(output)
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