Browse Source
Remove num_active_invite_codes
merge-requests/8/head
Ivan Fonseca
8 years ago
No known key found for this signature in database
GPG Key ID: 95A9C856EC788689
2 changed files with
5 additions and
18 deletions
-
tildes/tildes/templates/macros/user_menu.jinja2
-
tildes/tildes/views/user.py
|
|
|
@ -51,13 +51,13 @@ |
|
|
|
|
|
|
|
<li>Misc</li> |
|
|
|
<ul class="nav"> |
|
|
|
{% if request.user.invite_codes_remaining or num_active_invite_codes|default(0) %} |
|
|
|
<li class="nav-item {{ 'active' if route == 'invite' else '' }}"> |
|
|
|
<strong><a href="/invite"> |
|
|
|
Invite someone ({{ request.user.invite_codes_remaining + num_active_invite_codes|default(0) }}) |
|
|
|
</a></strong> |
|
|
|
{% if request.user.invite_codes_remaining %}<strong>{% endif %} |
|
|
|
<a href="/invite"> |
|
|
|
Invite someone {% if request.user.invite_codes_remaining %}({{ request.user.invite_codes_remaining }}){% endif %} |
|
|
|
</a> |
|
|
|
{% if request.user.invite_codes_remaining %}</strong>{% endif %} |
|
|
|
</li> |
|
|
|
{% endif %} |
|
|
|
<li class="nav-item {{ 'active' if route == 'settings' else '' }}"> |
|
|
|
<a href="/settings"> |
|
|
|
Settings |
|
|
|
|
|
|
|
@ -54,22 +54,9 @@ def get_user(request: Request) -> dict: |
|
|
|
) |
|
|
|
merged_posts = merged_posts[:page_size] |
|
|
|
|
|
|
|
# if the user is on their own page, check if they have active invite codes |
|
|
|
num_active_invite_codes = None |
|
|
|
if user == request.user: |
|
|
|
num_active_invite_codes = ( |
|
|
|
request.query(UserInviteCode) |
|
|
|
.filter( |
|
|
|
UserInviteCode.user_id == request.user.user_id, |
|
|
|
UserInviteCode.invitee_id == None, # noqa |
|
|
|
) |
|
|
|
.count() |
|
|
|
) |
|
|
|
|
|
|
|
return { |
|
|
|
'user': user, |
|
|
|
'merged_posts': merged_posts, |
|
|
|
'num_active_invite_codes': num_active_invite_codes, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|