Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
aaf50250
Verified
Commit
aaf50250
authored
Nov 29, 2017
by
Thibaut Broggi
Browse files
Revert migration that create groups
It is already done in a command named "init_groups"
parent
4dd89717
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/rp/forms.py
View file @
aaf50250
...
...
@@ -18,6 +18,6 @@ class TagMultipleChoiceField(forms.ModelMultipleChoiceField):
class
SignupForm
(
forms
.
Form
):
def
signup
(
self
,
request
,
user
):
group
=
Group
.
objects
.
get
(
name
=
'
P
adawan'
)
group
=
Group
.
objects
.
get
(
name
=
'
p
adawan'
)
user
.
groups
.
add
(
group
)
user
.
save
()
apps/rp/migrations/0017_groups.py
View file @
aaf50250
from
django.db
import
migrations
from
django.contrib.auth.models
import
Group
def
add_groups
(
apps
,
schema_editor
):
groups
=
[
'Jedi'
,
'Padawan'
,
'Droid'
]
groups
=
[
'Jedi'
,
'Padawan'
,
'Droid'
]
def
add_groups
(
apps
,
schema_editor
):
for
i
in
groups
:
group
=
Group
(
name
=
i
)
group
.
save
()
def
remove_groups
(
apps
,
schema_editor
):
Group
.
objects
.
all
().
delete
()
for
i
in
groups
:
Group
.
objects
.
filter
(
name
=
i
).
delete
()
class
Migration
(
migrations
.
Migration
):
...
...
apps/rp/migrations/0018_
add_groups_to_users
.py
→
apps/rp/migrations/0018_
revert_0017
.py
View file @
aaf50250
from
django.db
import
migrations
from
django.contrib.auth.models
import
Group
,
User
def
add_groups
(
apps
,
schema_editor
):
users
=
User
.
objects
.
all
()
padawanGroup
=
Group
.
objects
.
get
(
name
=
'Padawan'
)
def
remove_groups
(
apps
,
schema_editor
):
groups
=
[
'Jedi'
,
'Padawan'
,
'Droid'
]
for
i
in
groups
:
Group
.
objects
.
filter
(
name
=
i
).
delete
()
for
user
in
users
:
user
.
groups
.
add
(
padawanGroup
)
user
.
save
()
class
Migration
(
migrations
.
Migration
):
...
...
@@ -16,5 +15,5 @@ class Migration(migrations.Migration):
]
operations
=
[
migrations
.
RunPython
(
add
_groups
),
migrations
.
RunPython
(
remove
_groups
),
]
templates/base.html
View file @
aaf50250
...
...
@@ -58,7 +58,7 @@
<li
class=
"nav-item"
>
<a
class=
"nav-link"
>
Vous êtes {{user.groups.all.0.name}}
{% if user.groups.all.0.name == "
P
adawan" %}
{% if user.groups.all.0.name == "
p
adawan" %}
<img
class=
"inline-image ml-2"
role=
"img"
src=
"{% static 'img/padawan.svg' %}"
/>
{% elif user.groups.all.0.name == "Jedi" %}
<img
class=
"inline-image ml-2"
role=
"img"
src=
"{% static 'img/jedi.svg' %}"
/>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment