From 533c65562d6ad96e77d2281868065a8f73e44e77 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 8 Nov 2012 18:57:53 +0100 Subject: [PATCH 1/5] Don't allow to deactivate or delete the superuser or yourself. Otherwise it's very danger to lock out your current (superuser) session. --- .../templates/participant/overview.html | 2 ++ openslides/participant/views.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openslides/participant/templates/participant/overview.html b/openslides/participant/templates/participant/overview.html index 2ab17289f..4a9aa133b 100644 --- a/openslides/participant/templates/participant/overview.html +++ b/openslides/participant/templates/participant/overview.html @@ -93,6 +93,7 @@ + {% if user != request_user and not user.is_superuser %} @@ -102,6 +103,7 @@ + {% endif %} {% endif %} diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 974d7d183..b1131ee5c 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -127,12 +127,13 @@ class UserOverview(ListView): # list of all existing categories details = [p['detail'] for p in User.objects.values('detail') .exclude(detail='').distinct()] - # list of all existing committees committees = [p['committee'] for p in User.objects.values('committee') .exclude(committee='').distinct()] + # context vars context.update({ 'allusers': all_users, + 'request_user': self.request.user, 'percent': round(percent, 1), 'details': details, 'committees': committees, @@ -204,6 +205,13 @@ class UserDeleteView(DeleteView): model = User url = 'user_overview' + def pre_redirect(self, request, *args, **kwargs): + if self.get_object() == self.request.user: + messages.error(request, _("You can not delete yourself.")) + elif self.get_object().is_superuser: + messages.error(request, _("You can not delete the administrator.")) + else: + super(DeleteView, self).pre_redirect(request, *args, **kwargs) class SetUserStatusView(RedirectView, SingleObjectMixin): """ @@ -220,6 +228,12 @@ class SetUserStatusView(RedirectView, SingleObjectMixin): if action == 'activate': self.object.is_active = True elif action == 'deactivate': + if self.get_object().user == self.request.user: + messages.error(request, _("You can not deactivate yourself.")) + return + elif self.get_object().is_superuser: + messages.error(request, _("You can not deactivate the administrator.")) + return self.object.is_active = False elif action == 'toggle': self.object.is_active = not self.object.is_active From 5623bb6888bd8377ed53ef8e24574633a3dfbce6 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 8 Nov 2012 19:13:31 +0100 Subject: [PATCH 2/5] Move professional support message into base template footer. --- openslides/config/models.py | 4 ---- openslides/templates/base.html | 2 +- openslides/utils/views.py | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/openslides/config/models.py b/openslides/config/models.py index 51a3958ae..4620a2d51 100644 --- a/openslides/config/models.py +++ b/openslides/config/models.py @@ -88,10 +88,6 @@ def default_config(sender, key, **kwargs): 'presentation': '', 'frontpage_title': _('Welcome to OpenSlides'), 'frontpage_welcometext': _('[Place for your welcome text.]'), - 'show_help_text': True, - 'help_text': _("Get professional support for OpenSlides on %s.") % - " \ - www.openslides.org", 'system_enable_anonymous': False, }.get(key) diff --git a/openslides/templates/base.html b/openslides/templates/base.html index f8050244f..2966c7c14 100644 --- a/openslides/templates/base.html +++ b/openslides/templates/base.html @@ -76,7 +76,7 @@ {% endblock %} diff --git a/openslides/utils/views.py b/openslides/utils/views.py index d3fd10d07..5d9e1303d 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -377,8 +377,6 @@ class FrontPage(TemplateView): continue if tab.permission: apps.append(tab) - if config['show_help_text']: - messages.info(self.request, config['help_text']) context.update({ 'apps': apps, 'title': config['frontpage_title'], From 216ac95cfb649c76d2f922d8de2c493136894e03 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 8 Nov 2012 20:08:09 +0100 Subject: [PATCH 3/5] Redirect to dashboard after submit widget selection form. --- openslides/projector/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openslides/projector/views.py b/openslides/projector/views.py index 958010ac7..7f008c87e 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -21,6 +21,7 @@ from django.core.urlresolvers import reverse from django.db import transaction from django.db.models import Q from django.dispatch import receiver +from django.shortcuts import redirect from django.utils.datastructures import SortedDict from django.utils.importlib import import_module from django.utils.translation import ugettext_lazy as _ @@ -206,8 +207,7 @@ class SelectWidgetsView(TemplateView): else: transaction.commit() self.request.session['widgets'] = activated_widgets - return self.render_to_response(context) - + return redirect(reverse('dashboard')) class ProjectorEdit(RedirectView): From 81570b61e6b3b83a4aafb64017ac47550d155302 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Thu, 8 Nov 2012 20:11:06 +0100 Subject: [PATCH 4/5] Rename submenu titel 'projector' to 'dashboard'. --- openslides/projector/templates/projector/base_projector.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openslides/projector/templates/projector/base_projector.html b/openslides/projector/templates/projector/base_projector.html index 9bcc440c3..2aae46a8d 100644 --- a/openslides/projector/templates/projector/base_projector.html +++ b/openslides/projector/templates/projector/base_projector.html @@ -4,12 +4,12 @@ {% load i18n %} {% load staticfiles %} -{% block title %}{{ block.super}} – {% trans 'Projector' %} {% endblock %} +{% block title %}{{ block.super}} – {% trans 'Dashboard' %} {% endblock %} {% block submenu %} {% url dashboard as url_dashboard %} {% url projector_select_widgets as url_select_widget %} -

{% trans "Projector" %}

+

{% trans "Dashboard" %}

    {% trans 'Overview' %} From 945081f7a6128ef64a34243c86db28471a4151f3 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 9 Nov 2012 09:25:14 +0100 Subject: [PATCH 5/5] Some minor changes and restructure work on howto create probable document. --- extras/win32-portable/create_portable.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/extras/win32-portable/create_portable.txt b/extras/win32-portable/create_portable.txt index 6770efd3f..6213aafd6 100644 --- a/extras/win32-portable/create_portable.txt +++ b/extras/win32-portable/create_portable.txt @@ -6,16 +6,19 @@ How to create a new portable Windows distribution of OpenSlides: easy_install -Z django django-mptt reportlab pil -2.) Install OpenSlides by running python setup.py install in the top directory - of OpenSlides. - NOTE: This step must be repeated whenever you make changes to OpenSlides +2.) Install OpenSlides by running in the top directory: -3.) In the main directory of the OpenSlides checkout execute: + python setup.py install - python extras/win32-portable/prepare_portable.py + NOTE: This step must be repeated whenever you make changes to OpenSlides. -4.) The portable OpenSlides distribution is now ready as a zip in the - 'dist/' directory +3.) Run in the main directory of the OpenSlides checkout: -Note: Creating the portable Windows distribution of OpenSlides is not possible, + python extras\win32-portable\prepare_portable.py + +4.) The portable OpenSlides distribution is now ready as a zip archive + in the 'dist' directory + + +NOTE: Creating the portable Windows distribution of OpenSlides is not possible, if Python is installed in 64-bit version.