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' permission_required = 'agenda.can_manage_agenda'
allow_ajax = True allow_ajax = True
url = 'item_overview' url_name = 'item_overview'
model = Item model = Item
def get_ajax_context(self, **kwargs): def get_ajax_context(self, **kwargs):
@ -123,16 +123,7 @@ class ItemUpdate(UpdateView):
model = Item model = Item
context_object_name = 'item' context_object_name = 'item'
form_class = ItemForm form_class = ItemForm
success_url = 'item_overview' success_url_name = '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())
class ItemCreate(CreateView): class ItemCreate(CreateView):
@ -144,16 +135,7 @@ class ItemCreate(CreateView):
model = Item model = Item
context_object_name = 'item' context_object_name = 'item'
form_class = ItemForm form_class = ItemForm
success_url = 'item_overview' success_url_name = '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())
class ItemDelete(DeleteView): class ItemDelete(DeleteView):
@ -162,6 +144,7 @@ class ItemDelete(DeleteView):
""" """
permission_required = 'agenda.can_manage_agenda' permission_required = 'agenda.can_manage_agenda'
model = Item model = Item
question_url_name = 'item_overview'
success_url_name = 'item_overview' success_url_name = 'item_overview'
def get_answer_options(self): def get_answer_options(self):
@ -221,12 +204,11 @@ def get_widgets(request):
""" """
return the agenda widget for the projector-tab. return the agenda widget for the projector-tab.
""" """
return [ return [Widget(
Widget( name='agenda',
name='agenda', display_name=_('Agenda'),
display_name=_('Agenda'), template='agenda/widget.html',
template='agenda/widget.html', context={
context={ 'agenda': SLIDE['agenda'],
'agenda': SLIDE['agenda'], 'items': Item.objects.all()},
'items': Item.objects.all()}, permission_required='projector.can_manage_projector')]
permission_required='projector.can_manage_projector')]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,9 @@ class ProjectorSlide(models.Model, SlideMixin):
} }
@models.permalink @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': if link == 'delete':
return ('customslide_delete', [str(self.id)]) return ('customslide_delete', [str(self.id)])

View File

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