Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
394ada93
Commit
394ada93
authored
Nov 20, 2017
by
Gabriel Detraz
Committed by
root
Nov 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajoute le support des membres et admin clubs
parent
0dfc4b54
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
168 additions
and
13 deletions
+168
-13
users/forms.py
users/forms.py
+12
-0
users/migrations/0060_auto_20171120_0317.py
users/migrations/0060_auto_20171120_0317.py
+25
-0
users/models.py
users/models.py
+16
-1
users/templates/users/profil.html
users/templates/users/profil.html
+43
-3
users/templates/users/user.html
users/templates/users/user.html
+1
-1
users/urls.py
users/urls.py
+5
-0
users/views.py
users/views.py
+66
-8
No files found.
users/forms.py
View file @
394ada93
...
...
@@ -379,6 +379,18 @@ class FullClubForm(ClubForm):
]
class
ClubAdminandMembersForm
(
ModelForm
):
"""Permet d'éditer la liste des membres et des administrateurs
d'un club"""
class
Meta
:
model
=
Club
fields
=
[
'administrators'
,
'members'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
super
(
ClubAdminandMembersForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
class
PasswordForm
(
ModelForm
):
""" Formulaire de changement brut de mot de passe.
Ne pas utiliser sans traitement"""
...
...
users/migrations/0060_auto_20171120_0317.py
0 → 100644
View file @
394ada93
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-11-20 02:17
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'users'
,
'0059_auto_20171025_1854'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'club'
,
name
=
'administrators'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'club_administrator'
,
to
=
'users.Adherent'
),
),
migrations
.
AddField
(
model_name
=
'club'
,
name
=
'members'
,
field
=
models
.
ManyToManyField
(
blank
=
True
,
related_name
=
'club_members'
,
to
=
'users.Adherent'
),
),
]
users/models.py
View file @
394ada93
...
...
@@ -60,7 +60,10 @@ from django.core.mail import send_mail
from
django.core.urlresolvers
import
reverse
from
django.db
import
transaction
from
django.utils
import
timezone
from
django.contrib.auth.models
import
AbstractBaseUser
,
BaseUserManager
from
django.contrib.auth.models
import
(
AbstractBaseUser
,
BaseUserManager
)
from
django.core.validators
import
RegexValidator
from
reversion
import
revisions
as
reversion
...
...
@@ -771,6 +774,7 @@ class Adherent(User):
pass
class
Club
(
User
):
PRETTY_NAME
=
"Clubs"
room
=
models
.
ForeignKey
(
...
...
@@ -779,6 +783,17 @@ class Club(User):
blank
=
True
,
null
=
True
)
administrators
=
models
.
ManyToManyField
(
blank
=
True
,
to
=
'users.Adherent'
,
related_name
=
'club_administrator'
)
members
=
models
.
ManyToManyField
(
blank
=
True
,
to
=
'users.Adherent'
,
related_name
=
'club_members'
)
pass
...
...
users/templates/users/profil.html
View file @
394ada93
...
...
@@ -141,21 +141,61 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>
{{ user.shell }}
</td>
{% endif %}
</table>
<h2>
Machines :
</h2>
{% if user.is_class_club %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:edit-club-admin-members' user.club.id %}"
>
<i
class=
"glyphicon glyphicon-lock"
></i>
Gérer admin et membres
</a>
<h3>
Administrateurs du club
</h3>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Nom
</th>
<th>
Prenom
</th>
<th>
Pseudo
</th>
</tr>
</thead>
{% for admin in user.club.administrators.all %}
<tr>
<td>
{{ admin.surname }}
</td>
<td>
{{ admin.name }}
</td>
<td>
{{ admin.pseudo }}
</td>
</tr>
{% endfor %}
</table>
<h3>
Membres
</h3>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
Nom
</th>
<th>
Prenom
</th>
<th>
Pseudo
</th>
</tr>
</thead>
{% for admin in user.club.members.all %}
<tr>
<td>
{{ admin.surname }}
</td>
<td>
{{ admin.name }}
</td>
<td>
{{ admin.pseudo }}
</td>
</tr>
{% endfor %}
</table>
{% endif %}
<h2>
Machines
</h2>
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'machines:new-machine' user.id %}"
><i
class=
"glyphicon glyphicon-phone"
></i>
Ajouter une machine
</a></h4>
{% if machines_list %}
{% include "machines/aff_machines.html" with machines_list=machines_list %}
{% else %}
<p>
Aucune machine
</p>
{% endif %}
<h2>
Cotisations
:
</h2>
<h2>
Cotisations
</h2>
{% if is_cableur %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:new-facture' user.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Ajouter une cotisation
</a>
{% if user_solde %}
<a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'cotisations:credit-solde' user.id %}"
><i
class=
"glyphicon glyphicon-piggy-bank"
></i>
Modifier le solde
</a>
{% endif%}
</h4>
{% endif%}
{% if facture_list %}
{% include "cotisations/aff_cotisations.html" with facture_list=facture_list %}
{% else %}
<p>
Aucune facture
</p>
{% endif %}
<h2>
Bannissements
:
</h2>
<h2>
Bannissements
</h2>
{% if is_bofh %}
<h4><a
class=
"btn btn-primary btn-sm"
role=
"button"
href=
"{% url 'users:add-ban' user.id %}"
><i
class=
"glyphicon glyphicon-pushpin"
></i>
Ajouter un bannissement
</a></h4>
{% endif %}
{% if ban_list %}
{% include "users/aff_bans.html" with ban_list=ban_list %}
...
...
users/templates/users/user.html
View file @
394ada93
...
...
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<form
class=
"form"
method=
"post"
>
{% csrf_token %}
{% massive_bootstrap_form userform 'room,school' %}
{% massive_bootstrap_form userform 'room,school
,administrators,members
' %}
{% bootstrap_button "Créer ou modifier" button_type="submit" icon="star" %}
</form>
<br
/>
...
...
users/urls.py
View file @
394ada93
...
...
@@ -33,6 +33,11 @@ urlpatterns = [
url
(
r
'^new_user/$'
,
views
.
new_user
,
name
=
'new-user'
),
url
(
r
'^new_club/$'
,
views
.
new_club
,
name
=
'new-club'
),
url
(
r
'^edit_info/(?P<userid>[0-9]+)$'
,
views
.
edit_info
,
name
=
'edit-info'
),
url
(
r
'^edit_club_admin_members/(?P<clubid>[0-9]+)$'
,
views
.
edit_club_admin_members
,
name
=
'edit-club-admin-members'
),
url
(
r
'^state/(?P<userid>[0-9]+)$'
,
views
.
state
,
name
=
'state'
),
url
(
r
'^password/(?P<userid>[0-9]+)$'
,
views
.
password
,
name
=
'password'
),
url
(
r
'^new_serviceuser/$'
,
views
.
new_serviceuser
,
name
=
'new-serviceuser'
),
...
...
users/views.py
View file @
394ada93
...
...
@@ -53,14 +53,40 @@ from rest_framework.renderers import JSONRenderer
from
reversion.models
import
Version
from
reversion
import
revisions
as
reversion
from
users.serializers
import
MailSerializer
from
users.models
import
User
,
Right
,
Ban
,
Whitelist
,
School
,
ListRight
from
users.models
import
Request
,
ServiceUser
,
Adherent
,
Club
from
users.forms
import
DelRightForm
,
BanForm
,
WhitelistForm
,
DelSchoolForm
from
users.forms
import
DelListRightForm
,
NewListRightForm
,
FullAdherentForm
from
users.forms
import
StateForm
,
FullClubForm
from
users.forms
import
RightForm
,
SchoolForm
,
EditServiceUserForm
from
users.forms
import
ServiceUserForm
,
ListRightForm
,
AdherentForm
,
ClubForm
from
users.forms
import
MassArchiveForm
,
PassForm
,
ResetPasswordForm
from
users.models
import
(
User
,
Right
,
Ban
,
Whitelist
,
School
,
ListRight
,
Request
,
ServiceUser
,
Adherent
,
Club
)
from
users.forms
import
(
DelRightForm
,
BanForm
,
WhitelistForm
,
DelSchoolForm
,
DelListRightForm
,
NewListRightForm
,
FullAdherentForm
,
StateForm
,
FullClubForm
,
RightForm
,
SchoolForm
,
EditServiceUserForm
,
ServiceUserForm
,
ListRightForm
,
AdherentForm
,
ClubForm
,
MassArchiveForm
,
PassForm
,
ResetPasswordForm
,
ClubAdminandMembersForm
)
from
cotisations.models
import
Facture
from
machines.models
import
Machine
from
preferences.models
import
OptionalUser
,
GeneralOption
...
...
@@ -128,6 +154,38 @@ def new_club(request):
return
form
({
'userform'
:
club
},
'users/user.html'
,
request
)
@
login_required
def
edit_club_admin_members
(
request
,
clubid
):
"""Vue d'edition de la liste des users administrateurs et
membres d'un club"""
try
:
club_instance
=
Club
.
objects
.
get
(
pk
=
clubid
)
except
Club
.
DoesNotExist
:
messages
.
error
(
request
,
"Club inexistant"
)
return
redirect
(
reverse
(
'users:index'
))
if
not
request
.
user
.
has_perms
((
'cableur'
,))
\
and
not
request
.
user
in
club_instance
.
administrators
.
all
():
messages
.
error
(
request
,
"Vous ne pouvez pas accéder à ce menu"
)
return
redirect
(
reverse
(
'users:profil'
,
kwargs
=
{
'userid'
:
str
(
request
.
user
.
id
)}
))
club
=
ClubAdminandMembersForm
(
request
.
POST
or
None
,
instance
=
club_instance
)
if
club
.
is_valid
():
with
transaction
.
atomic
(),
reversion
.
create_revision
():
club
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
club
.
changed_data
))
messages
.
success
(
request
,
"Le club a bien été modifié"
)
return
redirect
(
reverse
(
'users:profil'
,
kwargs
=
{
'userid'
:
str
(
club_instance
.
id
)}
))
return
form
({
'userform'
:
club
},
'users/user.html'
,
request
)
def
select_user_edit_form
(
request
,
user
):
"""Fonction de choix du bon formulaire, en fonction de:
- droit
...
...
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