diff --git a/accounts_app/locale/ru/LC_MESSAGES/django.po b/accounts_app/locale/ru/LC_MESSAGES/django.po index eeb76b2..7109797 100644 --- a/accounts_app/locale/ru/LC_MESSAGES/django.po +++ b/accounts_app/locale/ru/LC_MESSAGES/django.po @@ -278,20 +278,26 @@ msgstr "Учётная запись удалена" msgid "Permissions has successfully updated" msgstr "Права успешно обновлены" -#~ msgid "The responsibility of the administrator of the group of subscribers" -#~ msgstr "Ответственность администратора за группы абонентов" +msgid "The responsibility of the administrator of the group of subscribers" +msgstr "Ответственность администратора за группы абонентов" -#~ msgid "Administrator" -#~ msgstr "Администратор" +msgid "Administrator" +msgstr "Администратор" -#~ msgid "Options" -#~ msgstr "Настройки" +msgid "Options" +msgstr "Настройки" -#~ msgid "Change self onfo" -#~ msgstr "Изменить инфу о себе" +msgid "Change self onfo" +msgstr "Изменить инфу о себе" -#~ msgid "Edit" -#~ msgstr "Редактировать" +msgid "Edit" +msgstr "Редактировать" -#~ msgid "Access to groups" -#~ msgstr "Доступ к группам" +msgid "Access to groups" +msgstr "Доступ к группам" + +msgid "Manage responsibility groups" +msgstr "Группы администратора" + +msgid "Responsibilities has been updated" +msgstr "Ответственность за группы обновлена" diff --git a/accounts_app/templates/accounts/ext.htm b/accounts_app/templates/accounts/ext.htm index fe95281..4c08a3d 100644 --- a/accounts_app/templates/accounts/ext.htm +++ b/accounts_app/templates/accounts/ext.htm @@ -53,6 +53,14 @@ {% trans 'Administrator' %} + + {% url 'acc_app:manage_responsibility_groups' uid as manrespgr %} + + + {% trans 'Manage responsibility groups' %} + + + {% if request.user.is_superuser %} {% url 'acc_app:set_abon_groups_permission' uid as set_ag_perm %} diff --git a/accounts_app/templates/accounts/login.html b/accounts_app/templates/accounts/login.html index 029d1ac..5eb46c4 100644 --- a/accounts_app/templates/accounts/login.html +++ b/accounts_app/templates/accounts/login.html @@ -1,4 +1,4 @@ -{% load i18n %} +{% load i18n %} @@ -65,13 +65,12 @@
-
-

- {% trans 'Contact us' %} is-ttk@ya.ru. -

-
+
+

+ {% include 'custom_pages/footer.htm' %} +

+
- diff --git a/accounts_app/templates/accounts/manage_responsibility_groups.html b/accounts_app/templates/accounts/manage_responsibility_groups.html new file mode 100644 index 0000000..263eac8 --- /dev/null +++ b/accounts_app/templates/accounts/manage_responsibility_groups.html @@ -0,0 +1,25 @@ +{% extends request.is_ajax|yesno:'nullcont.htm,accounts/ext.htm' %} +{% load i18n %} +{% block content %} + + {% trans 'The responsibility of the administrator of the group of subscribers' %} +
{% csrf_token %} + {% for grp in groups %} +
+ +
+ {% endfor %} +
+ + +
+
+ +{% endblock %} diff --git a/accounts_app/urls.py b/accounts_app/urls.py index 20567bd..dfab615 100644 --- a/accounts_app/urls.py +++ b/accounts_app/urls.py @@ -1,4 +1,3 @@ -# -*- coding:utf-8 -*- from django.conf.urls import url from . import views @@ -9,7 +8,7 @@ app_name = 'account_app' urlpatterns = [ url(r'^login/', views.to_signin, name='login'), - url(r'^logout/', views.sign_out, name='logout'), + url(r'^logout/', views.SignOut.as_view(), name='logout'), url(r'^me$', views.profile_show, name='profile'), @@ -22,10 +21,22 @@ urlpatterns = [ url(r'^(?P\d+)$', views.profile_show, name='other_profile'), url(r'^(?P\d+)/perms$', views.perms, name='setup_perms'), - url(r'^(?P\d+)/perms/(?P[a-z_]+\.[a-zA-Z_]+)$', views.PermissionClassListView.as_view(), name='perms_klasses'), - url(r'^(?P\d+)/perms/(?P[a-z_]+\.[a-zA-Z_]+)/(?P\d+)$', views.perms_edit, name='perms_edit'), + + url(r'^(?P\d+)/perms/(?P[a-z_]+\.[a-zA-Z_]+)$', + views.PermissionClassListView.as_view(), + name='perms_klasses'), + + url(r'^(?P\d+)/perms/(?P[a-z_]+\.[a-zA-Z_]+)/(?P\d+)$', + views.perms_edit, + name='perms_edit'), + url(r'^(?P\d+)/del$', views.delete_profile, name='delete_profile'), - url(r'^(?P\d+)/user_group_access$', views.set_abon_groups_permission, name='set_abon_groups_permission') + url(r'^(?P\d+)/user_group_access$', + views.set_abon_groups_permission, + name='set_abon_groups_permission'), + url(r'^(?P\d+)/manage_responsibility_groups/$', + views.ManageResponsibilityGroups.as_view(), + name='manage_responsibility_groups') ] diff --git a/accounts_app/views.py b/accounts_app/views.py index 6e72be1..f9b76a6 100644 --- a/accounts_app/views.py +++ b/accounts_app/views.py @@ -2,12 +2,13 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth import authenticate, login, logout from django.core.exceptions import PermissionDenied -from django.urls import NoReverseMatch -from django.shortcuts import render, redirect, get_object_or_404 +from django.http import HttpResponseRedirect +from django.urls import NoReverseMatch, reverse_lazy +from django.shortcuts import render, redirect, get_object_or_404, resolve_url from django.contrib import messages from django.utils.decorators import method_decorator from django.utils.translation import ugettext as _ -from django.views.generic import ListView +from django.views.generic import ListView, UpdateView, RedirectView from django.conf import settings from group_app.models import Group @@ -24,12 +25,6 @@ class BaseAccListView(ListView): paginate_by = getattr(settings, 'PAGINATION_ITEMS_PER_PAGE', 10) -@login_required -@mydefs.only_admins -def home(request): - return redirect('acc_app:profile') - - def to_signin(request): nextl = request.GET.get('next') nextl = '' if nextl == 'None' or nextl is None or nextl.isspace() else nextl @@ -58,9 +53,12 @@ def to_signin(request): return redirect('acc_app:profile') -def sign_out(request): - logout(request) - return redirect('acc_app:login') +class SignOut(RedirectView): + url = reverse_lazy('acc_app:login') + + def get(self, request, *args, **kwargs): + logout(request) + return super(SignOut, self).get(request, *args, **kwargs) @login_required @@ -299,3 +297,35 @@ def set_abon_groups_permission(request, uid): 'groups': groups, 'picked_groups_ids': picked_groups }) + + +@method_decorator([login_required, mydefs.only_admins], name='dispatch') +class ManageResponsibilityGroups(ListView): + http_method_names = ['get', 'post'] + template_name = 'accounts/manage_responsibility_groups.html' + context_object_name = 'groups' + queryset = Group.objects.only('pk', 'title') + + def get_success_url(self): + return resolve_url('acc_app:manage_responsibility_groups', self.kwargs.get('uid')) + + def dispatch(self, request, *args, **kwargs): + uid = self.kwargs.get('uid') + self.object = get_object_or_404(UserProfile, pk=uid) + return super(ManageResponsibilityGroups, self).dispatch(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + context = super(ManageResponsibilityGroups, self).get_context_data(**kwargs) + context['uid'] = self.kwargs.get('uid') + context['userprofile'] = self.object + context['existing_groups'] = [g.get('pk') for g in self.object.responsibility_groups.only('pk').values('pk')] + return context + + def post(self, request, *args, **kwargs): + checked_groups = [int(ag) for ag in request.POST.getlist('grp', default=0)] + profile = self.object + profile.responsibility_groups.clear() + profile.responsibility_groups.add(*[int(g) for g in checked_groups]) + profile.save() + messages.success(request, _('Responsibilities has been updated')) + return HttpResponseRedirect(self.get_success_url()) diff --git a/clientsideapp/templates/clientsideapp/ext.html b/clientsideapp/templates/clientsideapp/ext.html index b9541b5..65e236c 100644 --- a/clientsideapp/templates/clientsideapp/ext.html +++ b/clientsideapp/templates/clientsideapp/ext.html @@ -83,13 +83,13 @@ {% block client_main %}{% endblock %} - + diff --git a/clientsideapp/templates/clientsideapp/index.html b/clientsideapp/templates/clientsideapp/index.html index a881d0e..8897641 100644 --- a/clientsideapp/templates/clientsideapp/index.html +++ b/clientsideapp/templates/clientsideapp/index.html @@ -1,4 +1,4 @@ {% extends 'clientsideapp/ext.html' %} {% block client_main %} - {% include 'clientsideapp/custom_pages/main_page.htm' %} + {% include 'custom_pages/main_page.htm' %} {% endblock %} diff --git a/clientsideapp/templates/clientsideapp/services.html b/clientsideapp/templates/clientsideapp/services.html index bb6f623..45abb0d 100644 --- a/clientsideapp/templates/clientsideapp/services.html +++ b/clientsideapp/templates/clientsideapp/services.html @@ -75,11 +75,11 @@ {% if current_service %} - {% include 'clientsideapp/custom_pages/service.htm' with active_service=current_service %} + {% include 'custom_pages/service.htm' with active_service=current_service %} {% endif %} - {% include 'clientsideapp/custom_pages/service_bottom.htm' %} + {% include 'custom_pages/service_bottom.htm' %} {% endblock %} diff --git a/clientsideapp/templates/clientsideapp/custom_pages/footer.htm b/templates/custom_pages/footer.htm similarity index 100% rename from clientsideapp/templates/clientsideapp/custom_pages/footer.htm rename to templates/custom_pages/footer.htm diff --git a/clientsideapp/templates/clientsideapp/custom_pages/main_page.htm b/templates/custom_pages/main_page.htm similarity index 100% rename from clientsideapp/templates/clientsideapp/custom_pages/main_page.htm rename to templates/custom_pages/main_page.htm diff --git a/clientsideapp/templates/clientsideapp/custom_pages/service.htm b/templates/custom_pages/service.htm similarity index 100% rename from clientsideapp/templates/clientsideapp/custom_pages/service.htm rename to templates/custom_pages/service.htm diff --git a/clientsideapp/templates/clientsideapp/custom_pages/service_bottom.htm b/templates/custom_pages/service_bottom.htm similarity index 100% rename from clientsideapp/templates/clientsideapp/custom_pages/service_bottom.htm rename to templates/custom_pages/service_bottom.htm