Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
37a5b578
Commit
37a5b578
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Patches
Plain Diff
Create user and profile with all field needed
parent
c4a5970c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/member/forms.py
+7
-1
7 additions, 1 deletion
apps/member/forms.py
apps/member/views.py
+9
-9
9 additions, 9 deletions
apps/member/views.py
templates/member/signup.html
+7
-4
7 additions, 4 deletions
templates/member/signup.html
with
23 additions
and
14 deletions
apps/member/forms.py
+
7
−
1
View file @
37a5b578
...
@@ -16,9 +16,15 @@ from crispy_forms.bootstrap import InlineField, FormActions, StrictButton, Div,
...
@@ -16,9 +16,15 @@ from crispy_forms.bootstrap import InlineField, FormActions, StrictButton, Div,
from
crispy_forms.layout
import
Layout
from
crispy_forms.layout
import
Layout
class
SignUpForm
(
UserCreationForm
):
class
Meta
:
model
=
User
fields
=
[
'
first_name
'
,
'
last_name
'
,
'
username
'
,
'
email
'
]
class
ProfileForm
(
forms
.
ModelForm
):
class
ProfileForm
(
forms
.
ModelForm
):
"""
"""
Forms pour la création d
'
un profile utilisateur
.
A form for the extras field provided by the :model:`member.Profile` model
.
"""
"""
class
Meta
:
class
Meta
:
model
=
Profile
model
=
Profile
...
...
This diff is collapsed.
Click to expand it.
apps/member/views.py
+
9
−
9
View file @
37a5b578
...
@@ -16,7 +16,7 @@ from django_tables2.views import SingleTableView
...
@@ -16,7 +16,7 @@ from django_tables2.views import SingleTableView
from
.models
import
Profile
,
Club
,
Membership
from
.models
import
Profile
,
Club
,
Membership
from
.forms
import
ProfileForm
,
ClubForm
,
MembershipForm
,
MemberFormSet
,
FormSetHelper
from
.forms
import
SignUpForm
,
ProfileForm
,
ClubForm
,
MembershipForm
,
MemberFormSet
,
FormSetHelper
from
.tables
import
ClubTable
,
UserTable
from
.tables
import
ClubTable
,
UserTable
from
.filters
import
UserFilter
,
UserFilterFormHelper
from
.filters
import
UserFilter
,
UserFilterFormHelper
...
@@ -29,10 +29,10 @@ class UserCreateView(CreateView):
...
@@ -29,10 +29,10 @@ class UserCreateView(CreateView):
Une vue pour inscrire un utilisateur et lui créer un profile
Une vue pour inscrire un utilisateur et lui créer un profile
"""
"""
form_class
=
Profile
Form
form_class
=
SignUp
Form
success_url
=
reverse_lazy
(
'
login
'
)
success_url
=
reverse_lazy
(
'
login
'
)
template_name
=
'
member/signup.html
'
template_name
=
'
member/signup.html
'
second_form
=
UserCreation
Form
second_form
=
Profile
Form
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
().
get_context_data
(
**
kwargs
)
context
=
super
().
get_context_data
(
**
kwargs
)
...
@@ -41,12 +41,12 @@ class UserCreateView(CreateView):
...
@@ -41,12 +41,12 @@ class UserCreateView(CreateView):
return
context
return
context
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
user
_form
=
UserCreation
Form
(
self
.
request
.
POST
)
profile
_form
=
Profile
Form
(
self
.
request
.
POST
)
if
user
_form
.
is_valid
():
if
form
.
is_valid
()
and
profile
_form
.
is_valid
():
user
=
user_
form
.
save
()
user
=
form
.
save
()
user_
profile
=
form
.
save
(
commit
=
False
)
# do not save to db
profile
=
profile_
form
.
save
(
commit
=
False
)
user_
profile
.
user
=
user
profile
.
user
=
user
user_
profile
.
save
()
profile
.
save
()
return
super
().
form_valid
(
form
)
return
super
().
form_valid
(
form
)
class
UserDetailView
(
LoginRequiredMixin
,
DetailView
):
class
UserDetailView
(
LoginRequiredMixin
,
DetailView
):
...
...
This diff is collapsed.
Click to expand it.
templates/member/signup.html
+
7
−
4
View file @
37a5b578
<!-- templates/signup.html -->
<!-- templates/signup.html -->
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% load crispy_forms_tags %}
{% load i18n %}
{% block title %}Sign Up{% endblock %}
{% block title %}Sign Up{% endblock %}
{% block content %}
{% block content %}
<h2>
Sign up
</h2>
<h2>
Sign up
</h2>
<form
method=
"post"
>
<form
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{ user_form|crispy }}
{{ form|crispy }}
{{ form|crispy }}
{{ user_form|crispy }}
<button
type=
"submit"
>
Sign up
</button>
<button
class=
"btn btn-link"
type=
"submit"
>
{% trans "Sign Up" %}
</button>
</form>
</form>
{% endblock %}
{% endblock %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment