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
efd13acc
Commit
efd13acc
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added a way to retrieve the permissions of the worker for a certain study
parent
bf279d6f
No related branches found
No related tags found
1 merge request
!192
Feature/add way to change password and PERMISSIONS
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/models/worker.py
+20
-0
20 additions, 0 deletions
smash/web/models/worker.py
with
20 additions
and
0 deletions
smash/web/models/worker.py
+
20
−
0
View file @
efd13acc
...
@@ -18,6 +18,7 @@ from web.models.holiday import Holiday
...
@@ -18,6 +18,7 @@ from web.models.holiday import Holiday
from
web.models.availability
import
Availability
from
web.models.availability
import
Availability
from
web.models.appointment
import
Appointment
from
web.models.appointment
import
Appointment
from
web.models.appointment_type_link
import
AppointmentTypeLink
from
web.models.appointment_type_link
import
AppointmentTypeLink
from
django.contrib.auth.models
import
Permission
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -227,6 +228,25 @@ class Worker(models.Model):
...
@@ -227,6 +228,25 @@ class Worker(models.Model):
return
office_availability
.
get_availability_percentage
(
only_working_hours
=
True
)
return
office_availability
.
get_availability_percentage
(
only_working_hours
=
True
)
def
get_permissions
(
self
,
study
):
if
self
.
user
.
is_superuser
:
return
set
([
p
.
codename
for
p
in
Permission
.
objects
.
all
()])
roles
=
self
.
roles
.
filter
(
study
=
study
)
if
roles
.
count
()
==
0
:
return
set
()
return
set
(
p
.
codename
for
p
in
roles
[
0
].
permissions
.
all
())
def
has_perm
(
self
,
codename
,
study
):
roles
=
self
.
roles
.
filter
(
study
=
study
)
if
roles
.
count
()
==
0
:
return
False
if
role
[
0
].
permissions
.
filter
(
codename
=
codename
).
all
().
count
()
>
0
:
return
True
else
:
return
False
@property
@property
def
role
(
self
):
def
role
(
self
):
roles
=
self
.
roles
.
filter
(
study
=
GLOBAL_STUDY_ID
)
roles
=
self
.
roles
.
filter
(
study
=
GLOBAL_STUDY_ID
)
...
...
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