chore: change index page in assignment app from fbv to cbv

parent b3b95eda
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
{% block content %} {% block content %}
<h1> {{assignment.course.course_code}} {{assignment.course.course_title}} {{assignment.course.section}} </h1> <h1> {{assignment.course.course_code}} {{assignment.course.course_title}} {{assignment.course.section}} </h1>
<p> <p id = "detail">
{{assignment.name}} <br> {{assignment.name}} <br>
{{assignment.description}} <br> {{assignment.description}} <br>
{{assignment.max_points}} <br> Highest Possible Score: {{assignment.max_points}} <br>
{{assignment.passing_score}} <br> Passing Score: {{assignment.passing_score}} <br>
{% if assignment.image %} {% if assignment.image %}
<img src="{{ assignment.image.url }}"> <img src="{{ assignment.image.url }}">
......
from django.urls import path, include from django.urls import path, include
from . import views from . import views
from .views import AssignmentsPageView
urlpatterns = [ urlpatterns = [
path('', views.index, name = 'index'), path('', AssignmentsPageView.as_view(), name = 'index'),
#assignments/1/details #assignments/1/details
path("<int:assignment_id>/details/", views.detail, name='detail'), path("<int:assignment_id>/details/", views.detail, name='detail'),
#assignments/add #assignments/add
......
from msilib.schema import ListView
from unicodedata import name from unicodedata import name
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.views import View
from .models import Course, Assignment from .models import Course, Assignment
from .forms import AssignmentForm from .forms import AssignmentForm
# Create your views here. # Create your views here.
def index(request): class AssignmentsPageView(View):
course_list = Course.objects.order_by("course_code")
context = { def get(self, request):
course_list = Course.objects.order_by("course_code")
context = {
'course_list': course_list 'course_list': course_list
} }
return render(request, "assignments/index.html", context)
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