Changed function names to avoid using __str__

parent b70a9fc9
...@@ -6,7 +6,8 @@ class Course(models.Model): ...@@ -6,7 +6,8 @@ class Course(models.Model):
course_title = models.CharField(max_length=50) course_title = models.CharField(max_length=50)
section = models.CharField(max_length=3) section = models.CharField(max_length=3)
def __str__(self): @property
def course_info(self):
return '{} {} {}'.format(self.course_code, self.course_title, self.section) return '{} {} {}'.format(self.course_code, self.course_title, self.section)
class Assignment(models.Model): class Assignment(models.Model):
...@@ -20,11 +21,12 @@ class Assignment(models.Model): ...@@ -20,11 +21,12 @@ class Assignment(models.Model):
def passing_score(self): def passing_score(self):
return self.max_points * 0.60 return self.max_points * 0.60
def __str__(self): @property
def assignment_info(self):
assignment = '<br>Assignment Name: {}'.format(self.name) assignment = '<br>Assignment Name: {}'.format(self.name)
assignment += '<br>Description: {}'.format(self.description) assignment += '<br>Description: {}'.format(self.description)
assignment += '<br>Perfect Score: {}'.format(self.max_points) assignment += '<br>Perfect Score: {}'.format(self.max_points)
assignment += '<br>Passing Score: {}'.format(self.passing_score) assignment += '<br>Passing Score: {}'.format(self.passing_score)
assignment += '<br>Course/Section: {}<br>'.format(self.course.__str__()) assignment += '<br>Course/Section: {}<br>'.format(self.course.course_info)
return assignment return assignment
\ No newline at end of file
...@@ -8,7 +8,7 @@ def index(request): ...@@ -8,7 +8,7 @@ def index(request):
def assignment_list(): def assignment_list():
final_list = '' final_list = ''
for a in range(len(Assignment.objects.all())): for a in range(len(Assignment.objects.all())):
final_list += '{}'.format(Assignment.objects.get(pk=a+1).__str__()) final_list += '{}'.format(Assignment.objects.get(pk=a+1).assignment_info)
return final_list return final_list
......
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