Browse Source

Set custom pages is global, and make form where can change user

responsibilities groups
devel
bashmak 8 years ago
parent
commit
9029b0e14a
  1. 30
      accounts_app/locale/ru/LC_MESSAGES/django.po
  2. 8
      accounts_app/templates/accounts/ext.htm
  3. 5
      accounts_app/templates/accounts/login.html
  4. 25
      accounts_app/templates/accounts/manage_responsibility_groups.html
  5. 21
      accounts_app/urls.py
  6. 52
      accounts_app/views.py
  7. 6
      clientsideapp/templates/clientsideapp/ext.html
  8. 2
      clientsideapp/templates/clientsideapp/index.html
  9. 4
      clientsideapp/templates/clientsideapp/services.html
  10. 0
      templates/custom_pages/footer.htm
  11. 0
      templates/custom_pages/main_page.htm
  12. 0
      templates/custom_pages/service.htm
  13. 0
      templates/custom_pages/service_bottom.htm

30
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 "Ответственность за группы обновлена"

8
accounts_app/templates/accounts/ext.htm

@ -53,6 +53,14 @@
{% trans 'Administrator' %}
</a>
</li>
{% url 'acc_app:manage_responsibility_groups' uid as manrespgr %}
<li{% if manrespgr == request.path %} class="active"{% endif %}>
<a href="{{ manrespgr }}">
{% trans 'Manage responsibility groups' %}
</a>
</li>
{% if request.user.is_superuser %}
{% url 'acc_app:set_abon_groups_permission' uid as set_ag_perm %}
<li{% if set_ag_perm == request.path %} class="active"{% endif %}>

5
accounts_app/templates/accounts/login.html

@ -1,4 +1,4 @@
{% load i18n %}<!DOCTYPE html>
<!DOCTYPE html>{% load i18n %}
<html lang="ru">
<head>
<meta charset="UTF-8">
@ -67,11 +67,10 @@
<footer class="footer">
<div class="container">
<p class="text-muted">
{% trans 'Contact us' %} <i>is-ttk@ya.ru</i>.
{% include 'custom_pages/footer.htm' %}
</p>
</div>
</footer>
</div>
</body>
</html>

25
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 %}
<legend>{% trans 'The responsibility of the administrator of the group of subscribers' %}</legend>
<form action="{% url 'acc_app:manage_responsibility_groups' userprofile.pk %}" method="post" role="form">{% csrf_token %}
{% for grp in groups %}
<div class="checkbox">
<label>
{% if grp.pk in existing_groups %}
<input name="grp" type="checkbox" value="{{ grp.pk }}" checked/>
{% else %}
<input name="grp" type="checkbox" value="{{ grp.pk }}"/>
{% endif %}
{{ grp.title }}
</label>
</div>
{% endfor %}
<div class="btn-group">
<input type="submit" class="btn btn-primary" value="{% trans 'Save' %}">
<input type="reset" class="btn btn-default" value="{% trans 'Reset' %}">
</div>
</form>
{% endblock %}

21
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<uid>\d+)$', views.profile_show, name='other_profile'),
url(r'^(?P<uid>\d+)/perms$', views.perms, name='setup_perms'),
url(r'^(?P<uid>\d+)/perms/(?P<klass_name>[a-z_]+\.[a-zA-Z_]+)$', views.PermissionClassListView.as_view(), name='perms_klasses'),
url(r'^(?P<uid>\d+)/perms/(?P<klass_name>[a-z_]+\.[a-zA-Z_]+)/(?P<obj_id>\d+)$', views.perms_edit, name='perms_edit'),
url(r'^(?P<uid>\d+)/perms/(?P<klass_name>[a-z_]+\.[a-zA-Z_]+)$',
views.PermissionClassListView.as_view(),
name='perms_klasses'),
url(r'^(?P<uid>\d+)/perms/(?P<klass_name>[a-z_]+\.[a-zA-Z_]+)/(?P<obj_id>\d+)$',
views.perms_edit,
name='perms_edit'),
url(r'^(?P<uid>\d+)/del$', views.delete_profile, name='delete_profile'),
url(r'^(?P<uid>\d+)/user_group_access$', views.set_abon_groups_permission, name='set_abon_groups_permission')
url(r'^(?P<uid>\d+)/user_group_access$',
views.set_abon_groups_permission,
name='set_abon_groups_permission'),
url(r'^(?P<uid>\d+)/manage_responsibility_groups/$',
views.ManageResponsibilityGroups.as_view(),
name='manage_responsibility_groups')
]

52
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):
class SignOut(RedirectView):
url = reverse_lazy('acc_app:login')
def get(self, request, *args, **kwargs):
logout(request)
return redirect('acc_app:login')
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())

6
clientsideapp/templates/clientsideapp/ext.html

@ -83,13 +83,13 @@
{% block client_main %}{% endblock %}
</div>
<div id="footer">
<footer>
<div class="container">
<p class="text-muted">
{% include 'clientsideapp/custom_pages/footer.htm' %}
{% include 'custom_pages/footer.htm' %}
</p>
</div>
</div>
</footer>
</body>

2
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 %}

4
clientsideapp/templates/clientsideapp/services.html

@ -75,11 +75,11 @@
</div>
</div>
{% 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 %}
</div>
</div>
{% include 'clientsideapp/custom_pages/service_bottom.htm' %}
{% include 'custom_pages/service_bottom.htm' %}
{% endblock %}

0
clientsideapp/templates/clientsideapp/custom_pages/footer.htm → templates/custom_pages/footer.htm

0
clientsideapp/templates/clientsideapp/custom_pages/main_page.htm → templates/custom_pages/main_page.htm

0
clientsideapp/templates/clientsideapp/custom_pages/service.htm → templates/custom_pages/service.htm

0
clientsideapp/templates/clientsideapp/custom_pages/service_bottom.htm → templates/custom_pages/service_bottom.htm

Loading…
Cancel
Save