Commit 666aec77 authored by Sherif's avatar Sherif

gave better method names for student name getters and changed empty name...

gave better method names for student name getters and changed empty name string checker to use boolean condition if(not) rather than if(==)
parent a3daba23
...@@ -215,23 +215,23 @@ class Student(TimeStampedModel): ...@@ -215,23 +215,23 @@ class Student(TimeStampedModel):
my_flag_num = Confirmation.objects.filter(student=self, lives_there=False).count() my_flag_num = Confirmation.objects.filter(student=self, lives_there=False).count()
return my_flag_num return my_flag_num
def get_first_name(self): def get_first_name_or_uname(self):
if self.user.get_short_name() == "": if not(self.user.get_short_name()):
return self.user.get_username() return self.user.get_username()
else: else:
return self.user.get_short_name() return self.user.get_short_name()
def get_last_name(self): def get_last_name_or_uname(self):
if self.user.last_name == "": if not(self.user.last_name):
return self.user.get_username() return self.user.get_username()
else: else:
return self.user.last_name return self.user.last_name
def get_full_name(self): def get_full_name_or_uname(self):
if self.user.get_full_name() == "": if not(self.user.get_full_name_or_uname()):
return self.user.get_username() return self.user.get_username()
else: else:
return self.user.get_full_name() return self.user.get_full_name_or_uname()
class Meta: class Meta:
ordering = ['user'] ordering = ['user']
......
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Flag {{ student.user.get_full_name }} {% endblock %} {% block title %} SRCT RoomList | Flag {{ student.user.get_full_name_or_uname }} {% endblock %}
{% block message_queue %} {% block message_queue %}
{% endblock %} {% endblock %}
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
<p class="lead text-center"> <p class="lead text-center">
<i class="fa fa-flag fa-lg"></i> <i class="fa fa-flag fa-lg"></i>
<strong> <strong>
{% if not student.user.get_full_name %} {% if not student.user.get_full_name_or_uname %}
Someone Someone
{% else %} {% else %}
{{ student.user.get_full_name }} {{ student.user.get_full_name_or_uname }}
{% endif %} {% endif %}
</strong> </strong>
<em>is in the wrong room!</em> <em>is in the wrong room!</em>
......
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
{% block title %} SRCT RoomList | Remove Flag {{ confirmation.student.user.get_full_name }} {% endblock %} {% block title %} SRCT RoomList | Remove Flag {{ confirmation.student.user.get_full_name_or_uname }} {% endblock %}
{% block message_queue %} {% block message_queue %}
{% endblock %} {% endblock %}
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
<i class="fa fa-flag fa-lg"></i> <i class="fa fa-flag fa-lg"></i>
Maybe Maybe
<strong> <strong>
{% if not confirmation.student.user.get_full_name %} {% if not confirmation.student.user.get_full_name_or_uname %}
Someone Someone
{% else %} {% else %}
{{ confirmation.student.user.get_full_name }} {{ confirmation.student.user.get_full_name_or_uname }}
{% endif %} {% endif %}
</strong> </strong>
<em>is in the correct room after all...</em> <em>is in the correct room after all...</em>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div> </div>
<div class="col-md-6 text-center"> <div class="col-md-6 text-center">
<h1><strong>{{ student.user.get_full_name }}</strong></h1> <h1><strong>{{ student.user.get_full_name_or_uname }}</strong></h1>
{% if shares %} {% if shares %}
<p class="lead"><strong> <p class="lead"><strong>
{% if student.room == None %} {% if student.room == None %}
......
{{ object.user.username }} {{ object.user.username }}
{{ object.user.get_full_name }} {{ object.user.get_full_name_or_uname }}
...@@ -45,7 +45,7 @@ SRCT Roomlist &bull; Search Students ...@@ -45,7 +45,7 @@ SRCT Roomlist &bull; Search Students
<h4>{{ result.object.user.username }}</h4> <h4>{{ result.object.user.username }}</h4>
</td> </td>
<td> <td>
<a href="{{ result.object.get_absolute_url }}"><h4><strong>{{ result.object.user.get_full_name }}</strong></h4></a> <a href="{{ result.object.get_absolute_url }}"><h4><strong>{{ result.object.user.get_full_name_or_uname }}</strong></h4></a>
</td> </td>
<td> <td>
{% if result.object.major %} {% if result.object.major %}
......
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
{% block title %} SRCT Roomlist | {{ student.get_full_name }} {% endblock %} {% block title %} SRCT Roomlist | {{ student.get_full_name_or_uname }} {% endblock %}
{% block messsage_queue %} {% block messsage_queue %}
{% endblock %} {% endblock %}
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-md-8 col-md-offset-2 text-center"> <div class="col-md-8 col-md-offset-2 text-center">
<img class="img-circle img-responsive center center-block" src="{{ student.profile_image_url }}" alt="{{ student.get_first_name }} Gravatar picture"> <img class="img-circle img-responsive center center-block" src="{{ student.profile_image_url }}" alt="{{ student.get_first_name_or_uname }} Gravatar picture">
<h1>{{ student.get_full_name }} , {{ student.user.username }}</h1> <h1>{{ student.get_full_name_or_uname }} , {{ student.user.username }}</h1>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h2><strong>Welcome, {{ me.get_first_name }}!</strong></h2> <h2><strong>Welcome, {{ me.get_first_name_or_uname }}!</strong></h2>
</div> </div>
</div> </div>
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
<div class="row"> <div class="row">
{% for student in students %} {% for student in students %}
<div class="col-sm-3 text-center"> <div class="col-sm-3 text-center">
<img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"> <img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.get_first_name_or_uname }} Gravatar picture">
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></a></h4> <h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.get_full_name_or_uname }}</strong></a></h4>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major.name }}</em></a></h5> <h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major.name }}</em></a></h5>
<h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</a></h5> <h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</a></h5>
{% if student.get_flag_count %} {% if student.get_flag_count %}
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
<div class="row"> <div class="row">
{% for student in students %} {% for student in students %}
<div class="col-sm-3 text-center"> <div class="col-sm-3 text-center">
<img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"> <img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.get_first_name_or_uname }} Gravatar picture">
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.first_name }} {{ student.user.last_name }}</strong></a></h4> <h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.get_full_name_or_uname }}</strong></a></h4>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major.name }}</em></a></h5> <h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major.name }}</em></a></h5>
{% if student.get_flag_count > 4 %} {% if student.get_flag_count > 4 %}
<p><em>* a number of other floormates say this info is incorrect</em></p> <p><em>* a number of other floormates say this info is incorrect</em></p>
......
{% extends 'layouts/base.html' %} {% block title %} SRCT Roomlist &bull; Homepage {% endblock %} {% block content %} {% extends 'layouts/base.html' %} {% block title %} SRCT Roomlist &bull; Homepage {% endblock %} {% block content %}
{% load cache %} {% load cache %}
{% load gravatar %} {% load gravatar %}
<h2>Welcome Back {{ me.get_first_name }}!</h2> <h2>Welcome Back {{ me.get_first_name_or_uname }}!</h2>
<legend></legend> <legend></legend>
{% if not me.room %} {% if not me.room %}
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<div class="row"> <div class="row">
{% for student in roomies %} {% for student in roomies %}
<div class="col-md-3"> <div class="col-md-3">
<a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.get_first_name}} Gravatar picture"></img></a> <a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.get_first_name_or_uname}} Gravatar picture"></img></a>
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.get_full_name }}</strong></a></h4> <h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.get_full_name_or_uname }}</strong></a></h4>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5> <h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5>
</div> </div>
{% empty %} {% empty %}
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
{% for student in floories %} {% for student in floories %}
<div class="col-md-3"> <div class="col-md-3">
<a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></a> <a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></a>
<h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.get_full_name }}</strong></a></h4> <h4><a href="{{ student.get_absolute_url }}"><strong>{{ student.user.get_full_name_or_uname }}</strong></a></h4>
<h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5> <h5><a href="{{ student.major.get_absolute_url }}"><em>{{ student.major }}</em></a></h5>
<h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</h5></a> <h5><a href="{{ student.room.get_absolute_url }}">{{ student.room }}</h5></a>
</div> </div>
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<!--{//% for student in majormates %} <!--{//% for student in majormates %}
<div class="col-md-3"> <div class="col-md-3">
<a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></a> <a href="{{ student.get_absolute_url }}"><img class="img-circle img-responsive center center-block" src="{% gravatar_url student.user.email 100 %}" alt="{{ student.user.first_name }} Gravatar picture"></a>
<h4><a href="{{ student.get_full_name }}"><strong>{{ student.user.get_full_name }}</strong></a></h4> <h4><a href="{{ student.get_full_name_or_uname }}"><strong>{{ student.user.get_full_name_or_uname }}</strong></a></h4>
</div> </div>
{//% empty %} {//% empty %}
<h4>There are no other students registered in your major right now.</h4> <h4>There are no other students registered in your major right now.</h4>
......
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