Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Seaward
Keel - LDH Middleware
Commits
28fc608f
Commit
28fc608f
authored
Feb 28, 2019
by
David Seaward
Browse files
Refactor user creation function for debugging.
Signed-off-by:
David Seaward
<
david.seaward@puri.sm
>
parent
caa46a90
Pipeline
#4624
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cart/views.py
View file @
28fc608f
from
django
import
forms
from
django.contrib.auth
import
get_user_model
from
django.conf
import
settings
from
django.contrib.auth
import
authenticate
,
login
from
registration
import
signals
from
registration.backends.simple.views
import
RegistrationView
from
ldapregister.forms
import
RegistrationForm
from
captcha.fields
import
CaptchaField
from
cart.models
import
ChosenReward
User
=
get_user_model
()
class
CartRegistrationForm
(
RegistrationForm
):
captcha
=
CaptchaField
()
...
...
@@ -27,7 +32,19 @@ class CartRegistrationView(RegistrationView):
)
def
register
(
self
,
form
):
usr
=
super
().
register
(
form
)
reward
=
ChosenReward
(
user
=
usr
,
reward
=
self
.
reward
)
# we ignore super().register(form) and replicate it here
new_user
=
form
.
save
()
reward
=
ChosenReward
(
user
=
new_user
,
reward
=
self
.
reward
)
reward
.
save
()
return
usr
new_user
=
authenticate
(
username
=
getattr
(
new_user
,
User
.
USERNAME_FIELD
),
password
=
form
.
cleaned_data
[
'password1'
]
)
login
(
self
.
request
,
new_user
)
signals
.
user_registered
.
send
(
sender
=
self
.
__class__
,
user
=
new_user
,
request
=
self
.
request
)
return
new_user
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