From b0d2be5eebeb20410861d095b780e5d81afad066 Mon Sep 17 00:00:00 2001 From: Shane Moore Date: Mon, 23 Jul 2018 23:17:33 -0400 Subject: [PATCH] Invite page: Move codes below button and sort The codes weren't in any defined order previously, so this sorts them to put the newest ones at the top, and also moves the button above. --- .../templates/intercooler/invite_code.jinja2 | 28 +++++++++------- tildes/tildes/templates/invite.jinja2 | 32 +++++++++++-------- tildes/tildes/views/user.py | 1 + 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/tildes/tildes/templates/intercooler/invite_code.jinja2 b/tildes/tildes/templates/intercooler/invite_code.jinja2 index dd81f1f..5f4a7f7 100644 --- a/tildes/tildes/templates/intercooler/invite_code.jinja2 +++ b/tildes/tildes/templates/intercooler/invite_code.jinja2 @@ -1,12 +1,18 @@ - +
+ {% if num_remaining > 0 %} + + {% else %} +

You don't currently have any invite codes available.

+ {% endif %} +

You have the following invite codes active that have not been used yet:

+
-{% if num_remaining > 0 %} - -{% endif %} + diff --git a/tildes/tildes/templates/invite.jinja2 b/tildes/tildes/templates/invite.jinja2 index 4689995..e8b0f33 100644 --- a/tildes/tildes/templates/invite.jinja2 +++ b/tildes/tildes/templates/invite.jinja2 @@ -17,23 +17,29 @@
+
+ {% if request.user.invite_codes_remaining > 0 %} + + {% else %} +

You don't currently have any invite codes available.

+ {% endif %} + {% if codes %} -

You have the following invite codes active that have not been used yet:

+

You have the following invite codes active that have not been used yet:

+
{% for code in codes %} {% endfor %} -{% endif %} - -{% if request.user.invite_codes_remaining > 0 %} - {% else %} -

You don't currently have any invite codes available.

+ {% endif %} + {% endblock %} diff --git a/tildes/tildes/views/user.py b/tildes/tildes/views/user.py index 3b3da0b..220a4d4 100644 --- a/tildes/tildes/views/user.py +++ b/tildes/tildes/views/user.py @@ -70,6 +70,7 @@ def get_invite(request: Request) -> dict: UserInviteCode.user_id == request.user.user_id, UserInviteCode.invitee_id == None, # noqa ) + .order_by(desc(UserInviteCode.created_time)) .all() )