Added functions to return necessary URLs

parent 512987e6
from django.db import models
from django.urls import reverse
class Course(models.Model):
......@@ -6,6 +7,9 @@ class Course(models.Model):
title = models.CharField(max_length=255, blank=True, null=True)
section = models.CharField(max_length=3, blank=True, null=True)
def __str__(self):
return self.code + '-' + self.section
class Assignment(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
......@@ -17,3 +21,12 @@ class Assignment(models.Model):
def save(self, *args, **kwargs):
self.passing_score = int(self.perfect_score * 0.60)
super(Assignment, self).save(*args, **kwargs)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('assignments:assignments-item', kwargs={'pk': self.pk})
def get_update_url(self):
return reverse('assignments:assignments-edit', kwargs={'pk': self.pk})
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