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. 28
      tildes/tildes/templates/intercooler/invite_code.jinja2
  2. 32
      tildes/tildes/templates/invite.jinja2
  3. 1
      tildes/tildes/views/user.py

28
tildes/tildes/templates/intercooler/invite_code.jinja2

@ -1,12 +1,18 @@
<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"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
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>
{% if num_remaining > 0 %}
<button
class="btn btn-primary"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
username=request.user.username,
) }}"
data-ic-replace-target="true"
>Generate new code ({{ num_remaining }} left)</button>
{% endif %}
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>

32
tildes/tildes/templates/invite.jinja2

@ -17,23 +17,29 @@
<div class="divider"></div> <div class="divider"></div>
<div class="code-gen-btn">
{% if request.user.invite_codes_remaining > 0 %}
<button
class="btn btn-primary"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
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 %} {% if codes %}
<p>You have the following invite codes active that have not been used yet:</p>
<p>You have the following invite codes active that have not been used yet:</p>
</div>
{% for code in codes %} {% for code in codes %}
<input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input> <input class="form-input input-lg input-invite-code" type="text" value="{{ code }}" readonly data-js-autoselect-input>
{% endfor %} {% endfor %}
{% endif %}
{% if request.user.invite_codes_remaining > 0 %}
<button
class="btn btn-primary"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
username=request.user.username,
) }}"
data-ic-replace-target="true"
>Generate new code ({{ request.user.invite_codes_remaining }} left)</button>
{% else %} {% else %}
<p>You don't currently have any invite codes available.</p>
</div>
{% endif %} {% endif %}
{% endblock %} {% 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.user_id == request.user.user_id,
UserInviteCode.invitee_id == None, # noqa UserInviteCode.invitee_id == None, # noqa
) )
.order_by(desc(UserInviteCode.created_time))
.all() .all()
) )

Loading…
Cancel
Save