Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.web
Commits
be218a1e
Commit
be218a1e
authored
Sep 11, 2020
by
Samuel GAIST
Browse files
[ui][registration][all] Pre-commit cleanup
parent
2ab6dfac
Pipeline
#42695
passed with stage
in 14 minutes and 54 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
beat/web/ui/registration/admin.py
View file @
be218a1e
...
...
@@ -27,8 +27,8 @@
from
django.contrib
import
admin
from
.models
import
RegistrationProfile
from
.models
import
PreregistrationProfile
from
.models
import
RegistrationProfile
class
RegistrationAdmin
(
admin
.
ModelAdmin
):
...
...
beat/web/ui/registration/forms.py
View file @
be218a1e
This diff is collapsed.
Click to expand it.
beat/web/ui/registration/signals.py
View file @
be218a1e
...
...
@@ -27,7 +27,6 @@
from
django.dispatch
import
Signal
# A new user has registered.
user_registered
=
Signal
(
providing_args
=
[
"user"
])
...
...
beat/web/ui/registration/views.py
View file @
be218a1e
...
...
@@ -29,12 +29,10 @@
Views which allow users to create and activate accounts.
"""
from
django.conf
import
settings
from
django.urls
import
reverse
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
from
django.urls
import
reverse
from
django.views.decorators.csrf
import
csrf_protect
from
.forms
import
RegistrationFormTermsOfService
...
...
@@ -43,9 +41,12 @@ from .forms import RegistrationSupervisorForm
from
.models
import
RegistrationProfile
def
activate
(
request
,
activation_key
,
template_name
=
'registration/activate.html'
,
extra_context
=
None
):
def
activate
(
request
,
activation_key
,
template_name
=
"registration/activate.html"
,
extra_context
=
None
,
):
"""
Activate a ``User``'s account from an activation key, if their key
is valid and hasn't expired.
...
...
@@ -89,11 +90,10 @@ def activate(request, activation_key,
registration/activate.html or ``template_name`` keyword argument.
"""
activationKey
=
activation_key
.
lower
()
# Normalize before trying anything with it.
account
=
RegistrationProfile
.
objects
.
activate_user
(
activation_key
)
context
=
{
'account'
:
account
,
'expiration_days'
:
settings
.
ACCOUNT_ACTIVATION_DAYS
}
context
=
{
"account"
:
account
,
"expiration_days"
:
settings
.
ACCOUNT_ACTIVATION_DAYS
}
if
extra_context
is
not
None
:
for
key
,
value
in
extra_context
.
items
():
...
...
@@ -103,10 +103,13 @@ def activate(request, activation_key,
@
csrf_protect
def
register
(
request
,
success_url
=
None
,
form_class
=
RegistrationFormTermsOfService
,
template_name
=
'registration/registration_form.html'
,
extra_context
=
None
):
def
register
(
request
,
success_url
=
None
,
form_class
=
RegistrationFormTermsOfService
,
template_name
=
"registration/registration_form.html"
,
extra_context
=
None
,
):
"""
Allow a new user to register an account.
...
...
@@ -164,17 +167,19 @@ def register(request, success_url=None,
supervisor_form_active
=
False
if
request
.
GET
.
get
(
'
registration
'
)
==
"supervisor"
:
if
request
.
GET
.
get
(
"
registration
"
)
==
"supervisor"
:
supervisor_form_active
=
True
if
request
.
method
==
'
POST
'
:
if
request
.
method
==
"
POST
"
:
# Check the form
if
'
supervisor
'
not
in
request
.
POST
:
if
"
supervisor
"
not
in
request
.
POST
:
supervisor_form_active
=
True
form_supervisor
=
RegistrationSupervisorForm
(
data
=
request
.
POST
,
files
=
request
.
FILES
)
form_supervisor
=
RegistrationSupervisorForm
(
data
=
request
.
POST
,
files
=
request
.
FILES
)
form
=
form_class
()
if
form_supervisor
.
is_valid
():
new_user
=
form_supervisor
.
save
()
form_supervisor
.
save
()
# success_url needs to be dynamically generated here; setting a
# a default value using reverse() will cause circular-import
# problems with the default URLConf for this application, which
...
...
@@ -185,7 +190,7 @@ def register(request, success_url=None,
form
=
form_class
(
data
=
request
.
POST
,
files
=
request
.
FILES
)
form_supervisor
=
RegistrationSupervisorForm
()
if
form
.
is_valid
():
new_user
=
form
.
save
()
form
.
save
()
# success_url needs to be dynamically generated here; setting a
# a default value using reverse() will cause circular-import
# problems with the default URLConf for this application, which
...
...
@@ -195,12 +200,13 @@ def register(request, success_url=None,
form
=
form_class
()
form_supervisor
=
RegistrationFormTermsOfServiceSupervisor
()
context
=
{
'form'
:
form
,
'form_supervisor'
:
form_supervisor
,
'supervisor_form_active'
:
supervisor_form_active
,
'documentation_link'
:
settings
.
DOCUMENTATION_LINK
,
'url_prefix'
:
settings
.
URL_PREFIX
}
context
=
{
"form"
:
form
,
"form_supervisor"
:
form_supervisor
,
"supervisor_form_active"
:
supervisor_form_active
,
"documentation_link"
:
settings
.
DOCUMENTATION_LINK
,
"url_prefix"
:
settings
.
URL_PREFIX
,
}
if
extra_context
is
not
None
:
for
key
,
value
in
extra_context
.
items
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment