Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
bookshare
Commits
5c90508e
Commit
5c90508e
authored
Apr 08, 2016
by
Mark Stenglein
Browse files
Added method in Student model to fetch either full name or username if none present.
parent
cbb9d637
Changes
2
Hide whitespace changes
Inline
Side-by-side
bookshare/core/models.py
View file @
5c90508e
...
...
@@ -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
)
...
...
bookshare/core/templates/profile.html
View file @
5c90508e
{% 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 • {{ 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"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment