def groundwork(self, request, args, kwargs): self.profile = validate_perms(request, self.permissions) self.area = get_object_or_404(StaffArea, id=int(kwargs['staff_id'])) if self.area.conference.conferenceday_set.count() > 0: self.start_day = self.area.conference.conferenceday_set.order_by( "day").first().day else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NO_CONF_DAYS", defaults={ 'summary': "No Conference Days in Conference", 'description': no_conf_day_msg}) messages.error( request, user_message[0].description) return HttpResponseRedirect(reverse( 'manage_event_list', urlconf='gbe.scheduling.urls', args=[self.area.conference.conference_slug])) response = get_occurrences(labels=[ self.area.slug, self.area.conference.conference_slug]) self.children = response.occurrences show_general_status(request, response, self.__class__.__name__)
def get_list(self, request): pending = get_people( roles=["Pending Volunteer", "Waitlisted", "Rejected"], labels=[self.conference.conference_slug]) show_general_status(request, pending, self.__class__.__name__) rows = [] action = "" for pending_person in pending.people: action_links = { 'email': reverse('mail_to_individual', urlconf='gbe.email.urls', args=[pending_person.public_id]) } for action in ['approve', 'reject', 'waitlist']: if action in volunteer_action_map and ( volunteer_action_map[action]['role'] == (pending_person.role)): action_links[action] = None else: action_links[action] = reverse( self.review_list_view_name, urlconf='gbe.scheduling.urls', args=[ action, pending_person.public_id, pending_person.booking_id ]) row = { 'volunteer': pending_person.user.profile, 'occurrence': pending_person.occurrence, 'staff_areas': StaffArea.objects.filter( conference=self.conference, slug__in=pending_person.occurrence.labels), 'state': pending_person.role.split(' ', 1)[0], 'status': "", 'label': pending_person.label, 'action_links': action_links } if hasattr(pending_person.occurrence, 'container_event'): container = pending_person.occurrence.container_event row['parent_event'] = container.parent_event if pending_person.booking_id == self.changed_id: row['status'] = 'gbe-table-success' elif not row['volunteer'].is_active: row['status'] = "gbe-table-danger" elif pending_person.occurrence.role_count("Volunteer") >= ( pending_person.occurrence.max_volunteer): row['status'] = "gbe-table-warning" elif pending_person.role == "Pending Volunteer": row['status'] = "gbe-table-info" rows.append(row) return rows
def set_status(self, request, kwargs): check = False state = volunteer_action_map[kwargs['action']]['state'] if kwargs['action'] == "approve": check = True profile = get_object_or_404(Profile, pk=kwargs['public_id']) person = Person(user=profile.user_object, public_id=profile.pk, role=volunteer_action_map[kwargs['action']]['role'], booking_id=kwargs['booking_id'], worker=None) response = set_person(person=person) show_general_status(request, response, self.__class__.__name__) if not response.errors: self.changed_id = response.booking_id user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="SET_%s" % person.role, defaults={ 'summary': set_volunteer_role_summary % person.role, 'description': set_volunteer_role_msg % person.role }) full_msg = '%s Person: %s<br/>Event: %s, Start Time: %s' % ( user_message[0].description, str(profile), str(response.occurrence), response.occurrence.starttime.strftime(GBE_DATETIME_FORMAT)) messages.success(request, full_msg) self.send_notifications(request, response, state, person)
def bid_state_change(self, request): # Clear all commitments remove_response = remove_person( user=self.bidder.user_object, labels=[self.object.b_conference.conference_slug], roles=['Volunteer']) show_general_status(request, remove_response, self.__class__.__name__) # if the volunteer has been accepted, set the events. if request.POST['accepted'] == '3': person = Person( user=self.bidder.user_object, public_id=self.bidder.pk, role='Volunteer') for assigned_event in request.POST.getlist('events'): set_response = set_person( assigned_event, person) show_general_status(request, set_response, self.__class__.__name__) email_status = send_schedule_update_mail('Volunteer', self.bidder) self.check_email_status(request, email_status) return super(VolunteerChangeStateView, self).bid_state_change( request)
def staff_area_view(request, area_id): ''' Generates a staff area report: volunteer opportunities scheduled, volunteers scheduled, sorted by time/day See ticket #250 ''' show_style = False viewer_profile = validate_perms(request, 'any', require=True) if 'area' in request.GET.keys(): show_style = (request.GET['area'] == "Show") opps_response = None area = None opps = None if show_style: parent_response = get_occurrences(foreign_event_ids=[area_id]) if parent_response.occurrences: area = parent_response.occurrences[0] opps_response = get_occurrences( parent_event_id=parent_response.occurrences[0].pk) else: area = get_object_or_404(StaffArea, pk=area_id) opps_response = get_occurrences(labels=[ area.conference.conference_slug, area.slug]) if opps_response: show_general_status(request, opps_response, "staff_area") opps = opps_response.occurrences return render(request, 'gbe/report/staff_area_schedule.tmpl', {'opps': opps, 'area': area})
def get(self, request, *args, **kwargs): error_url = self.groundwork(request, args, kwargs) if error_url: return error_url title = str(self.occurrence) start_time = self.occurrence.start_time gbe_event = self.occurrence.eventitem result = delete_occurrence(self.occurrence.pk) show_general_status(request, result, self.__class__.__name__) if len(result.errors) == 0: result = get_occurrences( foreign_event_ids=[self.occurrence.foreign_event_id]) if len(result.occurrences) == 0: gbe_event.visible = False gbe_event.save() user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="DELETE_SUCCESS", defaults={ 'summary': "Occurrence Deletion Completed", 'description': "This event has been deleted." }) messages.success( request, '%s<br>Title: %s,<br> Start Time: %s' % (user_message[0].description, title, start_time.strftime(GBE_DATETIME_FORMAT))) return HttpResponseRedirect(self.redirect_to)
def clear_bookings(self, request, rehearsals, show=None): for item in rehearsals: response = remove_booking(item.event.pk, item.booking_id) show_general_status(request, response, self.__class__.__name__) if show: response = remove_booking(show.event.pk, show.booking_id) show_general_status(request, response, self.__class__.__name__)
def get(self, request, *args, **kwargs): context = self.process_inputs(request, args, kwargs) personal_schedule = [] eval_occurrences = [] if not self.conference or not self.this_day or not self.calendar_type: return render(request, self.template, context) response = get_occurrences( labels=[self.calendar_type, self.conference.conference_slug], day=self.this_day.day) show_general_status(request, response, self.__class__.__name__) if len(response.occurrences) > 0: if request.user.is_authenticated() and hasattr( request.user, 'profile'): sched_response = get_schedule( request.user, labels=[ self.calendar_type, self.conference.conference_slug ]) personal_schedule = sched_response.schedule_items person = Person(user=request.user, public_id=request.user.profile.pk, public_class="Profile") eval_response = get_eval_info(person=person) if len(eval_response.questions) > 0: eval_occurrences = eval_response.occurrences else: eval_occurrences = None max_block_size, context[ 'occurrences'] = self.build_occurrence_display( response.occurrences, personal_schedule, eval_occurrences) grid_size = 2 if max_block_size < 6: grid_size = self.grid_map[max_block_size] context['grid_size'] = grid_size return render(request, self.template, context)
def show_set_act_status(self, request, set_response): more_than_overbooked = False for warning in set_response.warnings: if warning.code != "OCCURRENCE_OVERBOOKED": more_than_overbooked = True if more_than_overbooked or len(set_response.errors) > 0: show_general_status(request, set_response, self.__class__.__name__)
def get(self, request, *args, **kwargs): this_url = reverse( 'set_favorite', args=[kwargs['occurrence_id'], kwargs['state']], urlconf='gbe.scheduling.urls') response = check_user_and_redirect( request, this_url, self.__class__.__name__) if response['error_url']: return HttpResponseRedirect(response['error_url']) self.owner = response['owner'] occurrence_id = int(kwargs['occurrence_id']) interested = get_bookings([occurrence_id], roles=["Interested"]) bookings = [] for person in interested.people: if person.user == self.owner.user_object: bookings += [person.booking_id] if kwargs['state'] == 'on' and len(bookings) == 0: person = Person( user=self.owner.user_object, role="Interested") response = set_person(occurrence_id, person) show_general_status(request, response, self.__class__.__name__) if len(response.errors) == 0 and response.booking_id: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="SET_FAVORITE", defaults={ 'summary': "User has shown interest", 'description': set_favorite_msg}) messages.success(request, user_message[0].description) elif kwargs['state'] == 'off' and len(bookings) > 0: success = True for booking_id in bookings: response = remove_booking(occurrence_id, booking_id) show_general_status(request, response, self.__class__.__name__) if response.booking_id: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="REMOVE_FAVORITE", defaults={ 'summary': "User has shown lack of interest", 'description': unset_favorite_msg}) messages.success(request, user_message[0].description) if request.GET.get('next', None): redirect_to = request.GET['next'] else: redirect_to = reverse('home', urlconf='gbe.urls') return HttpResponseRedirect(redirect_to)
def staff_area_view(request, target): ''' Generates a staff area report: volunteer opportunities scheduled, volunteers scheduled, sorted by time/day See ticket #250 ''' viewer_profile = validate_perms(request, ( 'Act Coordinator', 'Class Coordinator', 'Costume Coordinator', 'Vendor Coordinator', 'Volunteer Coordinator', 'Tech Crew', 'Scheduling Mavens', 'Staff Lead', 'Ticketing - Admin', 'Registrar', ), require=True) other = "Potential" roles = [] if 'filter' in list(request.GET.keys()) and (request.GET['filter'] == "Potential"): other = "Committed" for role, commit in list(role_commit_map.items()): if commit[0] == 1 or (commit[0] > 0 and commit[0] < 4 and other == "Committed"): roles += [role] opps_response = None area = None opps = None conference = None edit_link = None area = get_object_or_404(StaffArea, pk=target) opps_response = get_occurrences( labels=[area.conference.conference_slug, area.slug]) conference = area.conference if area.conference.status != 'completed': edit_link = reverse("edit_staff", urlconf='gbe.scheduling.urls', args=[area.pk]) if opps_response: show_general_status(request, opps_response, "staff_area") opps = opps_response.occurrences return render( request, 'gbe/report/staff_area_schedule.tmpl', { 'opps': opps, 'area': area, 'conference': conference, 'role_commit_map': role_commit_map, 'visible_roles': roles, 'other_option': other, 'edit_link': edit_link, })
def groundwork(self, request, args, kwargs): self.occurrence_id = int(kwargs['occurrence_id']) self.profile = validate_perms(request, self.permissions) response = get_occurrence(self.occurrence_id) show_general_status(request, response, self.__class__.__name__) if not response.occurrence: raise Http404 self.occurrence = response.occurrence self.start_day = self.occurrence.starttime.date() response = get_occurrences(parent_event_id=self.occurrence_id) self.children = response.occurrences show_general_status(request, response, self.__class__.__name__)
def prep_bid(self, request, args, kwargs): super(ActChangeStateView, self).prep_bid(request, args, kwargs) if 'next' in request.POST: self.next_page = request.POST['next'] elif 'next' in request.GET: self.next_page = request.GET['next'] if self.act_accepted(request): response = get_occurrences( foreign_event_ids=[request.POST['show']]) show_general_status(request, response, self.__class__.__name__) if response.occurrences.count() > 0: self.new_show = response.occurrences.first() else: raise Http404
def groundwork(self, request, args, kwargs): self.occurrence_id = int(kwargs['occurrence_id']) self.profile = validate_perms(request, self.permissions) response = get_occurrence(self.occurrence_id) show_general_status(request, response, self.__class__.__name__) if not response.occurrence: raise Http404 self.occurrence = response.occurrence if self.occurrence.as_subtype.__class__.__name__ == "Class": return HttpResponseForbidden("Class copy is not yet available") self.start_day = self.occurrence.starttime.date() response = get_occurrences(parent_event_id=self.occurrence_id) self.children = response.occurrences show_general_status(request, response, self.__class__.__name__)
def all_volunteer_view(request): ''' Generates a staff area report: volunteer opportunities scheduled, volunteers scheduled, sorted by time/day See ticket #250 ''' viewer_profile = validate_perms(request, 'any', require=True) roles = [] if request.GET and request.GET.get('conf_slug'): conference = get_conference_by_slug(request.GET['conf_slug']) else: conference = get_current_conference() for role, commit in list(role_commit_map.items()): if commit[0] > 0 and commit[0] < 4: roles += [role] opps_response = None opps = [] opps_response = get_occurrences( labels=[conference.conference_slug, "Volunteer"]) if opps_response: show_general_status(request, opps_response, "staff_area") for opp in opps_response.occurrences: item = { 'event': opp, 'areas': [], } for area in StaffArea.objects.filter(slug__in=opp.labels, conference=conference): item['areas'] += [area] opps += [item] return render(request, 'gbe/report/flat_volunteer_review.tmpl', {'opps': opps, 'conference': conference, 'conference_slugs': conference_slugs(), 'role_commit_map': role_commit_map, 'visible_roles': roles, 'columns': ['Event', 'Parent', 'Area', 'Date/Time', 'Location', 'Max', 'Current', 'Volunteers'] })
def groundwork(self, request, args, kwargs): self.profile = validate_perms(request, self.permissions) if request.GET.get('next', None): self.redirect_to = request.GET['next'] else: self.redirect_to = reverse('manage_event_list', urlconf='gbe.scheduling.urls') if "occurrence_id" in kwargs: result = get_occurrence(int(kwargs['occurrence_id'])) if result.errors and len(result.errors) > 0: show_general_status(request, result, self.__class__.__name__) return HttpResponseRedirect(self.redirect_to) else: self.occurrence = result.occurrence
def get(self, request, *args, **kwargs): this_url = reverse('set_favorite', args=[kwargs['occurrence_id'], kwargs['state']], urlconf='gbe.scheduling.urls') response = check_user_and_redirect(request, this_url, self.__class__.__name__) if response['error_url']: return HttpResponseRedirect(response['error_url']) self.owner = response['owner'] occurrence_id = int(kwargs['occurrence_id']) interested = get_bookings([occurrence_id], roles=["Interested"]) bookings = [] for person in interested.people: if person.user == self.owner.user_object: bookings += [person.booking_id] if kwargs['state'] == 'on' and len(bookings) == 0: person = Person(user=self.owner.user_object, role="Interested") response = set_person(occurrence_id, person) show_general_status(request, response, self.__class__.__name__) if len(response.errors) == 0 and response.booking_id: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="SET_FAVORITE", defaults={ 'summary': "User has shown interest", 'description': set_favorite_msg }) messages.success(request, user_message[0].description) elif kwargs['state'] == 'off' and len(bookings) > 0: success = True for booking_id in bookings: response = remove_booking(occurrence_id, booking_id) show_general_status(request, response, self.__class__.__name__) if response.booking_id: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="REMOVE_FAVORITE", defaults={ 'summary': "User has shown lack of interest", 'description': unset_favorite_msg }) messages.success(request, user_message[0].description) if request.GET.get('next', None): redirect_to = request.GET['next'] else: redirect_to = reverse('home', urlconf='gbe.urls') return HttpResponseRedirect(redirect_to)
def volunteer_type_view(request, conference_choice, volunteer_type_id): ''' Generates a staff area report: volunteer opportunities scheduled, volunteers scheduled, sorted by time/day See ticket #250 ''' viewer_profile = validate_perms(request, 'any', require=True) vol_type = get_object_or_404(AvailableInterest, pk=volunteer_type_id) eventitem_id_list = GenericEvent.objects.filter( e_conference__conference_slug=conference_choice, volunteer_type=vol_type).values_list('eventitem_id', flat=True) collection = get_occurrences(labels=[conference_choice, 'Volunteer'], foreign_event_ids=eventitem_id_list) show_general_status(request, collection, "volunteer_type") return render(request, 'gbe/report/staff_area_schedule.tmpl', { 'opps': collection.occurrences, 'vol_type': vol_type })
def get(self, request, *args, **kwargs): context = self.process_inputs(request, args, kwargs) personal_schedule = [] if not self.conference or not self.this_day: return render(request, self.template, context) response = get_occurrences( labels=["Volunteer", self.conference.conference_slug], day=self.this_day.day, max_volunteer=1) show_general_status(request, response, self.__class__.__name__) if len(response.occurrences) > 0: if request.user.is_authenticated and hasattr( request.user, 'profile'): all_roles = [] for n, m in role_options: all_roles += [m] sched_response = get_schedule( request.user, labels=["Volunteer", self.conference.conference_slug], roles=all_roles) personal_schedule = sched_response.schedule_items person = Person(user=request.user, public_id=request.user.profile.pk, public_class="Profile") eval_response = get_eval_info(person=person) context['occurrences'] = self.build_occurrence_display( response.occurrences, personal_schedule) context['col_per_hour'] = self.col_per_hour context['grid_list'] = self.make_time_range( self.start_grid_hour * 60, self.end_grid_hour * 60, int(60 / self.col_per_hour)) if self.next_day_end: # hack to roll around the clock context['grid_list'] += self.make_time_range( self.end_grid_hour * 60, (self.end_grid_hour + 1) * 60, int(60 / self.col_per_hour)) context['grid_list'] += self.make_time_range( 0, self.next_day_end * 60, int(60 / self.col_per_hour), True) context['col_fraction'] = 100.0 / len(context['grid_list']) return render(request, self.template, context)
def post(self, request, *args, **kwargs): error_url = self.groundwork(request, args, kwargs) if error_url: return error_url data = self.get_context_data(request) if not data['all_valid']: messages.error( request, UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_SCHED_ERROR", defaults={ 'summary': "Act Order Forms not valid", 'description': act_order_form_invalid })[0].description) data['open_panel'] = 'act' else: for act in data['acts']: person = Person(public_id=act['act'].performer.pk, booking_id=act['form'].prefix, role="Performer", commitment=Commitment( decorator_class=act['act'], order=act['form'].cleaned_data['order'])) response = set_person(person=person, occurrence_id=self.occurrence.pk) # we don't care about overbook warnings on this case response.warnings = [] show_general_status(request, response, self.__class__.__name__) # I can't think of a reason the set_person could fail that isn't # already ruled out by how the request is constructed. messages.success( request, UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_SCHED_SUCCESS", defaults={ 'summary': "Order of Acts was updated", 'description': act_order_submit_success })[0].description) return render(request, self.template, data)
def volunteer_type_view(request, conference_choice, volunteer_type_id): ''' Generates a staff area report: volunteer opportunities scheduled, volunteers scheduled, sorted by time/day See ticket #250 ''' viewer_profile = validate_perms(request, 'any', require=True) vol_type = get_object_or_404(AvailableInterest, pk=volunteer_type_id) eventitem_id_list = GenericEvent.objects.filter( e_conference__conference_slug=conference_choice, volunteer_type=vol_type).values_list('eventitem_id', flat=True) collection = get_occurrences( labels=[conference_choice, 'Volunteer'], foreign_event_ids=eventitem_id_list) show_general_status(request, collection, "volunteer_type") return render(request, 'gbe/report/staff_area_schedule.tmpl', {'opps': collection.occurrences, 'vol_type': vol_type})
def act_techinfo_detail(request, act_id): ''' Show the info for a specific act ''' shows = [] rehearsals = [] order = -1 act = get_object_or_404(Act, pk=act_id) # if this isn't a privileged user, it had better be a member of the # troupe or the performer. if not validate_perms(request, ('Scheduling Mavens', 'Stage Manager', 'Tech Crew', 'Technical Director', 'Producer'), require=False): profile = validate_profile(request) if profile not in act.performer.get_profiles(): raise PermissionDenied if act.accepted == 3: response = get_schedule(labels=[act.b_conference.conference_slug], commitment=act) show_general_status(request, response, "ActTechinfoDetail") for item in response.schedule_items: if item.event not in shows and Show.objects.filter( eventitem_id=item.event.eventitem.eventitem_id).exists(): shows += [item.event] order = item.commitment.order elif item.event not in rehearsals and GenericEvent.objects.filter( eventitem_id=item.event.eventitem.eventitem_id, type='Rehearsal Slot').exists(): rehearsals += [item.event] return render( request, 'gbe/report/act_tech_detail.tmpl', { 'act': act, 'state': acceptance_states[act.accepted][1], 'shows': shows, 'order': order, 'rehearsals': rehearsals })
def bid_state_change(self, request): # Clear all commitments remove_response = remove_person( user=self.bidder.user_object, labels=[self.object.b_conference.conference_slug], roles=['Volunteer']) show_general_status(request, remove_response, self.__class__.__name__) # if the volunteer has been accepted, set the events. if request.POST['accepted'] == '3': person = Person(user=self.bidder.user_object, public_id=self.bidder.pk, role='Volunteer') for assigned_event in request.POST.getlist('events'): set_response = set_person(assigned_event, person) show_general_status(request, set_response, self.__class__.__name__) email_status = send_schedule_update_mail('Volunteer', self.bidder) self.check_email_status(request, email_status) return super(VolunteerChangeStateView, self).bid_state_change(request)
def get(self, request, *args, **kwargs): context = self.process_inputs(request, args, kwargs) personal_schedule = [] eval_occurrences = [] if not self.conference or not self.this_day or not self.calendar_type: return render(request, self.template, context) response = get_occurrences( labels=[self.calendar_type, self.conference.conference_slug], day=self.this_day.day) show_general_status( request, response, self.__class__.__name__) if len(response.occurrences) > 0: if request.user.is_authenticated() and hasattr( request.user, 'profile'): sched_response = get_schedule( request.user, labels=[self.calendar_type, self.conference.conference_slug]) personal_schedule = sched_response.schedule_items person = Person( user=request.user, public_id=request.user.profile.pk, public_class="Profile") eval_response = get_eval_info(person=person) if len(eval_response.questions) > 0: eval_occurrences = eval_response.occurrences else: eval_occurrences = None max_block_size, context[ 'occurrences'] = self.build_occurrence_display( response.occurrences, personal_schedule, eval_occurrences) grid_size = 2 if max_block_size < 6: grid_size = self.grid_map[max_block_size] context['grid_size'] = grid_size return render(request, self.template, context)
def groundwork(self, request, args, kwargs): self.profile = validate_perms(request, self.permissions) self.area = get_object_or_404(StaffArea, id=int(kwargs['staff_id'])) if self.area.conference.conferenceday_set.count() > 0: self.start_day = self.area.conference.conferenceday_set.order_by( "day").first().day else: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NO_CONF_DAYS", defaults={ 'summary': "No Conference Days in Conference", 'description': no_conf_day_msg }) messages.error(request, user_message[0].description) return HttpResponseRedirect( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.area.conference.conference_slug])) response = get_occurrences( labels=[self.area.slug, self.area.conference.conference_slug]) self.children = response.occurrences show_general_status(request, response, self.__class__.__name__)
def eval_view(request, occurrence_id=None): details = None reviewer = validate_perms(request, ('Class Coordinator', )) if request.GET and request.GET.get('conf_slug'): conference = get_conference_by_slug(request.GET['conf_slug']) else: conference = get_current_conference() if occurrence_id: detail_response = get_eval_info(occurrence_id=int(occurrence_id)) show_general_status(request, detail_response, "EvaluationDetailView") if detail_response.occurrences and len( detail_response.occurrences) > 0: detail_response.answers.sort( key=lambda answer: (answer.profile.profile.display_name, answer.question.order)) details = { 'occurrence': detail_response.occurrences[0], 'title': detail_response.occurrences[ 0].eventitem.event.e_title, 'description': detail_response.occurrences[ 0].eventitem.event.e_description, 'questions': detail_response.questions, 'evaluations': detail_response.answers, } response = get_eval_summary( labels=[conference.conference_slug, "Conference"]) header = ['Class', 'Teacher(s)', 'Time', '# Interested', '# Evaluations'] for question in response.questions: header += [question.question] header += ['Actions'] display_list = [] summary_view_data = {} events = Class.objects.filter(e_conference=conference) for occurrence in response.occurrences: class_event = events.get( eventitem_id=occurrence.eventitem.eventitem_id) teachers = [] interested = [] for person in occurrence.people: if person.role == "Interested": interested += [person] elif person.role in ("Teacher", "Moderator"): teachers += [Performer.objects.get(pk=person.public_id)] display_item = { 'id': occurrence.id, 'eventitem_id': class_event.eventitem_id, 'sort_start': occurrence.start_time, 'start': occurrence.start_time.strftime(DATETIME_FORMAT), 'title': class_event.e_title, 'teachers': teachers, 'interested': len(interested), 'eval_count': response.count.get(occurrence.pk, 0), 'detail_link': reverse( 'evaluation_detail', urlconf='gbe.reporting.urls', args=[occurrence.id])} display_list += [display_item] summary_view_data[int(occurrence.id)] = {} for question in response.questions: for item in response.summaries[question.pk]: summary_view_data[int(item['event'])][int(question.pk)] = item[ 'summary'] display_list.sort(key=lambda k: k['sort_start']) user_message = UserMessage.objects.get_or_create( view="InterestView", code="ABOUT_EVAL_REPORT", defaults={ 'summary': "About Evaluation Report", 'description': eval_report_explain_msg}) return render(request, 'gbe/report/evals.tmpl', {'header': header, 'classes': display_list, 'questions': response.questions, 'summaries': summary_view_data, 'conference_slugs': conference_slugs(), 'conference': conference, 'about': user_message[0].description, 'details': details})
def AssignVolunteerView(request, volunteer_id): ''' Show a bid which needs to be assigned to shifts by the coordinator. To show: display useful information about the bid, If user is not a coordinator, politely decline to show anything. ''' reviewer = validate_perms(request, ('Volunteer Coordinator',)) if int(volunteer_id) == 0 and request.method == 'POST': volunteer_id = int(request.POST['volunteer']) volunteer = get_object_or_404( Volunteer, id=volunteer_id, ) if not volunteer.is_current: return HttpResponseRedirect(reverse( 'volunteer_view', urlconf='gbe.urls', args=[volunteer_id])) conference, old_bid = get_conf(volunteer) actionURL = reverse('volunteer_changestate', urlconf='gbe.urls', args=[volunteer_id]) response = get_occurrences( labels=[volunteer.b_conference.conference_slug], max_volunteer=1) show_general_status(request, response, "AssignVolunteerView") rehearsals = GenericEvent.objects.filter( type='Rehearsal Slot', e_conference=volunteer.b_conference ).values_list('eventitem_id', flat=True) sched_response = get_schedule( user=volunteer.profile.user_object, labels=[volunteer.b_conference.conference_slug, ], roles=['Volunteer', ]) show_general_status(request, sched_response, "AssignVolunteerView") booking_ids = [] for schedule_item in sched_response.schedule_items: booking_ids += [schedule_item.event.pk] conf_windows = conference.windows() volunteer_event_windows = [] volunteer_events = Event.objects.filter( e_conference=volunteer.b_conference) for event in response.occurrences: if event.foreign_event_id not in rehearsals: window = { 'occurrence': event, 'window': conf_windows.filter( day__day=event.starttime.date(), start__lte=event.starttime.time(), end__gt=event.starttime.time()).first(), 'booked': event.pk in booking_ids, 'eventitem': event.eventitem, 'staff_areas': StaffArea.objects.filter( conference=conference, slug__in=event.labels.values_list('text', flat=True)) } if hasattr(event, 'container_event'): window['parent_event'] = event.container_event.parent_event volunteer_event_windows += [window] return render( request, 'gbe/assign_volunteer.tmpl', {'volunteer': volunteer, 'interests': volunteer.interest_list, 'volunteer_event_windows': volunteer_event_windows, 'actionURL': actionURL, 'conference': conference, 'old_bid': old_bid})
def get(self, request, *args, **kwargs): error_url = self.groundwork(request, args, kwargs) if error_url: return error_url header = [ 'Order', 'Performer', 'Title', 'Duration (HH:MM:SS)', 'Starting Position', 'Prop Setup', 'Pronouns', 'Read Intro Exactly', 'Intro Text', 'Costume Colors', 'Starting Lights', 'Follow Spot', 'Wash Color', 'Background Color', 'Cue for light change', 'Lighting at End', 'Track Title', 'Track Artist', 'Mic Options' ] tech_info = [] response = get_people(foreign_event_ids=[self.item.eventitem_id], roles=["Performer"]) show_general_status(request, response, self.__class__.__name__) for performer in response.people: read_exact = "No" light_start = "Lights On" light_end = "Lights On" prop_setup_list = "" follow_spot = "OFF" wash = "No selection made" background = "No selection made" cue = "NONE" order = -1 act = get_object_or_404(Act, pk=performer.commitment.class_id) sched_response = get_schedule( labels=[act.b_conference.conference_slug], commitment=act) show_general_status(request, sched_response, self.__class__.__name__) for item in sched_response.schedule_items: if Show.objects.filter(eventitem_id=item.event.eventitem. eventitem_id).exists(): order = item.commitment.order if act.tech.prop_setup: for item in act.tech.prop_setup_list: if len(prop_setup_list) == 0: prop_setup_list = item else: prop_setup_list = "%s, %s" % (prop_setup_list, item) prop_setup_list = "%s\n%s" % (prop_setup_list, act.tech.crew_instruct) else: prop_setup_list = act.tech.crew_instruct if act.tech.read_exact: read_exact = "Yes" if act.tech.start_blackout: light_start = "Blackout" if act.tech.end_blackout: light_end = "Blackout" if act.tech.follow_spot_color: follow_spot = act.tech.follow_spot_color if act.tech.wash_color: wash = act.tech.wash_color if act.tech.background_color: background = act.tech.background_color if act.tech.special_lighting_cue: cue = act.tech.special_lighting_cue if act.tech.confirm_no_music: title = "no music" artist = "" else: title = act.tech.track_title artist = act.tech.track_artist tech_info.append([ order, str(act.performer), act.b_title, act.tech.duration, act.tech.starting_position, prop_setup_list, act.tech.pronouns, read_exact, act.tech.introduction_text, "Primary: %s\nSecondary: %s" % (act.tech.primary_color, act.tech.secondary_color), light_start, follow_spot, wash, background, cue, light_end, title, artist, act.tech.mic_choice, ]) response = HttpResponse(content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename=%s_tech.csv' % (str( self.item)) writer = csv.writer(response) writer.writerow(header) for row in tech_info: writer.writerow(row) return response
def post(self, request, *args, **kwargs): intro_message = self.groundwork(request, args, kwargs) if "day_id" in kwargs: day = get_object_or_404(ConferenceDay, pk=kwargs.get("day_id")) else: raise Http404 all_valid = True forms = [] the_form = None for conference in Conference.objects.filter( status__in=('upcoming', 'ongoing')): first_day = ConferenceDay.objects.filter( conference=conference).order_by('day').first() if first_day is not None: form = ConferenceStartChangeForm(request.POST, instance=first_day, prefix=first_day.pk) if first_day == day: form.fields['day'].required = True the_form = form all_valid = all_valid and form.is_valid() forms += [(first_day, form)] if the_form is None: messages.error(request, UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NO_CONF_DAY_FORM", defaults={ 'summary': "Conference Day Form Not Loaded", 'description': missing_day_form_note})[0].description) all_valid = False if not all_valid: return render( request, 'gbe/scheduling/manage_conference.tmpl', {'forms': forms, 'intro': intro_message, 'title': self.title, 'button': self.button, 'header': self.header}) conf_change = the_form.cleaned_data['day'] - day.day # update each conference day so form selection offers right choices for each_day in day.conference.conferenceday_set.all(): each_day.day = each_day.day + conf_change each_day.save() messages.success( request, "Moved Conference %s by %d days, change %d conference days" % ( day.conference.conference_slug, conf_change.days, day.conference.conferenceday_set.count())) # update all scheduled events event_count = 0 response = get_occurrences( labels=[day.conference.conference_slug]) for occurrence in response.occurrences: occ_response = update_occurrence( occurrence.pk, start_time=occurrence.starttime + conf_change) show_general_status(request, occ_response, self.__class__.__name__) if occ_response and occ_response.occurrence: event_count = event_count + 1 messages.success( request, "Moved %d scheduled events by %d days" % ( event_count, conf_change.days)) general_calendar_links = "" class_calendar_links = "" volunteer_calendar_links = "" for each_day in day.conference.conferenceday_set.filter( open_to_public=True).order_by('day'): general_calendar_links = "%s<li>%s - %s?day=%s" % ( general_calendar_links, each_day.day.strftime("%A"), reverse("calendar", urlconf='gbe.scheduling.urls', args=['General']), each_day.day.strftime(URL_DATE)) class_calendar_links = "%s<li>%s - %s?day=%s" % ( class_calendar_links, each_day.day.strftime("%A"), reverse("calendar", urlconf='gbe.scheduling.urls', args=['Conference']), each_day.day.strftime(URL_DATE)) volunteer_calendar_links = "%s<li>%s - %s?day=%s" % ( volunteer_calendar_links, each_day.day.strftime("%A"), reverse("calendar", urlconf='gbe.scheduling.urls', args=['Volunteer']), each_day.day.strftime(URL_DATE)) messages.warning( request, ("REMINDER: Don't forget to change the calendar links: <ul>" + "<li>Special Events</li><ul>%s</ul><li>Conference Events</li>" + "<ul>%s</ul><li>Volunteer Events</li><ul>%s</ul></ul>") % ( general_calendar_links, class_calendar_links, volunteer_calendar_links)) return HttpResponseRedirect( ("%s?%s-calendar_type=0&%s-calendar_type=1&%s-calendar_type=2" + "&filter=Filter") % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls'), day.conference.conference_slug, day.conference.conference_slug, day.conference.conference_slug))
def book_rehearsals(self, request): error = False bookings = [] forms = self.set_rehearsal_forms(request) # using the form guarantees that we've checked that the user is # only booking rehearsals that are open, for shows they are in. for rehearsal_form in forms: if not rehearsal_form.is_valid(): error = True if error: return error, bookings, forms, request for rehearsal_form in forms: if int(rehearsal_form.cleaned_data['rehearsal']) >= 0: person = Person( public_id=self.act.performer.pk, role="performer", commitment=Commitment(decorator_class=self.act)) if rehearsal_form.cleaned_data['booking_id']: person.booking_id = int( rehearsal_form.cleaned_data['booking_id']) response = set_person(occurrence_id=int( rehearsal_form.cleaned_data['rehearsal']), person=person) # errors are internal, and not OK to show regular user if response.errors: error = True else: show_general_status(request, response, self.__class__.__name__) self.act.tech.confirm_no_rehearsal = False if response.occurrence: bookings += [response.occurrence] self.rehearsals[int(rehearsal_form.prefix)] = ScheduleItem( event=response.occurrence, booking_id=response.booking_id) else: if rehearsal_form.cleaned_data['booking_id']: response = remove_booking( occurrence_id=self.rehearsals[int( rehearsal_form.prefix)].event.pk, booking_id=int( rehearsal_form.cleaned_data['booking_id'])) # errors are internal, and not OK to show regular user if response.errors: error = True else: del self.rehearsals[int(rehearsal_form.prefix)] success = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="REHEARSAL_REMOVED", defaults={ 'summary': "User Canceled Rehearsal", 'description': rehearsal_remove_confirmation }) messages.success(request, success[0].description) self.act.tech.confirm_no_rehearsal = True self.act.tech.save() # if there has been no failure, we've changed the state of rehearsal # bookings, and the forms should be changed to reflect the new # persistent state - BUG found on 7/9/21 with GBE-238 if not error: forms = self.set_rehearsal_forms() return error, bookings, forms, request
def bid_state_change(self, request): show = None rehearsals = [] # Determine if the current show should be changed if self.object.accepted in self.show_booked_states: response = get_schedule(commitment=self.object, roles=["Performer", "Waitlisted"]) show_general_status(request, response, self.__class__.__name__) show, rehearsals = self.parse_act_schedule(response.schedule_items) # if the act has been accepted, set the show. if self.act_accepted(request): # Cast the act into the show by adding it to the schedule # resource time if ('casting' not in request.POST) or ( request.POST['casting'] != '' and ActCastingOption.objects.filter( casting=request.POST['casting']).count() == 0): user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="INVALID_CASTING", defaults={ 'summary': "Casting Role Incorrect", 'description': no_casting_msg }) messages.error(request, user_message[0].description) return HttpResponseRedirect( reverse("act_review", urlconf='gbe.urls', args=[self.object.pk])) casting = request.POST['casting'] role = "Performer" if request.POST['accepted'] == '2': casting = "Waitlisted" role = "Waitlisted" same_show = False same_role = False if show and show.event.eventitem == self.new_show.eventitem: same_show = True if casting == show.commitment.role: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_NO_CHANGE", defaults={ 'summary': "Act State Not Changed", 'description': act_status_no_change_msg }) messages.success( request, "%s<br>Performer/Act: %s - %s" % (user_message[0].description, self.object.performer.name, self.object.b_title)) return super(ActChangeStateView, self).bid_state_change(request) person = Person(public_id=self.object.performer.pk, role=role, commitment=Commitment(role=casting, decorator_class=self.object)) profiles = self.object.get_performer_profiles() if len(profiles) > 1: person.users = [profile.user_object for profile in profiles] else: person.user = profiles[0].user_object if same_show and not same_role: person.booking_id = show.booking_id set_response = set_person(person=person) self.show_set_act_status(request, set_response) if request.POST['accepted'] != '3': self.clear_bookings(request, rehearsals) elif not same_show: self.clear_bookings(request, rehearsals, show) set_response = set_person(occurrence_id=self.new_show.pk, person=person) self.show_set_act_status(request, set_response) user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_ACCEPTED", defaults={ 'summary': "Act State Changed (Accept/Waitlist)", 'description': act_status_change_msg }) messages.success( request, "%s<br>Performer/Act: %s - %s<br>State: %s<br>Show: %s" % (user_message[0].description, self.object.performer.name, self.object.b_title, acceptance_states[int( request.POST['accepted'])][1], self.new_show.eventitem.child().e_title)) else: self.clear_bookings(request, rehearsals, show) user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_NOT_ACCEPTED", defaults={ 'summary': "Act State Changed (Not Accepted)", 'description': act_status_change_msg }) messages.success( request, "%s<br>Performer/Act: %s - %s<br>State: %s" % (user_message[0].description, self.object.performer.name, self.object.b_title, acceptance_states[int( request.POST['accepted'])][1])) return super(ActChangeStateView, self).bid_state_change(request)
def get(self, request, *args, **kwargs): if request.GET.get('next', None): redirect_to = request.GET['next'] else: redirect_to = reverse('home', urlconf='gbe.urls') this_url = reverse('set_volunteer', args=[kwargs['occurrence_id'], kwargs['state']], urlconf='gbe.scheduling.urls') response = check_user_and_redirect(request, this_url, self.__class__.__name__) if response['error_url']: return HttpResponseRedirect(response['error_url']) self.owner = response['owner'] occurrence_id = int(kwargs['occurrence_id']) occ_response = get_occurrence(occurrence_id) show_general_status(request, occ_response, self.__class__.__name__) if occ_response.errors: return HttpResponseRedirect(redirect_to) volunteers = get_bookings([occurrence_id], roles=["Volunteer", "Pending Volunteer"]) bookings = [] for person in volunteers.people: if person.user == self.owner.user_object: bookings += [person] schedule_response = None if kwargs['state'] == 'on' and len(bookings) == 0: # if this person hasn't volunteered yet, and wants to role = "Volunteer" default_summary = "User has volunteered" default_message = set_volunteer_msg if occ_response.occurrence.approval_needed: role = "Pending Volunteer" default_summary = "User is pending" default_message = set_pending_msg person = Person(user=self.owner.user_object, role=role) schedule_response = set_person(occurrence_id, person) show_general_status(request, schedule_response, self.__class__.__name__, False) if len(schedule_response.errors) == 0 and ( schedule_response.booking_id): user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="SET_%s" % role.replace(" ", "_").upper(), defaults={ 'summary': default_summary, 'description': default_message }) messages.success(request, user_message[0].description) elif kwargs['state'] == 'off' and len(bookings) > 0: # if this person has volunteered, and is withdrawing success = True for booking in bookings: role = booking.role default_summary = "User withdrew" default_message = unset_volunteer_msg if role == "Pending Volunteer": default_summary = "Pending user withdrew" default_message = unset_pending_msg schedule_response = remove_booking(occurrence_id, booking.booking_id) show_general_status(request, schedule_response, self.__class__.__name__) if schedule_response.booking_id: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="REMOVE_%s" % role.replace(" ", "_").upper(), defaults={ 'summary': default_summary, 'description': default_message }) messages.success(request, user_message[0].description) if schedule_response and schedule_response.booking_id: email_status = send_schedule_update_mail("Volunteer", self.owner) staff_status = send_volunteer_update_to_staff( self.owner, self.owner, occ_response.occurrence, kwargs['state'], schedule_response) if (email_status or staff_status) and validate_perms( request, 'any', require=False): user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="EMAIL_FAILURE", defaults={ 'summary': "Email Failed", 'description': volunteer_allocate_email_fail_msg }) messages.error(request, user_message[0].description + "status code: ") return HttpResponseRedirect(redirect_to)
def get_context_data(self, request): acts = [] all_valid = True scheduling_link = '' columns = [ 'Order', 'Tech Done', 'Act', 'Performer', 'Rehearsal', 'Music', 'Action' ] conference = self.item.e_conference # Setup act pane response = get_people(foreign_event_ids=[self.item.eventitem_id], roles=["Performer"]) show_general_status(request, response, self.__class__.__name__) for performer in response.people: rehearsals = [] order = -1 act = get_object_or_404(Act, pk=performer.commitment.class_id) sched_response = get_schedule( labels=[act.b_conference.conference_slug], commitment=act) show_general_status(request, sched_response, self.__class__.__name__) for item in sched_response.schedule_items: if item.event not in rehearsals and ( GenericEvent.objects.filter( eventitem_id=item.event.eventitem.eventitem_id, type='Rehearsal Slot').exists()): rehearsals += [item.event] elif Show.objects.filter(eventitem_id=item.event.eventitem. eventitem_id).exists(): order = item.commitment.order if request.POST: form = ActScheduleBasics(request.POST, prefix=performer.booking_id) all_valid = all_valid and form.is_valid() else: form = ActScheduleBasics( prefix=performer.booking_id, initial={'order': performer.commitment.order}) rebook_form = Form() rebook_form.fields['accepted'] = ChoiceField(choices=((3, 3), ), initial=3, widget=HiddenInput()) rebook_form = make_show_casting_form(conference, rebook_form, self.item.eventitem_id, performer.commitment.role) acts += [{ 'act': act, 'rehearsals': rehearsals, 'order': order, 'rebook_form': rebook_form, 'form': form }] # Setup Volunteer pane opps = [] roles = [] for role, commit in list(role_commit_map.items()): if commit[0] > 0 and commit[0] < 4: roles += [role] opps_response = get_occurrences( labels=[conference.conference_slug, "Volunteer"], parent_event_id=self.occurrence.pk) if opps_response: show_general_status(request, opps_response, self.__class__.__name__) for opp in opps_response.occurrences: item = { 'event': opp, 'areas': [], } for area in StaffArea.objects.filter(slug__in=opp.labels, conference=conference): item['areas'] += [area] opps += [item] vol_msg = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="VOLUNTEER_PANEL_INSTRUCTIONS", defaults={ 'summary': "Instructions at top of Volunteer Panel", 'description': volunteer_panel_instr }) return { 'this_show': self.item, 'email_forms': self.setup_email_forms(), 'this_occurrence': self.occurrence, 'acts': acts, 'all_valid': all_valid, 'columns': columns, 'other_shows': self.show_scope, 'conference_slugs': conference_slugs(), 'conference': conference, 'can_schedule': self.can_schedule_acts, 'can_rebook': self.can_rebook, 'can_approve_vol': self.can_approve_vol, 'can_assign_act': self.can_assign_act, 'change_acts': self.can_change_techinfo, 'opps': opps, 'role_commit_map': role_commit_map, 'visible_roles': roles, 'act_panel_instructions': UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ACT_PANEL_INSTRUCTIONS", defaults={ 'summary': "Instructions at top of Act Panel", 'description': act_panel_instr })[0].description, 'volunteer_panel_instructions': vol_msg[0].description, 'vol_columns': [ 'Event', 'Area', 'Date/Time', 'Location', 'Max', 'Current', 'Volunteers' ] }
def eval_view(request, occurrence_id=None): details = None reviewer = validate_perms(request, ('Class Coordinator', )) conference = None if request.GET and request.GET.get('conf_slug'): conference = get_conference_by_slug(request.GET['conf_slug']) if occurrence_id and not conference: detail_response = get_eval_info(occurrence_id=int(occurrence_id)) show_general_status(request, detail_response, "EvaluationDetailView") if detail_response.occurrences and len( detail_response.occurrences) > 0: detail_response.answers.sort(key=lambda answer: ( answer.profile.profile.display_name, answer.question.order)) details = { 'occurrence': detail_response.occurrences[0], 'title': detail_response.occurrences[0].eventitem.event.e_title, 'description': detail_response.occurrences[0].eventitem.event.e_description, 'questions': detail_response.questions, 'evaluations': detail_response.answers, } if not conference: conference = detail_response.occurrences[ 0].eventitem.event.e_conference if not conference: conference = get_current_conference() response = get_eval_summary( labels=[conference.conference_slug, "Conference"]) display_list = [] summary_view_data = {} events = Class.objects.filter(e_conference=conference) for occurrence in response.occurrences: class_event = events.get( eventitem_id=occurrence.eventitem.eventitem_id) teachers = [] interested = [] for person in occurrence.people: if person.role == "Interested": interested += [person] elif person.role in ("Teacher", "Moderator"): teachers += [Performer.objects.get(pk=person.public_id)] display_item = { 'id': occurrence.id, 'eventitem_id': class_event.eventitem_id, 'start': occurrence.start_time.strftime(GBE_TABLE_FORMAT), 'title': class_event.e_title, 'teachers': teachers, 'interested': len(interested), 'eval_count': response.count.get(occurrence.pk, 0), 'detail_link': reverse('evaluation_detail', urlconf='gbe.reporting.urls', args=[occurrence.id]) } display_list += [display_item] summary_view_data[int(occurrence.id)] = {} for question in response.questions: for item in response.summaries[question.pk]: summary_view_data[int(item['event'])][int( question.pk)] = item['summary'] user_message = UserMessage.objects.get_or_create( view="InterestView", code="ABOUT_EVAL_REPORT", defaults={ 'summary': "About Evaluation Report", 'description': eval_report_explain_msg }) return render( request, 'gbe/report/evals.tmpl', { 'columns': ['Class', 'Teacher(s)', 'Time', '# Interested', '# Evaluations'], 'vertical_columns': response.questions.values_list('question', flat=True), 'last_columns': ['Actions'], 'classes': display_list, 'questions': response.questions, 'summaries': summary_view_data, 'conference_slugs': conference_slugs(), 'conference': conference, 'about': user_message[0].description, 'details': details })