Skip to content

Commit d96fff4

Browse files
author
Sam Redmond
committed
Minor UX tweaks. Adds more information on the HQ page and cleans up templating loops a bit
1 parent 7e0b956 commit d96fff4

File tree

5 files changed

+72
-54
lines changed

5 files changed

+72
-54
lines changed

app/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class User(db.Model):
3333
last_logged_in = db.Column(db.DateTime)
3434

3535
#Administrative
36-
role = db.Column(db.SmallInteger, default = ROLE_SUPER)
36+
role = db.Column(db.SmallInteger, default = ROLE_USER)
3737

3838
#Requests Made
3939
requests = db.relationship('Request', backref = 'author')

app/templates/admin.html

+10-23
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,19 @@ <h2>Users</h2>
2121
<dd>{{ momentjs(u.last_logged_in).format('LLLL') }}</dd>
2222
<dt>Tutoring</dt>
2323
<dd>
24-
{% for subj in u.tutoring %}
25-
{% if loop.first %}
26-
{{ subj.title }}
27-
{% else %}
28-
, {{ subj.title }}
29-
{% endif %}
24+
{% if u.tutoring|length > 0 %}
25+
{{ u.tutoring|join(", ", attribute='title')}}
3026
{% else %}
3127
Not tutoring any subjects.
32-
{% endfor %}
28+
{% endif %}
3329
</dd>
3430
<dt>Learning</dt>
3531
<dd>
36-
{% for subj in u.learning %}
37-
{% if loop.first %}
38-
{{ subj.title }}
39-
{% else %}
40-
, {{ subj.title }}
41-
{% endif %}
32+
{% if u.learning|length > 0 %}
33+
{{ u.learning|join(", ", attribute='title')}}
4234
{% else %}
43-
Not learning any subjects. This shouldn't ever happen.
44-
{% endfor %}
35+
Not learning any subjects.
36+
{% endif %}
4537
</dd>
4638
<dt>Requests</dt>
4739
<dd>
@@ -57,7 +49,6 @@ <h2>Users</h2>
5749
</dd>
5850
<dt>Role</dt>
5951
<dd>{{ u.role }}</dd>
60-
<div class="pull-right"> <button class="btn btn-small btn-info" value={{ u.id }}>Promote/Demote</button></div>
6152
</dl>
6253
</div>
6354
</div>
@@ -136,15 +127,11 @@ <h2>Subjects</h2>
136127
</dd>
137128
<dt>Requests</dt>
138129
<dd>
139-
{% for r in s.requests %}
140-
{% if loop.first %}
141-
{{ r.title }}
142-
{% else %}
143-
, {{ r.title }}
144-
{% endif %}
130+
{% if s.requests|length > 0 %}
131+
{{ s.requests|join(", ", attribute='title')}}
145132
{% else %}
146133
No requests available.
147-
{% endfor %}
134+
{% endif %}
148135
</dd>
149136
</dl>
150137
</div>

app/templates/layout.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@
131131
<ul class="dropdown-menu">
132132
<li class="nav-header">Go To</li>
133133
<li><a href={{ url_for('me') }}>My Headquarters</a></li>
134-
<li><a href={{ url_for('show_user', user_id=g.user.id) }}>My Profile</a></li>
134+
<li><a href={{ url_for('show_user', user_id=g.user.id) }}>My Public Profile</a></li>
135135
<li class="divider"></li>
136136
<li class="nav-header">Options</li>
137137
<li><a href={{ url_for('learn') }}>Learn Now</a></li>
138138
<li><a href={{ url_for('teach') }}>Teach Now</a></li>
139+
<li><a href={{ url_for('teach') }}>Edit my Profile</a></li>
139140
</ul>
140141
</li>
141142
</ul>

app/templates/me.html

+41-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
11
{% extends "layout.html" %}
22
{% block content %}
3-
<h1>{{ g.user.first_name}}'s Headquarters</h1>
4-
<div class="well">
5-
<p>Hey {{ g.user.first_name }}, thanks for stopping by! If you need to learn</p>
3+
<h1>{{ g.user.first_name}}'s HQ</h1>
4+
<div class="alert alert-info">
5+
Hey {{ g.user.first_name }}, thanks for stopping by! Are you ready to get started? Click on one of the buttons below to begin.
66
</div>
7-
<ul>
8-
<li><a href={{ url_for('learn') }}>Learn</a></li>
9-
<li><a href={{ url_for('teach') }}>Teach</a></li>
10-
</ul>
7+
<div class="row-fluid">
8+
<a href= {{ url_for('learn') }} class="btn btn-primary btn-large span6">Learn &raquo;</a>
9+
<a href= {{ url_for('teach') }} class="btn btn-success btn-large span6">Teach &raquo;</a>
10+
</div>
11+
<hr />
12+
<h3>Account Information<small> <a href={{ url_for('edit') }}>Edit my profile</a></small></h3>
13+
<dl class="dl-horizontal">
14+
<dt>Grade</dt>
15+
<dd>{{ g.user.grade }}</dd>
16+
<dt>Created</dt>
17+
<dd>{{ momentjs(g.user.created).format('LLLL') }}</dd>
18+
<dt>Last Logged In</dt>
19+
<dd>{{ momentjs(g.user.last_logged_in).format('LLLL') }}</dd>
20+
<dt>Tutoring</dt>
21+
<dd>
22+
{% if g.user.tutoring|length > 0 %}
23+
{{ g.user.tutoring|join(", ", attribute='title') }}
24+
{% else %}
25+
<span class='text-error'>You aren't signed up to tutor any subjects. Why don't you <a href={{ url_for('edit') }}>edit your profile</a> now?</span>
26+
{% endif %}
27+
</dd>
28+
<dt>Learning</dt>
29+
<dd>
30+
{% if g.user.learning|length > 0 %}
31+
{{ g.user.learning|join(", ", attribute='title') }}
32+
{% else %}
33+
<span class='text-error'>You aren't signed up as learning any subjects. Why don't you <a href={{ url_for('edit') }}>edit your profile</a> now?</span>
34+
{% endif %}
35+
</dd>
36+
<dt>Requests</dt>
37+
<dd>
38+
{% if g.user.requests|length > 0 %}
39+
{{ g.user.requests|join(", ", attribute='title') }}
40+
{% else %}
41+
<span class='text-error'>Looks like you haven't requested any help? Why don't you <a href={{ url_for('learn') }}>begin</a> now?</span>
42+
{% endif %}
43+
</dd>
44+
</dl>
1145
{% endblock %}

app/templates/view_user.html

+18-22
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,28 @@ <h2>Basic Information</h2>
88
{{ user.first_name }} is in {{ user.grade }}th grade. He/she has a role of {{ user.role }} on this website.
99
<h2>Classes</h2>
1010
<h4>Tutoring</h4>
11-
{{ user.first_name}} has generously offered to tutor {{ user.tutoring|length }} math and science class(es)! He/she can tutor:<br />
12-
{% for subj in user.tutoring %}
13-
{% if loop.first %}
14-
{{ subj.title }}
15-
{% else %}
16-
, {{ subj.title }}
17-
{% endif %}
11+
{% if user.tutoring|length > 0 %}
12+
{{ user.first_name}} has generously offered to tutor {{ user.tutoring|length }} math and science class(es)! He/she can tutor:<br />
13+
{{ g.user.tutoring|join(", ", attribute='title') }}
1814
{% else %}
19-
{{ user.first_name }} {{ user.last_name }} is not tutoring any subjects.
20-
{% endfor %}
15+
{{ user.first_name }} is not tutoring any subjects.
16+
{% endif %}
2117
<h4>Learning</h4>
22-
{{ user.first_name}} is taking {{ user.learning|length }} math and science class(es) this year! He/she is taking:<br />
23-
{% for subj in user.learning %}
24-
{% if loop.first %}
25-
{{ subj.title }}
26-
{% else %}
27-
, {{ subj.title }}
28-
{% endif %}
18+
{% if user.learning|length > 0 %}
19+
{{ user.first_name}} is taking {{ user.learning|length }} math and science class(es) this year! He/she is taking:<br />
20+
{{ g.user.learning|join(", ", attribute='title') }}
2921
{% else %}
30-
{{ user.first_name }} is not learning any subjects. This shouldn't ever happen.
31-
{% endfor %}
22+
{{ user.first_name }} is not signed up for any math/science subjects this year.
23+
{% endif %}
3224
<h2>Requests</h2>
33-
{{ user.first_name}} has made {{ user.requests|length }} request(s) for help. For privacy reasons, we don't divulge each individual request.
25+
{% if user.requests|length > 0 %}
26+
{{ user.first_name}} has made {{ user.requests|length }} request(s) for help. For privacy reasons, we don't divulge each individual request.
27+
{% else %}
28+
{{ user.first_name }} has not requested any help.
29+
{% endif %}
3430
{% else %}
35-
<div class="alert alert-error">
36-
<strong>Error!</strong> The specified user does not exist in the database.
37-
</div>
31+
<div class="alert alert-error">
32+
<strong>Error!</strong> The specified user does not exist in the database.
33+
</div>
3834
{% endif %}
3935
{% endblock %}

0 commit comments

Comments
 (0)