def post(self, request, *args, **kwargs): context = self.groundwork(request, args, kwargs) context['second_form'] = StaffAreaForm(request.POST) if context['second_form'].is_valid(): new_event = context['second_form'].save() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="STAFF_AREA_CREATE_SUCCESS", defaults={ 'summary': "Staff area has been created", 'description': "Staff area has been created." }) messages.success( request, '%s<br>Title: %s' % (user_message[0].description, new_event.title)) if request.POST.get('set_event') == 'More...' and ( context['volunteer_scheduling']): return HttpResponseRedirect( "%s?start_open=False" % reverse('edit_staff', urlconf='gbe.scheduling.urls', args=[new_event.id])) else: return HttpResponseRedirect( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.conference.conference_slug])) return render(request, self.template, context)
def post(self, request, *args, **kwargs): if "manage-opps" in request.path: return super(EditStaffAreaView, self).post(request, *args, **kwargs) self.groundwork(request, args, kwargs) context = {} context['event_form'] = StaffAreaForm(request.POST, instance=self.staff_area) if context['event_form'].is_valid(): new_event = context['event_form'].save() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="STAFF_AREA_UPDATE_SUCCESS", defaults={ 'summary': "Staff Area has been updated", 'description': "Staff Area has been updated." }) messages.success( request, '%s<br>Title: %s' % (user_message[0].description, new_event.title)) if request.POST.get('edit_event', 0) != "Save and Continue": return HttpResponseRedirect( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.conference.conference_slug])) else: return HttpResponseRedirect("%s?volunteer_open=True" % self.success_url) else: context['start_open'] = True return render(request, self.template, self.make_context(request, errorcontext=context))
def make_context(self, request, errorcontext=None): context = super(EditStaffAreaView, self).make_context(request, errorcontext) context['edit_title'] = 'Edit Staff Area' context['staff_id'] = self.staff_area.pk # if there was an error in the edit form if 'event_form' not in context: context['event_form'] = StaffAreaForm(instance=self.staff_area) if validate_perms(request, ('Volunteer Coordinator', ), require=False): volunteer_initial_info = { 'max_volunteer': self.staff_area.default_volunteers, 'location': self.staff_area.default_location } context.update( self.get_manage_opportunity_forms( volunteer_initial_info, self.manage_vol_url, self.conference, request, errorcontext=errorcontext, labels=[ self.conference.conference_slug, self.staff_area.slug ])) else: context['start_open'] = True return context
def get(self, request, *args, **kwargs): context = self.groundwork(request, args, kwargs) context['second_form'] = StaffAreaForm( initial={'conference': self.conference}) return render(request, self.template, context)