added form page, reflected name changes of other pages

parent 9bdbde1f
from django.urls import path
from .views import ListView_view, DetailView_view
from .views import ListView, DetailView, AssignmentCreateView
urlpatterns = [
path('', ListView_view),
path('<int:pk>/details', DetailView_view)
path('', ListView),
path('<int:pk>/details', DetailView),
path('add', AssignmentCreateView.as_view()),
]
app_name = "assignments"
from django.shortcuts import render
from .models import Assignment, Course
from django.http import Http404
from django.views.generic.edit import CreateView
def ListView_view(request, *args, **kwargs):
def ListView(request, *args, **kwargs):
list_context = {
"all_courses": Course.objects.all().order_by('code')
}
return render(request, "assignments/ListView.html", list_context)
return render(request, "assignments/assignment_list.html", list_context)
def DetailView_view(request, pk):
def DetailView(request, pk):
if Assignment.objects.filter(id=pk).exists():
detailed_context = {
"assignment": Assignment.objects.get(id=pk)
}
return render(request, "assignments/DetailView.html", detailed_context)
return render(
request, "assignments/assignment_detail.html",
detailed_context
)
else:
raise Http404('Assignment does not exist.')
class AssignmentCreateView(CreateView):
model = Assignment
fields = ["name", "description", "max_points", "image", "course"]
def get_success_url(self):
return "/assignments/"
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