Browse Source

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.
merge-requests/19/head
Shane Moore 6 years ago
committed by Deimos
parent
commit
b0d2be5eeb
  1. 10
      tildes/tildes/templates/intercooler/invite_code.jinja2
  2. 20
      tildes/tildes/templates/invite.jinja2
  3. 1
      tildes/tildes/views/user.py

10
tildes/tildes/templates/intercooler/invite_code.jinja2

@ -1,5 +1,4 @@
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>
<div class="code-gen-btn">
{% if num_remaining > 0 %}
<button
class="btn btn-primary"
@ -8,5 +7,12 @@
username=request.user.username,
) }}"
data-ic-replace-target="true"
data-ic-target=".code-gen-btn"
>Generate new code ({{ num_remaining }} left)</button>
{% else %}
<p>You don't currently have any invite codes available.</p>
{% endif %}
<p>You have the following invite codes active that have not been used yet:</p>
</div>
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>

20
tildes/tildes/templates/invite.jinja2

@ -17,13 +17,7 @@
<div class="divider"></div>
{% if codes %}
<p>You have the following invite codes active that have not been used yet:</p>
{% for code in codes %}
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>
{% endfor %}
{% endif %}
<div class="code-gen-btn">
{% if request.user.invite_codes_remaining > 0 %}
<button
class="btn btn-primary"
@ -32,8 +26,20 @@
username=request.user.username,
) }}"
data-ic-replace-target="true"
data-ic-target=".code-gen-btn"
>Generate new code ({{ request.user.invite_codes_remaining }} left)</button>
{% else %}
<p>You don't currently have any invite codes available.</p>
{% endif %}
{% if codes %}
<p>You have the following invite codes active that have not been used yet:</p>
</div>
{% for code in codes %}
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>
{% endfor %}
{% else %}
</div>
{% endif %}
{% endblock %}

1
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()
)

Loading…
Cancel
Save