forked from Github-Mirrors/canaille
invitation: display the invitation link even if the mail could not be sent
This commit is contained in:
parent
c8f33cd77a
commit
694a5bacc8
2 changed files with 26 additions and 8 deletions
|
@ -155,9 +155,11 @@ def users(user):
|
|||
def user_invitation(user):
|
||||
form = InvitationForm(request.form or None)
|
||||
|
||||
success = False
|
||||
mail_sent = None
|
||||
registration_url = None
|
||||
form_validated = False
|
||||
if request.form and form.validate():
|
||||
form_validated = True
|
||||
registration_url = url_for(
|
||||
"account.registration",
|
||||
data=obj_to_b64([form.uid.data, form.mail.data, form.groups.data]),
|
||||
|
@ -165,15 +167,14 @@ def user_invitation(user):
|
|||
_external=True,
|
||||
)
|
||||
|
||||
success = send_invitation_mail(form.mail.data, registration_url)
|
||||
if not success:
|
||||
flash(_("An error happened whilen sending the invitation link."), "error")
|
||||
mail_sent = send_invitation_mail(form.mail.data, registration_url)
|
||||
|
||||
return render_template(
|
||||
"invite.html",
|
||||
form=form,
|
||||
menuitems="users",
|
||||
success=success,
|
||||
form_validated=form_validated,
|
||||
mail_sent=mail_sent,
|
||||
registration_url=registration_url,
|
||||
)
|
||||
|
||||
|
|
|
@ -7,22 +7,37 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="invitationform">
|
||||
{% if success %}
|
||||
{% if form_validated %}
|
||||
|
||||
<div class="ui attached segment">
|
||||
<h2 class="ui center aligned header">
|
||||
<div class="content">
|
||||
{{ _("Invitation sent") }}
|
||||
{% if mail_sent %}
|
||||
{{ _("Invitation sent") }}
|
||||
{% else %}
|
||||
{{ _("Invitation not sent") }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{% if mail_sent %}
|
||||
<div class="ui attached success message">
|
||||
{% set email = form.mail.data %}
|
||||
{% trans %}This invitation link has been to {{ email }}{% endtrans %}
|
||||
{% trans %}This invitation link has been sent to {{ email }}{% endtrans %}
|
||||
{% trans %}If you need to provide this link by other ways than email, you can copy it there:{% endtrans %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="ui attached error message">
|
||||
{% set email = form.mail.data %}
|
||||
{% trans %}This invitation link could not be sent to {{ email }} due to technical issues.{% endtrans %}
|
||||
{% trans %}However you can copy the there to provide it by other ways than email:{% endtrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="ui attached segment">
|
||||
<div class="ui center aligned container">
|
||||
<div class="ui fields">
|
||||
|
@ -39,9 +54,11 @@
|
|||
<a class="ui right floated button" href="{{ url_for("account.profile_creation") }}">
|
||||
{{ _("Create a user") }}
|
||||
</a>
|
||||
{% if mail_sent %}
|
||||
<a href="{{ url_for('account.user_invitation') }}" class="ui right floated button" name="action" value="invite" id="invite">
|
||||
{{ _("Invite another user") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue