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
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
d2c580dd
Commit
d2c580dd
authored
Dec 06, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close issue
#26
: improve SAS ergonomy
parent
b7b9820d
Pipeline
#476
passed with stage
in 2 minutes and 34 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
sas/views.py
sas/views.py
+7
-4
No files found.
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
(
'users'
,
show_help_text
=
False
,
help_text
=
""
,
label
=
_
(
"Add user"
),
required
=
False
)
class
SASMainView
(
FormView
):
form_class
=
SASForm
...
...
@@ -110,8 +111,10 @@ 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'
],
picture
=
self
.
form
.
cleaned_data
[
'picture'
]).
save
()
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
:
self
.
form
.
add_error
(
None
,
_
(
"You do not have the permission to do that"
))
...
...
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