Ignore request flow

This commit is contained in:
Mouse Reeve 2021-03-21 08:17:48 -07:00
parent 81ab73f309
commit 5297b9d796
4 changed files with 36 additions and 11 deletions

View file

@ -16,7 +16,8 @@
<ul class="menu-list"> <ul class="menu-list">
<li> <li>
{% url 'settings-invites' as url %} {% url 'settings-invites' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Invites" %}</a> {% url 'settings-invite-requests' as alt_url %}
<a href="{{ url }}"{% if url in request.path or request.path in alt_url %} class="is-active" aria-selected="true"{% endif %}>{% trans "Invites" %}</a>
</li> </li>
<li> <li>
{% url 'settings-reports' as url %} {% url 'settings-reports' as url %}

View file

@ -6,19 +6,25 @@
<div class="tabs"> <div class="tabs">
<ul> <ul>
{% url 'settings-invites' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invites" %}</a>
</li>
{% url 'settings-invite-requests' as url %} {% url 'settings-invite-requests' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}> <li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invite Requests" %}</a> <a href="{{ url }}">{% trans "Invite Requests" %}</a>
</li> </li>
{% url 'settings-invites' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invites" %}</a>
</li>
</ul> </ul>
</div> </div>
<section class="block"> <section class="block">
<h2 class="title is-4">{% trans "Invite Requests" %}</h2> <h2 class="title is-4">
{% if ignored %}
{% trans "Ignored Invite Requests" %}
{% else %}
{% trans "Invite Requests" %}
{% endif %}
</h2>
<table class="table is-striped"> <table class="table is-striped">
<tr> <tr>
@ -55,8 +61,13 @@
</form> </form>
<form name="ignore-request" method="post" action="{% url 'settings-invite-requests-ignore' %}"> <form name="ignore-request" method="post" action="{% url 'settings-invite-requests-ignore' %}">
{% csrf_token %}
<input type="hidden" name="invite-request" value="{{ req.id }}"> <input type="hidden" name="invite-request" value="{{ req.id }}">
{% if not req.ignored %}
<button type="submit" class="button is-danger is-light is-small">{% trans "Ignore" %}</button> <button type="submit" class="button is-danger is-light is-small">{% trans "Ignore" %}</button>
{% else %}
<button type="submit" class="button is-danger is-light is-small">{% trans "Un-gnore" %}</button>
{% endif %}
</form> </form>
</div> </div>
{% endif %} {% endif %}
@ -65,5 +76,11 @@
{% endfor %} {% endfor %}
</table> </table>
{% include 'snippets/pagination.html' with page=requests path=request.path %} {% include 'snippets/pagination.html' with page=requests path=request.path %}
{% if ignored %}
<p><a href="{% url 'settings-invite-requests' %}">{% trans "Back to pending requests" %}</a></p>
{% else %}
<p><a href="{% url 'settings-invite-requests' %}?ignored=True">{% trans "View ignored requests" %}</a></p>
{% endif %}
</section> </section>
{% endblock %} {% endblock %}

View file

@ -6,14 +6,14 @@
<div class="tabs"> <div class="tabs">
<ul> <ul>
{% url 'settings-invites' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invites" %}</a>
</li>
{% url 'settings-invite-requests' as url %} {% url 'settings-invite-requests' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}> <li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invite Requests" %}</a> <a href="{{ url }}">{% trans "Invite Requests" %}</a>
</li> </li>
{% url 'settings-invites' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Invites" %}</a>
</li>
</ul> </ul>
</div> </div>

View file

@ -130,4 +130,11 @@ class InviteRequest(View):
@require_POST @require_POST
def ignore_invite_request(request): def ignore_invite_request(request):
""" ok """ """ hide an invite request """
invite_request = get_object_or_404(
models.InviteRequest, id=request.POST.get("invite-request")
)
invite_request.ignored = not invite_request.ignored
invite_request.save()
return redirect("settings-invite-requests")