Староверов Данила Андреевич 1 рік тому
батько
коміт
271e3d4adf

+ 12 - 3
SharixAdmin/forms.py

@@ -153,12 +153,21 @@ class PartnerInformationUpdateForm(forms.ModelForm):
         
 class PartnerInformationCreateForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
-        super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)          
+        super(PartnerInformationCreateForm, self).__init__(*args, **kwargs)       
+        for field in iter(self.fields):
+            if 'class' not in self.fields[field].widget.attrs:
+                self.fields[field].widget.attrs.update({'class':'form-control'})
+   
+    # legal_name = forms.Fi()
     class Meta:
         model = Company
         fields = ['legal_name', 'address', 'repr_id']
-        
+
         widgets = {
             'description': forms.Select(attrs={'class': 'form-select'}),
             'repr_id': forms.Select(attrs={'class': 'form-select'}),
-        }
+        }
+
+
+        #     username = forms.CharField(label="Номер телефона",
+        # widget=forms.TextInput(attrs={'class':'form-control'}))

+ 2 - 0
SharixAdmin/groups.py

@@ -14,6 +14,8 @@ def create_groups(sender, **kwargs):
     Group.objects.get_or_create(name='PARTNER-SUPERVISOR')
     Group.objects.get_or_create(name='PARTNER-TECHSUPPORT')
     Group.objects.get_or_create(name='GUEST')
+    Group.objects.get_or_create(name='CLIENT')
+    Group.objects.get_or_create(name='PROVIDER')
     
 
 

+ 11 - 1
SharixAdmin/views/provider.py

@@ -1,11 +1,13 @@
 from django_tables2 import SingleTableView
+from SharixAdmin.groups import group_required
 from SharixAdmin.tables import ProviderTable
 from metaservicesynced.models import Provider
 from django.contrib.auth.decorators import login_required
 from SharixAdmin.views.context import get_context
 from django.http import JsonResponse
+from django.contrib.auth.mixins import UserPassesTestMixin
 
-class ProviderListView(SingleTableView):
+class ProviderListView(UserPassesTestMixin, SingleTableView):
     table_class = ProviderTable
     queryset = Provider.objects.all()
     template_name = 'SharixAdmin/provider.html'
@@ -18,7 +20,15 @@ class ProviderListView(SingleTableView):
         }))
         return context
     
+    def test_func(self) -> bool or None:
+        group_names = ('PARTNER-ADMIN')
+        if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
+            return True
+        return False
+
+    
 @login_required
+@group_required('PARTNER-ADMIN')
 def change_provider_status(request):
     if request.method == 'POST':
         provider_id = request.POST.get('provider_id')

+ 2 - 2
SharixAdmin/views/service.py

@@ -20,13 +20,13 @@ class ServiceListView(UserPassesTestMixin, SingleTableView):
         return context
     
     def test_func(self) -> bool or None:
-        group_names = ('PARTNER-ADMIN')
+        group_names = ('PROVIDER')
         if bool(self.request.user.groups.filter(name=group_names)) or self.request.user.is_superuser:
             return True
         return False
 
 @login_required
-@group_required('PARTNER-ADMIN')
+@group_required('PROVIDER')
 def change_service_status(request):
     if request.method == 'POST':
         service_id = request.POST.get('service_id')

+ 1 - 1
SharixAdmin/views/service_type.py

@@ -57,7 +57,7 @@ class ServiceTypeUpdateView(UserPassesTestMixin, UpdateView):
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context.update(get_context(self.request, {
-            'title': 'Тарифы услуг',
+            'title': 'Услуги сервиса',
             'object_list': context['object_list'],
         }))
         return context