def book_event(self, scheduling_form, people_formset, working_class): room = get_object_or_404(Room, name=scheduling_form.cleaned_data['location']) start_time = get_start_time(scheduling_form.cleaned_data) labels = [self.conference.conference_slug] if working_class.calendar_type: labels += [working_class.calendar_type] people = [] for assignment in people_formset: if assignment.is_valid() and assignment.cleaned_data['worker']: people += [ Person(user=assignment.cleaned_data['worker'].workeritem. as_subtype.user_object, public_id=assignment.cleaned_data['worker']. workeritem.pk, role=assignment.cleaned_data['role']) ] response = create_occurrence( working_class.eventitem_id, start_time, scheduling_form.cleaned_data['max_volunteer'], people=people, locations=[room], labels=labels) return response
def copy_event(self, occurrence, delta, conference, room, labels, parent_event_id=None, set_room=False): new_event_room = room if (not set_room) and \ occurrence.location.as_subtype.conferences.filter( pk=conference.pk).exists(): new_event_room = occurrence.location gbe_event_copy = occurrence.as_subtype gbe_event_copy.pk = None gbe_event_copy.event_id = None gbe_event_copy.eventitem_ptr_id = None gbe_event_copy.eventitem_id = None gbe_event_copy.e_conference = conference gbe_event_copy.save() response = create_occurrence( gbe_event_copy.eventitem_id, occurrence.starttime + delta, max_volunteer=occurrence.max_volunteer, max_commitments=occurrence.max_commitments, locations=[new_event_room], parent_event_id=parent_event_id, labels=labels, approval=occurrence.approval_needed) return response
def copy_event(self, occurrence, delta, conference, room, labels, root=None): new_event_room = room gbe_event_copy = occurrence.as_subtype gbe_event_copy.pk = None gbe_event_copy.event_id = None gbe_event_copy.eventitem_ptr_id = None gbe_event_copy.eventitem_id = None gbe_event_copy.e_conference = conference gbe_event_copy.save() if root: labels += [self.area.slug] if occurrence.location.as_subtype.conferences.filter( pk=conference.pk).exists(): new_event_room = occurrence.location response = create_occurrence(gbe_event_copy.eventitem_id, occurrence.starttime + delta, max_volunteer=occurrence.max_volunteer, locations=[new_event_room], labels=labels, approval=occurrence.approval_needed) return response
def copy_event(self, occurrence, delta, conference, root=None): gbe_event_copy = occurrence.as_subtype gbe_event_copy.pk = None gbe_event_copy.event_id = None gbe_event_copy.eventitem_ptr_id = None gbe_event_copy.eventitem_id = None gbe_event_copy.e_conference = conference gbe_event_copy.save() labels = [conference.conference_slug, gbe_event_copy.calendar_type] if root: labels += [root.slug] response = create_occurrence(gbe_event_copy.eventitem_id, occurrence.starttime + delta, max_volunteer=occurrence.max_volunteer, locations=[occurrence.location], labels=labels) return response
def copy_event(self, occurrence, delta, conference, root=None): gbe_event_copy = occurrence.as_subtype gbe_event_copy.pk = None gbe_event_copy.event_id = None gbe_event_copy.eventitem_ptr_id = None gbe_event_copy.eventitem_id = None gbe_event_copy.e_conference = conference gbe_event_copy.save() labels = [conference.conference_slug, gbe_event_copy.calendar_type] if root: labels += [root.slug] response = create_occurrence( gbe_event_copy.eventitem_id, occurrence.starttime + delta, max_volunteer=occurrence.max_volunteer, locations=[occurrence.location], labels=labels ) return response
def book_event(self, scheduling_form, people_formset, working_class): room = get_object_or_404( Room, name=scheduling_form.cleaned_data['location']) start_time = get_start_time(scheduling_form.cleaned_data) labels = [self.conference.conference_slug] if working_class.calendar_type: labels += [working_class.calendar_type] people = [] for assignment in people_formset: if assignment.is_valid() and assignment.cleaned_data['worker']: people += [Person( user=assignment.cleaned_data[ 'worker'].workeritem.as_subtype.user_object, public_id=assignment.cleaned_data['worker'].workeritem.pk, role=assignment.cleaned_data['role'])] response = create_occurrence( working_class.eventitem_id, start_time, scheduling_form.cleaned_data['max_volunteer'], people=people, locations=[room], labels=labels) return response
def copy_event(self, occurrence, delta, conference, root=None): parent_event_id = None if root: parent_event_id = root.pk gbe_event_copy = occurrence.as_subtype gbe_event_copy.pk = None gbe_event_copy.event_id = None gbe_event_copy.eventitem_ptr_id = None gbe_event_copy.eventitem_id = None gbe_event_copy.e_conference = conference gbe_event_copy.save() labels = [conference.conference_slug] for label in occurrence.labels: if not Conference.objects.filter(conference_slug=label).exists(): labels += [label] response = create_occurrence( gbe_event_copy.eventitem_id, occurrence.starttime + delta, max_volunteer=occurrence.max_volunteer, locations=[occurrence.location], parent_event_id=parent_event_id, labels=labels ) return response
def do_additional_actions(self, request): response = None context = None if ('create_slot' in request.POST.keys()) or ( 'duplicate_slot' in request.POST.keys()): self.create = True if 'create_slot' in request.POST.keys(): self.event_form = RehearsalSlotForm( request.POST, prefix='new_slot', conference=self.conference) else: self.event_form = RehearsalSlotForm( request.POST, conference=self.conference) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event.e_conference = self.conference self.event.save() response = create_occurrence( self.event.eventitem_id, self.start_time, self.max_volunteer, locations=[self.room], labels=data['labels'], parent_event_id=self.parent_id) else: context = {'createslotform': self.event_form, 'rehearsal_open': True} elif 'edit_slot' in request.POST.keys(): self.event = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) casting_response = get_acts(int(request.POST['opp_sched_id'])) self.event_form = RehearsalSlotForm( request.POST, instance=self.event, initial={'current_acts': len(casting_response.castings)}) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event_form.save() response = update_occurrence( data['opp_sched_id'], self.start_time, self.max_volunteer, locations=[self.room]) else: context = { 'error_slot_form': self.event_form, 'error_slot_occurrence_id': int( request.POST['opp_sched_id']), 'rehearsal_open': True} elif 'delete_slot' in request.POST.keys(): opp = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) title = opp.e_title opp.delete() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="DELETE_REHEARSAL_SUCCESS", defaults={ 'summary': "Rehearsal Slot Deleted", 'description': rehearsal_delete_msg}) messages.success( request, '%s<br>Title: %s' % ( user_message[0].description, title)) return HttpResponseRedirect(self.success_url) return self.check_success_and_return( request, response=response, errorcontext=context, window_controls="rehearsal_open=True")
def post(self, request, *args, **kwargs): error_url = self.groundwork(request, args, kwargs) if error_url: return error_url self.create = False response = None context = None if ('create' in list(request.POST.keys())) or ('duplicate' in list( request.POST.keys())): self.create = True if 'create' in list(request.POST.keys()): self.event_form = VolunteerOpportunityForm( request.POST, prefix='new_opp', conference=self.conference) else: self.event_form = VolunteerOpportunityForm( request.POST, conference=self.conference) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event.e_conference = self.conference self.event.save() response = create_occurrence(self.event.eventitem_id, self.start_time, self.max_volunteer, locations=[self.room], labels=data['labels'], parent_event_id=self.parent_id, approval=self.approval) else: context = { 'createform': self.event_form, 'volunteer_open': True } return self.check_success_and_return(request, response=response, errorcontext=context) elif 'edit' in list(request.POST.keys()): self.event = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) self.event_form = VolunteerOpportunityForm(request.POST, instance=self.event) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event_form.save() response = update_occurrence(data['opp_sched_id'], self.start_time, self.max_volunteer, locations=[self.room], approval=self.approval) else: context = { 'error_opp_form': self.event_form, 'volunteer_open': True } return self.check_success_and_return(request, response=response, errorcontext=context) elif 'delete' in list(request.POST.keys()): opp = get_object_or_404(GenericEvent, event_id=request.POST['opp_event_id']) title = opp.e_title opp.delete() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="DELETE_SUCCESS", defaults={ 'summary': "Volunteer Opportunity Deleted", 'description': "This volunteer opportunity was deleted." }) messages.success( request, '%s<br>Title: %s' % (user_message[0].description, title)) return HttpResponseRedirect(self.success_url) elif 'allocate' in list(request.POST.keys()): response = get_occurrence(request.POST['opp_sched_id']) return HttpResponseRedirect( reverse('edit_volunteer', urlconf='gbe.scheduling.urls', args=[ self.conference.conference_slug, request.POST['opp_sched_id'] ])) else: actions = self.do_additional_actions(request) if actions: return actions else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="UNKNOWN_ACTION", defaults={ 'summary': "Unknown Action", 'description': "This is an unknown action." }) messages.error(request, user_message[0].description) return HttpResponseRedirect(self.success_url)
def post(self, request, *args, **kwargs): error_url = self.groundwork(request, args, kwargs) if error_url: return error_url self.create = False response = None context = None if ('create' in request.POST.keys()) or ( 'duplicate' in request.POST.keys()): self.create = True if 'create' in request.POST.keys(): self.event_form = VolunteerOpportunityForm( request.POST, prefix='new_opp', conference=self.conference) else: self.event_form = VolunteerOpportunityForm( request.POST, conference=self.conference) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event.e_conference = self.conference self.event.save() response = create_occurrence( self.event.eventitem_id, self.start_time, self.max_volunteer, locations=[self.room], labels=data['labels'], parent_event_id=self.parent_id) else: context = {'createform': self.event_form, 'volunteer_open': True} return self.check_success_and_return(request, response=response, errorcontext=context) elif 'edit' in request.POST.keys(): self.event = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) self.event_form = VolunteerOpportunityForm( request.POST, instance=self.event) if self.event_form.is_valid(): data = self.get_basic_form_settings() self.event_form.save() response = update_occurrence( data['opp_sched_id'], self.start_time, self.max_volunteer, locations=[self.room]) else: context = {'error_opp_form': self.event_form, 'volunteer_open': True} return self.check_success_and_return(request, response=response, errorcontext=context) elif 'delete' in request.POST.keys(): opp = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) title = opp.e_title opp.delete() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="DELETE_SUCCESS", defaults={ 'summary': "Volunteer Opportunity Deleted", 'description': "This volunteer opportunity was deleted."}) messages.success( request, '%s<br>Title: %s' % ( user_message[0].description, title)) return HttpResponseRedirect(self.success_url) elif 'allocate' in request.POST.keys(): response = get_occurrence(request.POST['opp_sched_id']) return HttpResponseRedirect( reverse('edit_volunteer', urlconf='gbe.scheduling.urls', args=[self.conference.conference_slug, request.POST['opp_sched_id']])) else: actions = self.do_additional_actions(request) if actions: return actions else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="UNKNOWN_ACTION", defaults={ 'summary': "Unknown Action", 'description': "This is an unknown action."}) messages.error( request, user_message[0].description) return HttpResponseRedirect(self.success_url)