Skip to content

Commit

Permalink
[refs #89212] Update product permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaboiangiu committed Oct 20, 2017
1 parent d872d43 commit bd88336
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions insitu/templates/product/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="row">
<h1 class="col-sm-12">
<span>Product details</span>
{% if request.user.service_resp or request.user.is_superuser %}
{% if request.user.is_superuser %}
<span class="pull-right delete-btn">
<a class="btn btn-primary pull-right"
href="{% url 'product:delete' product.pk %}">Delete
Expand Down Expand Up @@ -108,7 +108,7 @@ <h1 class="col-sm-12">
<div class="row">
<h3 class="col-sm-12">
<span>Requirements</span>
{% if request.user.service_resp or request.user.is_superuser %}
{% if request.user.is_superuser %}
<span class="pull-right">
<a class="btn btn-primary pull-right"
href="{% url 'product:requirement:add' product.pk %}">Add requirement</a>
Expand All @@ -126,7 +126,7 @@ <h3 class="col-sm-12">
<th>Criticality</th>
<th class="no-sort">Barriers</th>
<th class="no-sort">Note</th>
{% if request.user.service_resp or request.user.is_superuser %}
{% if request.user.is_superuser %}
<th class="no-sort"></th>
{% endif %}
</tr>
Expand Down
2 changes: 1 addition & 1 deletion insitu/templates/product/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="row">
<h1 class="col-sm-12">
<span>Products</span>
{% if request.user.service_resp or request.user.is_superuser %}
{% if request.user.is_superuser %}
<span class="pull-right">
<a class="btn btn-primary pull-right"
href="{% url 'product:add' %}">New product</a>
Expand Down
3 changes: 1 addition & 2 deletions insitu/tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def setUp(self):
status = base.ProductStatusFactory()
coverage = base.CoverageFactory()

responsible_user = base.UserFactory()
base.CopernicususResponsibleFactory(user=responsible_user)
responsible_user = base.UserFactory(is_superuser=True)
self.client.force_login(responsible_user)
self._DATA = {
'acronym': 'TST',
Expand Down
7 changes: 4 additions & 3 deletions insitu/views/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from insitu.views.protected.permissions import (
IsAuthenticated,
IsCopernicusServiceResponsible,
IsSuperuser
)
from picklists import models as pickmodels

Expand Down Expand Up @@ -74,7 +75,7 @@ def get(self, request, *args, **kwargs):
class ProductAdd(ProtectedCreateView):
template_name = 'product/add.html'
form_class = forms.ProductForm
permission_classes = (IsCopernicusServiceResponsible, )
permission_classes = (IsSuperuser, )

def permission_denied(self, request):
self.permission_denied_redirect = reverse('product:list')
Expand All @@ -91,7 +92,7 @@ class ProductEdit(ProtectedUpdateView):
form_class = forms.ProductForm
model = models.Product
context_object_name = 'product'
permission_classes = (IsCopernicusServiceResponsible, )
permission_classes = (IsSuperuser, )

def permission_denied(self, request):
self.permission_denied_redirect = reverse('product:list')
Expand Down Expand Up @@ -119,7 +120,7 @@ class ProductDelete(ProtectedDeleteView):
form_class = forms.ProductForm
model = models.Product
context_object_name = 'product'
permission_classes = (IsCopernicusServiceResponsible, )
permission_classes = (IsSuperuser, )

def permission_denied(self, request):
self.permission_denied_redirect = reverse('product:list')
Expand Down

0 comments on commit bd88336

Please sign in to comment.