Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
b396dd9a
Commit
b396dd9a
authored
3 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
indentation
parent
6b5c1d88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!336
Pylint checks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/forms/worker_form.py
+14
-10
14 additions, 10 deletions
smash/web/forms/worker_form.py
with
14 additions
and
10 deletions
smash/web/forms/worker_form.py
+
14
−
10
View file @
b396dd9a
...
...
@@ -51,19 +51,21 @@ class WorkerForm(ModelForm):
choices
=
role_choices_by_worker_type
(
worker_type
)
if
worker_type
in
[
WORKER_VOUCHER_PARTNER
,
WORKER_HEALTH_PARTNER
]:
'''
Since ChoiceField expects tuples (id, label), for a *custom* HiddenInput field we need to create a charfield with TextInput widget
providing the value of the *id*. hidden_form_field CSS class is defined in templates/doctors/add.html and has display:none property.
'''
# Since ChoiceField expects tuples (id, label), for a *custom* HiddenInput field we need to create
# a charfield with TextInput widget providing the value of the *id*. hidden_form_field CSS class is defined
# in templates/doctors/add.html and has display:none property.
if
initial_role
is
None
:
initial_role
=
choices
[
0
][
0
]
# get 1st element of 1st tuple (('VOUCHER_PARTNER', 'Voucher Partner'),)
self
.
fields
[
'
role
'
]
=
forms
.
CharField
(
label
=
'
Role
'
,
widget
=
forms
.
TextInput
(
attrs
=
{
'
class
'
:
'
hidden_form_field
'
}),
disabled
=
True
)
self
.
fields
[
'
role
'
]
=
forms
.
CharField
(
label
=
'
Role
'
,
widget
=
forms
.
TextInput
(
attrs
=
{
'
class
'
:
'
hidden_form_field
'
}),
disabled
=
True
)
else
:
self
.
fields
[
'
role
'
]
=
forms
.
ChoiceField
(
label
=
'
Role
'
,
choices
=
choices
)
self
.
fields
[
'
role
'
].
initial
=
initial_role
#use only the codename used in the code decorators
self
.
fields
[
'
permissions
'
]
=
forms
.
ModelMultipleChoiceField
(
required
=
False
,
queryset
=
PermissionDecorator
.
get_permissions
())
# use only the codename used in the code decorators
self
.
fields
[
'
permissions
'
]
=
forms
.
ModelMultipleChoiceField
(
required
=
False
,
queryset
=
PermissionDecorator
.
get_permissions
())
if
initial_permissions
is
not
None
:
self
.
fields
[
'
permissions
'
].
initial
=
[
c
.
pk
for
c
in
initial_permissions
]
...
...
@@ -88,7 +90,7 @@ class WorkerForm(ModelForm):
fields
=
OrderedDict
()
if
worker_type
==
WORKER_STAFF
:
if
worker_type
==
WORKER_STAFF
:
if
instance
is
None
or
instance
.
pk
is
None
:
fields
[
'
login
'
]
=
forms
.
CharField
(
label
=
'
Login
'
)
fields
[
'
password
'
]
=
forms
.
CharField
(
label
=
'
Password
'
,
widget
=
forms
.
PasswordInput
)
...
...
@@ -121,7 +123,9 @@ class WorkerForm(ModelForm):
role
.
permissions
.
set
(
self
.
cleaned_data
[
'
permissions
'
])
role
.
save
()
else
:
role
=
WorkerStudyRole
.
objects
.
create
(
worker
=
instance
,
study_id
=
GLOBAL_STUDY_ID
,
name
=
self
.
cleaned_data
[
'
role
'
])
role
=
WorkerStudyRole
.
objects
.
create
(
worker
=
instance
,
study_id
=
GLOBAL_STUDY_ID
,
name
=
self
.
cleaned_data
[
'
role
'
])
role
.
permissions
.
set
(
self
.
cleaned_data
[
'
permissions
'
])
role
.
save
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment