Commit 2dfd98ab authored by Ciella's avatar Ciella

Bugfix: string displays

parent 60c980e6
...@@ -7,9 +7,12 @@ class Course(models.Model): ...@@ -7,9 +7,12 @@ class Course(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
section = models.CharField(max_length=3) section = models.CharField(max_length=3)
def __str__(self): def format_course(self):
return '{} {} - {}'.format(self.code, self.title, self.section) return '{} {} - {}'.format(self.code, self.title, self.section)
def __str__(self):
return '{}-{}'.format(self.code, self.section)
class Assignment(models.Model): class Assignment(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
...@@ -22,8 +25,11 @@ class Assignment(models.Model): ...@@ -22,8 +25,11 @@ class Assignment(models.Model):
self.passing_score = int((self.perfect_score)*(0.60)) self.passing_score = int((self.perfect_score)*(0.60))
super(Assignment, self).save(*args, **kwargs) super(Assignment, self).save(*args, **kwargs)
def __str__(self): def format_assignment(self):
return '{}'.format(self.name) return '{}'.format(self.name)
def __str__(self):
return '{} {}: {}'.format(self.course.code, self.course.section, self.name)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk': self.pk}) return reverse('assignments:assignment-details', kwargs={'pk': self.pk})
\ No newline at end of file
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
</div> </div>
<div class="col-9 text-center"> <div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6"> <div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">{{ object }}</h1> <h1 class="display-3" style="font-size:50px; color:#052c65">{{ object.name }}</h1>
</div> </div>
<br> <br>
<div class="row p-2" style="background-color:#e3e4e6"> <div class="row p-2" style="background-color:#e3e4e6">
<h5 class="display-3" style="font-size:25px">{{ object.course }}</h5> <h5 class="display-3" style="font-size:25px">{{ object.course.format_course }}</h5>
</div> </div>
<br> <br>
<div class="row"> <div class="row">
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<br> <br>
{% for task in tasks %} {% for task in tasks %}
<a href="{{ task.get_absolute_url }}" class="link-dark; display-3" style="font-size:18px; color:#052c65"> <a href="{{ task.get_absolute_url }}" class="link-dark; display-3" style="font-size:18px; color:#052c65">
{{ task }}</a> {{ task.format_assignment }}</a>
<br> <br>
{% endfor %} {% endfor %}
<br><br> <br><br>
......
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