Commit 5c90508e authored by Mark Stenglein's avatar Mark Stenglein

Added method in Student model to fetch either full name or username if none present.

parent cbb9d637
......@@ -19,6 +19,12 @@ class Student(TimeStampedModel):
emails_sent = models.PositiveIntegerField(default=0)
def get_full_name(self):
if (self.user.get_full_name() == ""):
return self.user.username
else:
return self.user.get_full_name()
def has_nickname(self):
pf_name = "%s %s" % (self.pf_first_name, self.pf_last_name)
......
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • {{ student.user.get_full_name }}
{% if student.user.get_full_name == "" %}
SRCT Bookshare • {{ student.user.username }}
{% else %}
SRCT Bookshare • {{ student.user.get_full_name }}
{% endif %}
{% endblock title %}
{% block content %}
......@@ -17,7 +21,11 @@ SRCT Bookshare • {{ student.user.get_full_name }}
<img class="img-circle img-responsive" src="{% gravatar_url student.user.email 75 %}">
</div>
<div class="col-md-6">
<h2><strong>{{ student.user.get_full_name }}</strong>
{% if student.user.get_full_name == "" %}
<h2><strong>{{ student.user.username }}</strong>
{% else %}
<h2><strong>{{ student.user.get_full_name }}</strong>
{% endif %}
{% if student.user == request.user %}
<small><a href="{% url 'name_change' %}">(Edit)</a></small>
{% endif %}
......@@ -37,7 +45,11 @@ SRCT Bookshare &bull; {{ student.user.get_full_name }}
{% endfor %}
</h3></a>
{% else %}
<small>{{ student.user.first_name }} has no ratings yet.</small>
{% if student.user.get_full_name == "" %}
<small>{{ student.user.username }} has no ratings yet.</small>
{% else %}
<small>{{ student.user.first_name }} has no ratings yet.</small>
{% endif %}
{% endif %}
</div>
<div class="col-md-2 text-right">
......
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