-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add case "graduatedSymbol" to getlegendgraphic filter. * Start integration of django_registration. * Add registration settings. Add sign up link to login page. * Refactoring login/rest_password template structure. * Add django_registration templates required. * Base registration two-step workflow. * Add django-registration to requirements. * Add is_active management. * Ads reCAPTCHA, close #597. * Add reCAPTCHA to reset password form. * Add reCAPTCHA to registration form. * Add 'other_info' field to userdata model. * Add 'first_name', 'last_name' and 'other_info' to registration form. * Add 'registration_intro' to GeneralSuiteData model. * Add 'registration_intro' to general suite data info form. * Add 'registration_intro' context to registration form page. * Make translatable 'registration_intro'. * Registration intro management. * Add save of 'other_info' userdata property. * Send email to administrator if REGISTRATION_ACTIVE_BY_ADMIN is True. * Introduce 'registered' and 'activated_by_admin' userdata model properties. * Send email to user after activation by administrator. * Refine * Check for testing. * Fix send email on activation by administrator for only registered users. * 🌐 Add _it_ translation. * Change position of registration information message inside the registration form page. * Change version for development state. * Add check for anonymous user inside the registration_allowed method. * Adding test for registration workflow. * Add test for registration view. * Change override_settings parameters for tests. * Change override_settings parameters for tests. * Change override_settings parameters for tests. * Recaptcha form element styling. * Start create form for recovery username. * Add workflow for username recovery. * Fix send email to administrators. --------- Co-authored-by: wlorenzetti <[email protected]>
- Loading branch information
1 parent
d189697
commit 0fd2396
Showing
9 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
g3w-admin/templates/registration/username_recovery_done.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base_login.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block login_page_box_body %} | ||
<div class="login-box-body"> | ||
<div class="login-box-msg"> | ||
<h3>{% trans 'Check your inbox.' %}</h3> | ||
<p>{% trans "We've emailed you your username. You should receive the email shortly!" %}</p> | ||
</div> | ||
</div><!-- /.login-box-body --> | ||
{% endblock %} |
10 changes: 10 additions & 0 deletions
10
g3w-admin/templates/registration/username_recovery_email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% load i18n %}{% autoescape off %} | ||
{% blocktranslate %}You're receiving this email because you requested a username recovery for your user account at {{ site_name }}.{% endblocktranslate %} | ||
|
||
{% translate "Your username is:" %} | ||
|
||
{{ user.get_username }} | ||
|
||
{{ SETTINGS.REGISTRATION_EMAIL_BODY_SIGN }} | ||
|
||
{% endautoescape %} |
37 changes: 37 additions & 0 deletions
37
g3w-admin/templates/registration/username_recovery_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% extends "base_login.html" %} | ||
{% load static %} | ||
{% load i18n %} | ||
|
||
{% block login_page_box_body %} | ||
<div class="login-box-body"> | ||
{% if form.errors %} | ||
<div class="alert alert-danger alert-dismissible"> | ||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> | ||
<h4><i class="icon fa fa-ban"></i> {% trans 'LOGIN ERROR' %}!</h4> | ||
{% if form.errors.email %} | ||
{% trans 'Email no present into database' %} | ||
{% endif %} | ||
{% if form.errors.captcha %} | ||
{% trans 'Checking the CAPTCHA is required' %} | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="login-box-msg"> | ||
<h3>{% trans 'Forgot your username?' %}</h3> | ||
<p>{% trans "Enter your email address below, and we'll email your username." %}</p> | ||
</div> | ||
<div class="form-group has-feedback"> | ||
<input type="text" class="form-control" name="email" placeholder="Email address"> | ||
<span class="glyphicon glyphicon-email form-control-feedback"></span> | ||
</div> | ||
<div class="form-group recaptcha">{{ form.captcha }}</div> | ||
<div class="row"> | ||
<div class="col-xs-12"> | ||
<button type="submit" class="btn btn-primary btn-block btn-flat">{% trans 'Send me username' %}</button> | ||
</div><!-- /.col --> | ||
</div> | ||
</form> | ||
</div><!-- /.login-box-body --> | ||
{% endblock %} |
3 changes: 3 additions & 0 deletions
3
g3w-admin/templates/registration/username_recovery_subject.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% load i18n %}{% autoescape off %} | ||
{{ SETTINGS.REGISTRATION_EMAIL_SUBJECT_PREFIX}} {% blocktranslate %}Username recovery on {{ site_name }}{% endblocktranslate %} | ||
{% endautoescape %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -851,7 +851,8 @@ def clean_email(self): | |
|
||
|
||
|
||
|
||
class G3WUsernameRecoveryForm(G3WreCaptchaFormMixin, PasswordResetForm): | ||
pass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
from django.contrib.auth.models import Group | ||
from django.contrib.sites.shortcuts import get_current_site | ||
from django.template.loader import render_to_string | ||
from django.contrib.auth.views import PasswordResetView, PasswordResetDoneView | ||
from django.urls import reverse_lazy | ||
from guardian.shortcuts import assign_perm, get_objects_for_user | ||
from guardian.decorators import permission_required_or_403 | ||
from django_registration.backends.activation import views as registration_views | ||
|
@@ -335,11 +337,33 @@ def send_admin_activation_email(self, user): | |
request=self.request, | ||
) | ||
|
||
# Get email of every admin users (Admin Level 1 and Admin Level 2) | ||
admins = User.objects.filter(is_superuser=True) | ||
|
||
send_mail( | ||
subject, | ||
message, | ||
settings.DEFAULT_FROM_EMAIL, | ||
["[email protected]"], | ||
[a.email for a in admins], | ||
fail_silently=False, | ||
) | ||
|
||
|
||
class UsernameRecoveryView(PasswordResetView): | ||
""" | ||
A view to recovery username by email, follow the same logic of Password reset. | ||
""" | ||
|
||
email_template_name = 'registration/username_recovery_email.html' | ||
form_class = G3WUsernameRecoveryForm | ||
subject_template_name = 'registration/username_recovery_subject.txt' | ||
success_url = reverse_lazy('username_recovery_done') | ||
template_name = 'registration/username_recovery_form.html' | ||
title = _('Username recovery') | ||
|
||
class UsernameRecoveryDoneView(PasswordResetDoneView): | ||
""" | ||
View for show message to the end user of emailing username. | ||
""" | ||
template_name = 'registration/username_recovery_done.html' | ||
title = _('Username sent') |