Commit 653eb15b authored by Ciella's avatar Ciella

Bugfix for models, URLs, and views

parent 385eee3d
from django.db import models
from django.urls import reverse
# Create your models here.
class Course(models.Model):
......@@ -7,7 +8,7 @@ class Course(models.Model):
section = models.CharField(max_length=3)
def __str__(self):
return '{} {}'.format(self.code, self.section)
return '{} {} - {}'.format(self.code, self.title, self.section)
class Assignment(models.Model):
......@@ -22,4 +23,7 @@ class Assignment(models.Model):
super(Assignment, self).save(*args, **kwargs)
def __str__(self):
return '{} {}: {}'.format(self.course.code, self.course.section, self.name)
\ No newline at end of file
return '{}'.format(self.name)
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk': self.pk})
\ No newline at end of file
......@@ -3,10 +3,10 @@ from django.urls import path
from .views import assignments_view, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [
path('assignments/', assignments_view, name='assignments_view'),
path('assignments/<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-details'),
path('assignments/add/', AssignmentCreateView.as_view(), name='assignment-add'),
path('assignments/<int:pk>/edit/', AssignmentUpdateView.as_view(), name='assignment-edit'),
path('', assignments_view, name='assignments'),
path('<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentCreateView.as_view(), name='assignment-add'),
path('<int:pk>/edit/', AssignmentUpdateView.as_view(), name='assignment-edit'),
]
app_name = 'assignments'
\ No newline at end of file
......@@ -8,7 +8,7 @@ from .models import Assignment
def assignments_view(request):
tasks = Assignment.objects.all()
context = {'tasks' : tasks}
return render(request, 'assignments/assignments.html')
return render(request, 'assignments/assignments.html', context)
class AssignmentDetailView(DetailView):
......
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