Староверов Данила Андреевич 1 rok pred
rodič
commit
b44d56325b

+ 1 - 1
SharixAdmin/groups.py

@@ -21,7 +21,7 @@ def create_groups(sender, **kwargs):
 def group_required(*group_names):
     def in_groups(u):
         if u.is_authenticated:
-            if u.groups.filter(name__in=group_names).exists() or u.is_superuser:
+            if u.groups.filter(name=group_names).exists() or u.is_superuser:
                 return True
         return False
 

+ 2 - 1
SharixAdmin/views/context.py

@@ -25,7 +25,8 @@ menu = [
      'roles':['METASERVICE-ADMIN']},
     {'title':'Информация о партнере',   'link':'partner_information/add/', 'sel':'person',
      'roles':['PARTNER-ADMIN']},
-    {'title':'Тарифы',                  'link':'service', 'sel':'tikets'},
+    {'title':'Тарифы',                  'link':'service', 'sel':'tikets',
+     'roles':['PARTNER-ADMIN']},
 ]
 
 def get_context(request, page_context) -> dict:

+ 2 - 2
SharixAdmin/views/partner_info.py

@@ -25,7 +25,7 @@ class PartnerInformationCreate(UserPassesTestMixin, CreateView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     
@@ -47,7 +47,7 @@ class PartnerInformationUpdateView(UserPassesTestMixin, UpdateView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     

+ 1 - 1
SharixAdmin/views/partners.py

@@ -22,7 +22,7 @@ class PartnersListView(UserPassesTestMixin, SingleTableView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 

+ 1 - 1
SharixAdmin/views/resource.py

@@ -22,7 +22,7 @@ class ResourceListView(UserPassesTestMixin, SingleTableView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 

+ 1 - 1
SharixAdmin/views/service.py

@@ -21,7 +21,7 @@ class ServiceListView(UserPassesTestMixin, SingleTableView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 

+ 2 - 2
SharixAdmin/views/service_info.py

@@ -24,7 +24,7 @@ class ServiceInformationCreate(UserPassesTestMixin, CreateView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     
@@ -46,6 +46,6 @@ class ServiceInformationUpdateView(UserPassesTestMixin, UpdateView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False

+ 3 - 3
SharixAdmin/views/service_tariff.py

@@ -25,7 +25,7 @@ class ServiceTariffCreate(UserPassesTestMixin, CreateView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 
@@ -44,7 +44,7 @@ class ServiceTariffListView(UserPassesTestMixin, SingleTableView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 
@@ -67,7 +67,7 @@ class ServiceTariffUpdateView(UserPassesTestMixin, UpdateView):
     
     def test_func(self) -> bool or None:
         group_names = ('PARTNER-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 

+ 4 - 4
SharixAdmin/views/service_type.py

@@ -25,7 +25,7 @@ class ServiceTypeCreate(UserPassesTestMixin, CreateView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     
@@ -45,7 +45,7 @@ class ServiceTypeListView(UserPassesTestMixin, SingleTableView):
 
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 
@@ -64,7 +64,7 @@ class ServiceTypeUpdateView(UserPassesTestMixin, UpdateView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
     
@@ -86,6 +86,6 @@ class ServiceTypeDelete(UserPassesTestMixin, DeleteView):
     
     def test_func(self) -> bool or None:
         group_names = ('METASERVICE-ADMIN')
-        if bool(self.request.user.groups.filter(name__in=group_names)) or self.request.user.is_superuser:
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False