From 497a8cdb709b6e2d0e7c9fac68a70184f6c5ff8a Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Thu, 12 Apr 2012 14:20:05 +0200 Subject: [PATCH] added AjaxView --- .../application/templates/application/poll_view.html | 1 + openslides/system/models.py | 2 +- openslides/utils/views.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openslides/application/templates/application/poll_view.html b/openslides/application/templates/application/poll_view.html index f9be853fc..6d2a4dd34 100644 --- a/openslides/application/templates/application/poll_view.html +++ b/openslides/application/templates/application/poll_view.html @@ -22,6 +22,7 @@

{%trans "Results of" %} {{ ballot }}. {%trans "Vote" %}

-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}
{% csrf_token %} + diff --git a/openslides/system/models.py b/openslides/system/models.py index d439d5f2d..d72d7559b 100644 --- a/openslides/system/models.py +++ b/openslides/system/models.py @@ -86,7 +86,7 @@ from openslides.utils.signals import template_manipulation @receiver(template_manipulation, dispatch_uid="system_base_system") def set_submenu(sender, request, context, **kwargs): - if sender.__class__.__module__ != 'system.views': + if not request.path.startswith('/config/'): return None selected = True if request.path == reverse('config_general') else False menu_links = [ diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 0755a051e..942e7b11e 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -43,6 +43,7 @@ FREE_TO_GO = 'free to go' View = _View + class LoginMixin(object): @method_decorator(login_required) def dispatch(self, request, *args, **kwargs): @@ -81,6 +82,14 @@ class ListView(PermissionMixin, _ListView): return context +class AjaxView(PermissionMixin, View): + def get(self, request, *args, **kwargs): + return HttpResponse(json.dumps(self.get_ajax_context(**kwargs))) + + def get_ajax_context(self, **kwargs): + return {} + + class RedirectView(PermissionMixin, _RedirectView): permanent = False allow_ajax = False
{% trans "Option" %}