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
e200757a
Commit
e200757a
authored
Jul 03, 2016
by
chirac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Demenagement de force
parent
96b1413c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
98 additions
and
0 deletions
+98
-0
users/migrations/0009_user_room.py
users/migrations/0009_user_room.py
+22
-0
users/migrations/0010_auto_20160703_1226.py
users/migrations/0010_auto_20160703_1226.py
+20
-0
users/migrations/0011_auto_20160703_1227.py
users/migrations/0011_auto_20160703_1227.py
+20
-0
users/migrations/0012_auto_20160703_1230.py
users/migrations/0012_auto_20160703_1230.py
+20
-0
users/migrations/__pycache__/0009_user_room.cpython-34.pyc
users/migrations/__pycache__/0009_user_room.cpython-34.pyc
+0
-0
users/migrations/__pycache__/0010_auto_20160703_1226.cpython-34.pyc
...ations/__pycache__/0010_auto_20160703_1226.cpython-34.pyc
+0
-0
users/migrations/__pycache__/0011_auto_20160703_1227.cpython-34.pyc
...ations/__pycache__/0011_auto_20160703_1227.cpython-34.pyc
+0
-0
users/migrations/__pycache__/0012_auto_20160703_1230.cpython-34.pyc
...ations/__pycache__/0012_auto_20160703_1230.cpython-34.pyc
+0
-0
users/models.py
users/models.py
+16
-0
No files found.
users/migrations/0009_user_room.py
0 → 100644
View file @
e200757a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'topologie'
,
'0009_auto_20160703_1200'
),
(
'users'
,
'0008_user_registered'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'user'
,
name
=
'room'
,
field
=
models
.
ForeignKey
(
to
=
'topologie.Room'
,
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
default
=
1
),
preserve_default
=
False
,
),
]
users/migrations/0010_auto_20160703_1226.py
0 → 100644
View file @
e200757a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'users'
,
'0009_user_room'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'room'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
blank
=
True
,
to
=
'topologie.Room'
,
null
=
True
),
),
]
users/migrations/0011_auto_20160703_1227.py
0 → 100644
View file @
e200757a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'users'
,
'0010_auto_20160703_1226'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'room'
,
field
=
models
.
ForeignKey
(
null
=
True
,
blank
=
True
,
unique
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
to
=
'topologie.Room'
),
),
]
users/migrations/0012_auto_20160703_1230.py
0 → 100644
View file @
e200757a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'users'
,
'0011_auto_20160703_1227'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'room'
,
field
=
models
.
OneToOneField
(
blank
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
PROTECT
,
to
=
'topologie.Room'
,
null
=
True
),
),
]
users/migrations/__pycache__/0009_user_room.cpython-34.pyc
0 → 100644
View file @
e200757a
File added
users/migrations/__pycache__/0010_auto_20160703_1226.cpython-34.pyc
0 → 100644
View file @
e200757a
File added
users/migrations/__pycache__/0011_auto_20160703_1227.cpython-34.pyc
0 → 100644
View file @
e200757a
File added
users/migrations/__pycache__/0012_auto_20160703_1230.cpython-34.pyc
0 → 100644
View file @
e200757a
File added
users/models.py
View file @
e200757a
...
...
@@ -6,6 +6,15 @@ from django.utils import timezone
from
topologie.models
import
Room
def
remove_user_room
(
room
):
""" Déménage de force l'ancien locataire de la chambre """
try
:
user
=
User
.
objects
.
get
(
room
=
room
)
except
User
.
DoesNotExist
:
return
user
.
room
=
None
user
.
save
()
class
User
(
models
.
Model
):
STATE_ACTIVE
=
0
STATE_DEACTIVATED
=
1
...
...
@@ -74,12 +83,19 @@ class UserForm(ModelForm):
fields
=
'__all__'
class
InfoForm
(
ModelForm
):
force
=
forms
.
BooleanField
(
label
=
"Forcer le déménagement ?"
,
initial
=
False
,
required
=
False
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
InfoForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'name'
].
label
=
'Nom'
self
.
fields
[
'surname'
].
label
=
'Prenom'
self
.
fields
[
'school'
].
label
=
'Etablissement'
def
clean_force
(
self
):
if
self
.
cleaned_data
.
get
(
'force'
,
False
):
remove_user_room
(
self
.
cleaned_data
.
get
(
'room'
))
return
class
Meta
:
model
=
User
fields
=
[
'name'
,
'surname'
,
'pseudo'
,
'email'
,
'school'
,
'promo'
,
'room'
]
...
...
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