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
18ae699e
Commit
18ae699e
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
consider permissions in the sidebar template
parent
77c6017e
No related branches found
No related tags found
1 merge request
!192
Feature/add way to change password and PERMISSIONS
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/templates/sidebar.html
+18
-3
18 additions, 3 deletions
smash/web/templates/sidebar.html
smash/web/views/__init__.py
+6
-1
6 additions, 1 deletion
smash/web/views/__init__.py
with
24 additions
and
4 deletions
smash/web/templates/sidebar.html
+
18
−
3
View file @
18ae699e
...
@@ -23,12 +23,14 @@
...
@@ -23,12 +23,14 @@
</a>
</a>
</li>
</li>
{% if "change_worker" in permissions or "add_worker" in permissions or "delete_worker" in permissions %}
<li
data-desc=
"workers"
>
<li
data-desc=
"workers"
>
<a
href=
"{% url 'web.views.workers' %}"
>
<a
href=
"{% url 'web.views.workers' %}"
>
<i
class=
"fa fa-user-md"
></i>
<i
class=
"fa fa-user-md"
></i>
<span>
Worker
s
</span>
<span>
Worker
</span>
</a>
</a>
</li>
</li>
{% endif %}
<li
data-desc=
"equipment_and_rooms"
class=
"treeview"
>
<li
data-desc=
"equipment_and_rooms"
class=
"treeview"
>
<a
href=
"{% url 'web.views.equipment_and_rooms' %}"
>
<a
href=
"{% url 'web.views.equipment_and_rooms' %}"
>
...
@@ -83,16 +85,29 @@
...
@@ -83,16 +85,29 @@
</span>
</span>
</a>
</a>
<ul
class=
"treeview-menu"
>
<ul
class=
"treeview-menu"
>
{% if "change_configurationitem" in permissions %}
<li><a
href=
"{% url 'web.views.configuration' %}"
>
General
</a></li>
<li><a
href=
"{% url 'web.views.configuration' %}"
>
General
</a></li>
{% endif %}
{% if "change_language" in permissions %}
<li><a
href=
"{% url 'web.views.languages' %}"
>
Languages
</a></li>
<li><a
href=
"{% url 'web.views.languages' %}"
>
Languages
</a></li>
{% if study.has_voucher_types %}
{% endif %}
{% if study.has_voucher_types and "change_vouchertype" in permissions %}
<li><a
href=
"{% url 'web.views.voucher_types' %}"
>
Voucher types
</a></li>
<li><a
href=
"{% url 'web.views.voucher_types' %}"
>
Voucher types
</a></li>
{% endif %}
{% endif %}
{% if study.has_vouchers %}
{% if study.has_vouchers and "change_voucher" in permissions %}
<li><a
href=
"{% url 'web.views.workers' 'VOUCHER_PARTNER' %}"
>
Voucher partners
</a></li>
<li><a
href=
"{% url 'web.views.workers' 'VOUCHER_PARTNER' %}"
>
Voucher partners
</a></li>
{% endif %}
{% endif %}
{% if "change_worker" in permissions %}
<li><a
href=
"{% url 'web.views.workers' 'HEALTH_PARTNER' %}"
>
Health partners
</a></li>
<li><a
href=
"{% url 'web.views.workers' 'HEALTH_PARTNER' %}"
>
Health partners
</a></li>
{% endif %}
{% if "change_study" in permissions %}
<li><a
href=
"{% url 'web.views.edit_study' study_id %}"
>
Study
</a></li>
<li><a
href=
"{% url 'web.views.edit_study' study_id %}"
>
Study
</a></li>
{% endif %}
</ul>
</ul>
</li>
</li>
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/__init__.py
+
6
−
1
View file @
18ae699e
...
@@ -6,6 +6,7 @@ from django.views.generic.base import ContextMixin
...
@@ -6,6 +6,7 @@ from django.views.generic.base import ContextMixin
from
web.models.constants
import
GLOBAL_STUDY_ID
from
web.models.constants
import
GLOBAL_STUDY_ID
from
notifications
import
get_notifications
from
notifications
import
get_notifications
from
..models
import
Worker
,
Study
from
..models
import
Worker
,
Study
from
web.decorators
import
PermissionDecorator
handler404
=
'
web.views.e404_page_not_found
'
handler404
=
'
web.views.e404_page_not_found
'
handler500
=
'
web.views.e500_error
'
handler500
=
'
web.views.e500_error
'
...
@@ -41,9 +42,12 @@ def wrap_response(request, template, params):
...
@@ -41,9 +42,12 @@ def wrap_response(request, template, params):
def
extend_context
(
params
,
request
):
def
extend_context
(
params
,
request
):
study
=
Study
.
get_by_id
(
GLOBAL_STUDY_ID
)
person
=
Worker
.
get_by_user
(
request
.
user
)
# None if AnonymousUser or no Worker associated
person
=
Worker
.
get_by_user
(
request
.
user
)
# None if AnonymousUser or no Worker associated
permissions
=
[]
if
person
is
not
None
:
if
person
is
not
None
:
role
=
person
.
role
role
=
person
.
role
permissions
=
person
.
get_permissions
(
study
)
person
=
unicode
(
person
)
person
=
unicode
(
person
)
else
:
else
:
#use full name if available, username otherwise
#use full name if available, username otherwise
...
@@ -54,8 +58,9 @@ def extend_context(params, request):
...
@@ -54,8 +58,9 @@ def extend_context(params, request):
role
=
'
<No worker information>
'
role
=
'
<No worker information>
'
notifications
=
get_notifications
(
request
.
user
)
notifications
=
get_notifications
(
request
.
user
)
final_params
=
params
.
copy
()
final_params
=
params
.
copy
()
study
=
Study
.
get_by_id
(
GLOBAL_STUDY_ID
)
final_params
.
update
({
final_params
.
update
({
'
permissions
'
:
permissions
,
'
conf_perms
'
:
permissions
&
PermissionDecorator
.
codename_groups
[
'
configuration
'
],
'
person
'
:
person
,
'
person
'
:
person
,
'
role
'
:
role
,
'
role
'
:
role
,
'
notifications
'
:
notifications
,
'
notifications
'
:
notifications
,
...
...
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