added AjaxView

This commit is contained in:
Oskar Hahn 2012-04-12 14:20:05 +02:00
parent 3eeae673c0
commit 497a8cdb70
3 changed files with 11 additions and 1 deletions

View File

@ -22,6 +22,7 @@
<p>{%trans "Results of" %} {{ ballot }}. {%trans "Vote" %}</p>
<i>-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}</i>
<form action="" method="post">{% csrf_token %}
<span id="poll_id" style="display:none">{{ poll.id }}</span>
<table class="table" style="width: auto;">
<tr>
<th>{% trans "Option" %}</th>

View File

@ -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 = [

View File

@ -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