mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Send invites
This commit is contained in:
parent
685da1f5b8
commit
1644c421e5
7 changed files with 53 additions and 23 deletions
|
@ -6,6 +6,16 @@ from bookwyrm import models
|
||||||
from bookwyrm.tasks import app
|
from bookwyrm.tasks import app
|
||||||
|
|
||||||
|
|
||||||
|
def invite_email(invite_request):
|
||||||
|
""" send out an invite code """
|
||||||
|
site = models.SiteSettings.objects.get()
|
||||||
|
data = {
|
||||||
|
"site_name": site.name,
|
||||||
|
"invite_link": invite_request.invite.link,
|
||||||
|
}
|
||||||
|
send_email.delay(invite_request.email, "invite", data)
|
||||||
|
|
||||||
|
|
||||||
def password_reset_email(reset_code):
|
def password_reset_email(reset_code):
|
||||||
""" generate a password reset email """
|
""" generate a password reset email """
|
||||||
site = models.SiteSettings.objects.get()
|
site = models.SiteSettings.objects.get()
|
||||||
|
|
2
bookwyrm/templates/email/invite/html_content.html
Normal file
2
bookwyrm/templates/email/invite/html_content.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{% load i18n %}
|
||||||
|
<a href="{{ invite_link }}">{% blocktrans %}Join {{ site_name }}{% endblocktrans %}</a>
|
2
bookwyrm/templates/email/invite/subject.html
Normal file
2
bookwyrm/templates/email/invite/subject.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{% load i18n %}
|
||||||
|
{% blocktrans %}You're invited! Join {{ site_name }}{% endblocktrans %}
|
2
bookwyrm/templates/email/invite/text_content.html
Normal file
2
bookwyrm/templates/email/invite/text_content.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{% load i18n %}
|
||||||
|
{% blocktrans %}Join {{ site_name }}: {{ invite_link }}{% endblocktrans %}
|
|
@ -15,8 +15,8 @@
|
||||||
<h2 class="menu-label">{% trans "Manage Users" %}</h2>
|
<h2 class="menu-label">{% trans "Manage Users" %}</h2>
|
||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li>
|
<li>
|
||||||
{% url 'settings-invites' as url %}
|
{% url 'settings-invite-requests' as url %}
|
||||||
{% url 'settings-invite-requests' as alt_url %}
|
{% url 'settings-invites' 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>
|
<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>
|
||||||
|
|
|
@ -49,17 +49,20 @@
|
||||||
{% trans "Requested" %}
|
{% trans "Requested" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="field is-grouped">
|
||||||
{% if req.invite and not req.invite.times_used %}
|
|
||||||
<button class="button is-danger is-light is-small">{% trans "Revoke invite" %}</button>
|
|
||||||
{% else %}
|
|
||||||
<div class="field is-grouped">
|
|
||||||
<form name="send-invite" method="post" action="{% url 'settings-invite-requests' %}">
|
<form name="send-invite" method="post" action="{% url 'settings-invite-requests' %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="invite-request" value="{{ req.id }}">
|
<input type="hidden" name="invite-request" value="{{ req.id }}">
|
||||||
|
{% if not req.invite %}
|
||||||
<button type="submit" class="button is-link is-light is-small">{% trans "Send invite" %}</button>
|
<button type="submit" class="button is-link is-light is-small">{% trans "Send invite" %}</button>
|
||||||
|
{% else %}
|
||||||
|
<button type="submit" class="button is-link is-light is-small">{% trans "Re-send invite" %}</button>
|
||||||
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{% if req.invite and not req.invite.times_used %}
|
||||||
|
{# <button class="button is-danger is-light is-small">{% trans "Revoke invite" %}</button> #}
|
||||||
|
{% else %}
|
||||||
<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 %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="invite-request" value="{{ req.id }}">
|
<input type="hidden" name="invite-request" value="{{ req.id }}">
|
||||||
|
@ -69,7 +72,6 @@
|
||||||
<button type="submit" class="button is-danger is-light is-small">{% trans "Un-gnore" %}</button>
|
<button type="submit" class="button is-danger is-light is-small">{% trans "Un-gnore" %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
|
||||||
from bookwyrm import forms, models
|
from bookwyrm import emailing, forms, models
|
||||||
from bookwyrm.settings import PAGE_LENGTH
|
from bookwyrm.settings import PAGE_LENGTH
|
||||||
from . import helpers
|
from . import helpers
|
||||||
|
|
||||||
|
@ -107,6 +107,18 @@ class ManageInviteRequests(View):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
""" send out an invite """
|
""" send out an invite """
|
||||||
|
invite_request = get_object_or_404(
|
||||||
|
models.InviteRequest, id=request.POST.get("invite-request")
|
||||||
|
)
|
||||||
|
# allows re-sending invites
|
||||||
|
invite_request.invite, _ = models.SiteInvite.objects.get_or_create(
|
||||||
|
use_limit=1,
|
||||||
|
user=request.user,
|
||||||
|
)
|
||||||
|
|
||||||
|
invite_request.save()
|
||||||
|
emailing.invite_email(invite_request)
|
||||||
|
return redirect('settings-invite-requests')
|
||||||
|
|
||||||
|
|
||||||
class InviteRequest(View):
|
class InviteRequest(View):
|
||||||
|
|
Loading…
Reference in a new issue