Updated some views for the new utils.views style

This commit is contained in:
Oskar Hahn 2013-02-03 19:43:36 +01:00
parent 139ba74459
commit 90614cc637
8 changed files with 33 additions and 41 deletions

View File

@ -91,7 +91,7 @@ class SetClosed(RedirectView, SingleObjectMixin):
"""
permission_required = 'agenda.can_manage_agenda'
allow_ajax = True
url = 'item_overview'
url_name = 'item_overview'
model = Item
def get_ajax_context(self, **kwargs):
@ -123,16 +123,7 @@ class ItemUpdate(UpdateView):
model = Item
context_object_name = 'item'
form_class = ItemForm
success_url = 'item_overview'
apply_url = 'item_edit'
def get_success_url(self):
messages.success(
self.request, _("Item %s was successfully modified.")
% html_strong(self.request.POST['title']))
if 'apply' in self.request.POST:
return ''
return reverse(super(UpdateView, self).get_success_url())
success_url_name = 'item_overview'
class ItemCreate(CreateView):
@ -144,16 +135,7 @@ class ItemCreate(CreateView):
model = Item
context_object_name = 'item'
form_class = ItemForm
success_url = 'item_overview'
apply_url = 'item_edit'
def get_success_url(self):
messages.success(
self.request, _("Item %s was successfully created.")
% html_strong(self.request.POST['title']))
if 'apply' in self.request.POST:
return reverse(self.get_apply_url(), args=[self.object.id])
return reverse(super(CreateView, self).get_success_url())
success_url_name = 'item_overview'
class ItemDelete(DeleteView):
@ -162,6 +144,7 @@ class ItemDelete(DeleteView):
"""
permission_required = 'agenda.can_manage_agenda'
model = Item
question_url_name = 'item_overview'
success_url_name = 'item_overview'
def get_answer_options(self):
@ -221,8 +204,7 @@ def get_widgets(request):
"""
return the agenda widget for the projector-tab.
"""
return [
Widget(
return [Widget(
name='agenda',
display_name=_('Agenda'),
template='agenda/widget.html',

View File

@ -635,6 +635,7 @@ class Config(FormView):
permission_required = 'config.can_manage_config'
form_class = ConfigForm
template_name = 'assignment/config.html'
success_url_name = 'config_assignment'
def get_initial(self):
return {
@ -685,8 +686,7 @@ def register_tab(request):
def get_widgets(request):
return [
Widget(
return [Widget(
name='assignments',
display_name=_('Elections'),
template='assignment/widget.html',

View File

@ -33,6 +33,7 @@ class GeneralConfig(FormView):
permission_required = 'config.can_manage_config'
form_class = GeneralConfigForm
template_name = 'config/general.html'
success_url_name = 'config_general'
def get_initial(self):
return {

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load tags %}

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load tags %}

View File

@ -163,6 +163,7 @@ class UserCreateView(CreateView):
model = User
context_object_name = 'edit_user'
form_class = UserCreateForm
success_url_name = 'user_overview'
def manipulate_object(self, form):
self.object.username = gen_username(
@ -181,6 +182,7 @@ class UserUpdateView(UpdateView):
model = User
context_object_name = 'edit_user'
form_class = UserUpdateForm
success_url_name = 'user_overview'
class UserDeleteView(DeleteView):
@ -396,6 +398,7 @@ class GroupCreateView(CreateView):
context_object_name = 'group'
model = Group
form_class = GroupForm
success_url_name = 'user_group_overview'
def get(self, request, *args, **kwargs):
delete_default_permissions()
@ -411,6 +414,7 @@ class GroupUpdateView(UpdateView):
model = Group
context_object_name = 'group'
form_class = GroupForm
success_url_name = 'user_group_overview'
def get(self, request, *args, **kwargs):
delete_default_permissions()
@ -439,6 +443,7 @@ class Config(FormView):
permission_required = 'config.can_manage_config'
form_class = ConfigForm
template_name = 'participant/config.html'
success_url_name = 'config_participant'
def get_initial(self):
return {

View File

@ -38,7 +38,9 @@ class ProjectorSlide(models.Model, SlideMixin):
}
@models.permalink
def get_absolute_url(self, link='delete'):
def get_absolute_url(self, link='edit'):
if link == 'edit':
return ('customslide_edit', [str(self.id)])
if link == 'delete':
return ('customslide_delete', [str(self.id)])

View File

@ -341,6 +341,7 @@ class CustomSlideCreateView(CreateView):
template_name = 'projector/new.html'
model = ProjectorSlide
context_object_name = 'customslide'
success_url_name = 'dashboard'
class CustomSlideUpdateView(UpdateView):
@ -351,6 +352,7 @@ class CustomSlideUpdateView(UpdateView):
template_name = 'projector/new.html'
model = ProjectorSlide
context_object_name = 'customslide'
success_url_name = 'dashboard'
class CustomSlideDeleteView(DeleteView):
@ -359,7 +361,7 @@ class CustomSlideDeleteView(DeleteView):
"""
permission_required = 'projector.can_manage_projector'
model = ProjectorSlide
url_name = 'dashboard'
success_url_name = 'dashboard'
def register_tab(request):