Browse Source

Generate invite links instead of codes

This doesn't really change anything functionally, but it gives users
specific links that they can send out that will pre-fill the invite code
on the registration page, instead of requiring them to copy-paste it or
type it in themselves.
merge-requests/53/head
Deimos 6 years ago
parent
commit
49059e1dce
  1. 3
      tildes/scss/modules/_input.scss
  2. 8
      tildes/tildes/templates/intercooler/invite_code.jinja2
  3. 8
      tildes/tildes/templates/invite.jinja2
  4. 2
      tildes/tildes/templates/register.jinja2
  5. 5
      tildes/tildes/views/register.py

3
tildes/scss/modules/_input.scss

@ -2,5 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
.input-invite-code {
margin-bottom: 0.4rem;
font-size: 0.6rem;
margin-top: 0.4rem;
}

8
tildes/tildes/templates/intercooler/invite_code.jinja2

@ -4,7 +4,7 @@
<div class="code-gen-btn">
{% if num_remaining > 0 %}
<button
class="btn btn-primary"
class="btn btn-primary mb-2"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
username=request.user.username,
@ -13,9 +13,9 @@
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>
<p>You aren't able to generate more invite links right now.</p>
{% endif %}
<p>You have the following invite codes active that have not been used yet:</p>
<p>You have the following invite links 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>
<input class="form-input input-invite-code" type="text" value="{{ request.route_url("register", _query={"code": code}) }}" readonly data-js-autoselect-input>

8
tildes/tildes/templates/invite.jinja2

@ -23,7 +23,7 @@
<div class="code-gen-btn">
{% if request.user.invite_codes_remaining > 0 %}
<button
class="btn btn-primary"
class="btn btn-primary mb-2"
data-ic-get-from="{{ request.route_url(
'ic_user_invite_code',
username=request.user.username,
@ -32,14 +32,14 @@
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>
<p>You aren't able to generate more invite links right now.</p>
{% endif %}
{% if codes %}
<p>You have the following invite codes active that have not been used yet:</p>
<p>You have the following invite links 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>
<input class="form-input input-invite-code" type="text" value="{{ request.route_url("register", _query={"code": code}) }}" readonly data-js-autoselect-input>
{% endfor %}
{% else %}
</div>

2
tildes/tildes/templates/register.jinja2

@ -19,7 +19,7 @@
<div class="form-group">
<label class="form-label" for="invite_code"><strong>Invite Code</strong></label>
<input class="form-input" id="invite_code" name="invite_code" type="text" placeholder="Invite code">
<input class="form-input" id="invite_code" name="invite_code" type="text" placeholder="Invite code" value="{{ code }}">
</div>
<div class="form-group">

5
tildes/tildes/views/register.py

@ -25,11 +25,12 @@ from tildes.views.decorators import not_logged_in, rate_limit_view
@view_config(
route_name="register", renderer="register.jinja2", permission=NO_PERMISSION_REQUIRED
)
@use_kwargs({"code": String(missing="")})
@not_logged_in
def get_register(request: Request) -> dict:
def get_register(request: Request, code: str) -> dict:
"""Display the registration form."""
# pylint: disable=unused-argument
return {}
return {"code": code}
def user_schema_check_breaches(request: Request) -> UserSchema:

Loading…
Cancel
Save