Commit 8dd5776e authored by Sherif's avatar Sherif

added 3 methods in the Student class to retreive first, last, and full name...

added 3 methods in the Student class to retreive first, last, and full name with the ability to fall back on username if student name is  empty string.
parent 1028479c
......@@ -214,6 +214,24 @@ class Student(TimeStampedModel):
def get_flag_count(self):
my_flag_num = Confirmation.objects.filter(student=self, lives_there=False).count()
return my_flag_num
def get_first_name(self):
if self.user.get_short_name() == "":
return self.user.get_username()
else:
return self.user.get_short_name()
def get_last_name(self):
if self.user.last_name == "":
return self.user.get_username()
else:
return self.user.last_name
def get_full_name(self):
if self.user.get_full_name() == "":
return self.user.get_username()
else:
return self.user.get_full_name()
class Meta:
ordering = ['user']
......@@ -223,7 +241,7 @@ class Student(TimeStampedModel):
def __unicode__(self):
return unicode(self.user.username)
# def save(self, *args, **kwargs):
#print('we be savin\'!')
#from django.db.models.signals import pre_save, post_save
......
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