Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
d2c580dd
Commit
d2c580dd
authored
Dec 06, 2016
by
Skia
🤘
Browse files
Close issue
#26
: improve SAS ergonomy
parent
b7b9820d
Pipeline
#476
passed with stage
in 2 minutes and 34 seconds
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
sas/views.py
View file @
d2c580dd
...
...
@@ -10,6 +10,7 @@ from django import forms
from
django.core.exceptions
import
PermissionDenied
from
ajax_select
import
make_ajax_form
,
make_ajax_field
from
ajax_select.fields
import
AutoCompleteSelectField
,
AutoCompleteSelectMultipleField
from
io
import
BytesIO
from
PIL
import
Image
...
...
@@ -48,9 +49,9 @@ class SASForm(forms.Form):
class
RelationForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
PeoplePictureRelation
fields
=
[
'picture'
,
'user'
]
fields
=
[
'picture'
]
widgets
=
{
'picture'
:
forms
.
HiddenInput
}
user
=
make_ajax_field
(
PeoplePictureRelation
,
'user'
,
'users'
,
label
=
_
(
"Add user"
))
user
s
=
AutoCompleteSelectMultipleField
(
'user
s
'
,
show_help_text
=
False
,
help_text
=
""
,
label
=
_
(
"Add user"
)
,
required
=
False
)
class
SASMainView
(
FormView
):
form_class
=
SASForm
...
...
@@ -110,7 +111,9 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
self
.
form
=
self
.
get_form
()
if
request
.
user
.
is_authenticated
()
and
request
.
user
.
is_in_group
(
'ae-membres'
):
if
self
.
form
.
is_valid
():
PeoplePictureRelation
(
user
=
self
.
form
.
cleaned_data
[
'user'
],
for
uid
in
self
.
form
.
cleaned_data
[
'users'
]:
u
=
User
.
objects
.
filter
(
id
=
uid
).
first
()
PeoplePictureRelation
(
user
=
u
,
picture
=
self
.
form
.
cleaned_data
[
'picture'
]).
save
()
return
super
(
PictureView
,
self
).
form_valid
(
self
.
form
)
else
:
...
...
Write
Preview
Supports
Markdown
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