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 build_occurrence_display(self, occurrences, personal_schedule=None, eval_occurrences=None): display_list = [] events = Event.objects.filter(e_conference=self.conference) hour_block_size = {} for occurrence in occurrences: role = None for booking in personal_schedule: if booking.event == occurrence: role = booking.role event = events.filter(pk=occurrence.eventitem.event.pk).first() hour = occurrence.start_time.strftime("%-I:00 %p") occurrence_detail = { 'start': occurrence.start_time.strftime(GBE_TIME_FORMAT), 'end': occurrence.end_time.strftime(GBE_TIME_FORMAT), 'title': event.e_title, 'location': occurrence.location, 'hour': hour, 'approval_needed': occurrence.approval_needed, 'detail_link': reverse('detail_view', urlconf='gbe.scheduling.urls', args=[occurrence.eventitem.pk]), 'teachers': [], } if self.can_edit_show and occurrence.event_type_name == "Show": occurrence_detail['show_dashboard'] = reverse( 'show_dashboard', urlconf='gbe.scheduling.urls', args=[occurrence.pk]) for person in get_bookings([occurrence.pk], roles=["Teacher", "Moderator"]).people: presenter = Performer.objects.get(pk=person.public_id) occurrence_detail['teachers'] += [(person.role, presenter)] (occurrence_detail['favorite_link'], occurrence_detail['volunteer_link'], occurrence_detail['evaluate'], occurrence_detail['highlight'], occurrence_detail['vol_disable_msg']) = build_icon_links( occurrence, eval_occurrences, self.calendar_type, (self.conference.status == "completed"), personal_schedule) display_list += [occurrence_detail] if hour in hour_block_size: hour_block_size[hour] += 1 else: hour_block_size[hour] = 1 return max(hour_block_size.values()), display_list
def get_event_display_info(eventitem_id): ''' Helper for displaying a single of event. ''' try: item = Event.objects.get_subclass(eventitem_id=eventitem_id) response = get_occurrences(foreign_event_ids=[eventitem_id]) except Event.DoesNotExist: raise Http404 bio_grid_list = [] featured_grid_list = [] occurrence_ids = [] for sched_event in response.occurrences: occurrence_ids += [sched_event.pk] for casting in sched_event.casting_list: if len(casting.role): featured_grid_list += [{ 'bio': casting._item.bio, 'role': casting.role, }] else: bio_grid_list += [casting._item.bio] booking_response = get_bookings( occurrence_ids, roles=['Teacher', 'Panelist', 'Moderator', 'Staff Lead']) people = [] if len(booking_response.people) == 0 and (item.__class__.__name__ == "Class"): people = [{ 'role': "Presenter", 'person': item.teacher, }] else: id_set = [] for person in booking_response.people: if person.public_id not in id_set: id_set += [person.public_id] people += [{ 'role': person.role, 'person': eval(person.public_class).objects.get(pk=person.public_id), }] eventitem_view = { 'event': item, 'scheduled_events': response.occurrences, 'bio_grid_list': bio_grid_list, 'featured_grid_list': featured_grid_list, 'people': people, } return eventitem_view
def get_event_display_info(eventitem_id): ''' Helper for displaying a single of event. ''' try: item = Event.objects.get_subclass(eventitem_id=eventitem_id) response = get_occurrences(foreign_event_ids=[eventitem_id]) except Event.DoesNotExist: raise Http404 bio_grid_list = [] featured_grid_list = [] occurrence_ids = [] for sched_event in response.occurrences: occurrence_ids += [sched_event.pk] for casting in sched_event.casting_list: if len(casting.role): featured_grid_list += [{ 'bio': casting._item.bio, 'role': casting.role, }] else: bio_grid_list += [casting._item.bio] booking_response = get_bookings( occurrence_ids, roles=['Teacher', 'Panelist', 'Moderator', 'Staff Lead']) people = [] if len(booking_response.people) == 0 and ( item.__class__.__name__ == "Class"): people = [{ 'role': "Presenter", 'person': item.teacher, }] else: id_set = [] for person in booking_response.people: if person.public_id not in id_set: id_set += [person.public_id] people += [{ 'role': person.role, 'person': eval(person.public_class).objects.get( pk=person.public_id), }] eventitem_view = {'event': item, 'scheduled_events': response.occurrences, 'bio_grid_list': bio_grid_list, 'featured_grid_list': featured_grid_list, 'people': people, } return eventitem_view
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 LandingPageView(request, profile_id=None, historical=False): historical = "historical" in request.GET.keys() standard_context = {} standard_context['events_list'] = Event.objects.all()[:5] if (profile_id): admin_profile = validate_perms(request, ('Registrar', 'Volunteer Coordinator', 'Act Coordinator', 'Class Coordinator', 'Vendor Coordinator', 'Ticketing - Admin')) viewer_profile = get_object_or_404(Profile, pk=profile_id) admin_message = "You are viewing a user's profile, not your own." else: viewer_profile = validate_profile(request, require=False) admin_message = None template = loader.get_template('gbe/landing_page.tmpl') class_to_class_name = {Act: "Act", Class: "Class", Costume: "Costume", Vendor: "Vendor", Volunteer: "Volunteer"} class_to_view_name = {Act: 'act_review', Class: 'class_review', Costume: 'costume_review', Vendor: 'vendor_review', Volunteer: 'volunteer_review'} if viewer_profile: bids_to_review = [] person = Person( user=viewer_profile.user_object, public_id=viewer_profile.pk, public_class="Profile") for bid in viewer_profile.bids_to_review(): bid_type = class_to_class_name.get(bid.__class__, "UNKNOWN") view_name = class_to_view_name.get(bid.__class__, None) url = "" if view_name: url = reverse(view_name, urlconf='gbe.urls', args=[str(bid.id)]) bids_to_review += [{'bid': bid, 'url': url, 'action': "Review", 'bid_type': bid_type}] bookings = [] for booking in get_schedule( viewer_profile.user_object).schedule_items: gbe_event = booking.event.eventitem.child() booking_item = { 'id': booking.event.pk, 'role': booking.role, 'conference': gbe_event.e_conference, 'starttime': booking.event.starttime, 'interested': get_bookings( [booking.event.pk], roles=["Interested"]).people, 'eventitem_id': gbe_event.eventitem_id, 'title': gbe_event.e_title, } if gbe_event.calendar_type == "Conference" and ( booking.role not in ("Teacher", "Performer", "Moderator")): eval_check = get_eval_info(booking.event.pk, person) if len(eval_check.questions) > 0: if len(eval_check.answers) > 0: booking_item['evaluate'] = "disabled" else: booking_item['evaluate'] = reverse( 'eval_event', args=[booking.event.pk, ], urlconf='gbe.scheduling.urls') bookings += [booking_item] context = RequestContext( request, {'profile': viewer_profile, 'historical': historical, 'alerts': viewer_profile.alerts(historical), 'standard_context': standard_context, 'personae': viewer_profile.get_personae(), 'troupes': viewer_profile.get_troupes(), 'combos': viewer_profile.get_combos(), 'acts': viewer_profile.get_acts(historical), 'shows': viewer_profile.get_shows(), 'classes': viewer_profile.is_teaching(historical), 'proposed_classes': viewer_profile.proposed_classes(historical), 'vendors': viewer_profile.vendors(historical), 'volunteering': viewer_profile.get_volunteerbids(), 'costumes': viewer_profile.get_costumebids(historical), 'review_items': bids_to_review, 'tickets': get_purchased_tickets(viewer_profile.user_object), 'acceptance_states': acceptance_states, 'admin_message': admin_message, 'bookings': bookings, }) if not historical: user_message = UserMessage.objects.get_or_create( view="LandingPageView", code="ABOUT_INTERESTED", defaults={ 'summary': "About Interested Attendees", 'description': interested_explain_msg}) context['interested_info'] = user_message[0].description else: context = RequestContext(request, {'standard_context': standard_context}) return HttpResponse(template.render(context))
def get(self, request, *args, **kwargs): context = self.setup(request, args, kwargs) items = self.get_events_list_by_type() events = [] eval_occurrences = [] if request.user.is_authenticated() and hasattr(request.user, 'profile'): 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 for item in items: scheduled_events = [] presenters = [] response = get_occurrences( foreign_event_ids=[item.eventitem_id]) for occurrence in response.occurrences: evaluate = None people_response = get_bookings([occurrence.pk]) highlight = None role = None favorite_link = reverse( 'set_favorite', args=[occurrence.pk, 'on'], urlconf='gbe.scheduling.urls') for person in people_response.people: if request.user == person.user: role = person.role highlight = person.role.lower() if person.role == "Interested": favorite_link = reverse( 'set_favorite', args=[occurrence.pk, 'off'], urlconf='gbe.scheduling.urls') else: favorite_link = "disabled" if person.role in ( "Teacher", "Moderator", "Panelist") and person.public_class != "Profile": presenter = Performer.objects.get(pk=person.public_id) if presenter not in presenters: presenters += [presenter] if self.conference.status == "completed" or ( item.calendar_type == 'Volunteer'): favorite_link = None if (self.event_type == 'Class') and ( occurrence.start_time < (datetime.now( tz=pytz.timezone('America/New_York') ) - timedelta(hours=settings.EVALUATION_WINDOW)) ) and ( role not in ("Teacher", "Performer", "Moderator") ) and ( eval_occurrences is not None): if occurrence in eval_occurrences: evaluate = "disabled" else: evaluate = reverse( 'eval_event', args=[occurrence.pk, ], urlconf='gbe.scheduling.urls') scheduled_events += [{ 'occurrence': occurrence, 'favorite_link': favorite_link, 'highlight': highlight, 'evaluate': evaluate, }] if len(presenters) == 0 and item.calendar_type == "Conference": presenters += [item.teacher] events += [{ 'eventitem': item, 'scheduled_events': scheduled_events, 'presenters': presenters, 'detail': reverse('detail_view', urlconf='gbe.scheduling.urls', args=[item.eventitem_id])}] context['events'] = events return render(request, self.template, context)
def get(self, request, *args, **kwargs): context = self.setup(request, args, kwargs) items = self.get_events_list_by_type() events = [] eval_occurrences = [] if request.user.is_authenticated() and hasattr(request.user, 'profile'): 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 for item in items: scheduled_events = [] presenters = [] response = get_occurrences(foreign_event_ids=[item.eventitem_id]) for occurrence in response.occurrences: evaluate = None people_response = get_bookings([occurrence.pk]) highlight = None role = None favorite_link = reverse('set_favorite', args=[occurrence.pk, 'on'], urlconf='gbe.scheduling.urls') for person in people_response.people: if request.user == person.user: role = person.role highlight = person.role.lower() if person.role == "Interested": favorite_link = reverse( 'set_favorite', args=[occurrence.pk, 'off'], urlconf='gbe.scheduling.urls') else: favorite_link = "disabled" if person.role in ("Teacher", "Moderator", "Panelist" ) and person.public_class != "Profile": presenter = Performer.objects.get(pk=person.public_id) if presenter not in presenters: presenters += [presenter] if self.conference.status == "completed" or (item.calendar_type == 'Volunteer'): favorite_link = None if (self.event_type == 'Class') and ( occurrence.start_time < (datetime.now(tz=pytz.timezone('America/New_York')) - timedelta(hours=settings.EVALUATION_WINDOW))) and ( role not in ("Teacher", "Performer", "Moderator")) and (eval_occurrences is not None): if occurrence in eval_occurrences: evaluate = "disabled" else: evaluate = reverse('eval_event', args=[ occurrence.pk, ], urlconf='gbe.scheduling.urls') scheduled_events += [{ 'occurrence': occurrence, 'favorite_link': favorite_link, 'highlight': highlight, 'evaluate': evaluate, }] if len(presenters) == 0 and item.calendar_type == "Conference": presenters += [item.teacher] events += [{ 'eventitem': item, 'scheduled_events': scheduled_events, 'presenters': presenters, 'detail': reverse('detail_view', urlconf='gbe.scheduling.urls', args=[item.eventitem_id]) }] context['events'] = events return render(request, self.template, context)
def setup_eval(self, request, occurrence_id): eval_info = get_eval_info(occurrence_id, person=self.person) redirect_now = False item = None if len(eval_info.errors) > 0: for error in eval_info.errors: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code=error.code, defaults={ 'summary': "Get Eval Error", 'description': "An error has occurred. " }) messages.error(request, user_message[0].description + error.details) redirect_now = True elif len(eval_info.warnings) > 0: for warning in eval_info.warnings: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code=warning.code, defaults={ 'summary': "Get Eval Warning", 'description': warning.details }) messages.warning(request, user_message[0].description) redirect_now = True elif len(eval_info.questions) == 0: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NOT_READY", defaults={ 'summary': "No Questions", 'description': not_ready_for_eval }) messages.warning(request, user_message[0].description) redirect_now = True elif len(eval_info.answers) > 0: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="ONLY_ONE_EVAL", defaults={ 'summary': "One Eval per Attendee", 'description': one_eval_msg }) messages.warning(request, user_message[0].description) redirect_now = True else: item = Event.objects.get( eventitem_id=eval_info.occurrences[0].foreign_event_id) if verify_bought_conference(self.person.user, item.e_conference) is False: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="NO_VALID_PURCHASE", defaults={ 'summary': "Conference not purchased by user", 'description': not_purchased_msg }) messages.error(request, user_message[0].description) redirect_now = True response = get_bookings( occurrence_ids=[eval_info.occurrences[0].pk], roles=['Teacher', 'Moderator', 'Panelist']) user_performers = self.person.user.profile.get_performers() pk_list = [] for user_perf in user_performers: pk_list += [user_perf.pk] self.presenters = [] for person in response.people: if person.public_id in pk_list: user_message = UserMessage.objects.get_or_create( view=self.__class__.__name__, code="USER_IS_PRESENTER", defaults={ 'summary': "Can't eval your own class", 'description': eval_as_presenter_error }) messages.error(request, user_message[0].description) redirect_now = True break presenter = eval( person.public_class).objects.get(pk=person.public_id) self.presenters += [{ 'presenter': presenter, 'role': person.role }] if request.GET.get('next', None): redirect_to = request.GET['next'] else: redirect_to = reverse('home', urlconf='gbe.urls') return (redirect_to, eval_info, item, redirect_now)
def get(self, request, *args, **kwargs): context = self.groundwork(request, args, kwargs) items = self.get_events_list_by_type() events = [] eval_occurrences = [] all_roles = [] personal_schedule_items = [] if request.user.is_authenticated and hasattr(request.user, 'profile'): person = Person(user=request.user, public_id=request.user.profile.pk, public_class="Profile") for n, m in role_options: all_roles += [m] personal_schedule_items = get_schedule( request.user, labels=[self.conference.conference_slug], roles=all_roles, ).schedule_items eval_response = get_eval_info(person=person) if len(eval_response.questions) > 0: eval_occurrences = eval_response.occurrences else: eval_occurrences = None for item in items: scheduled_events = [] presenters = [] response = get_occurrences(foreign_event_ids=[item.eventitem_id]) for occurrence in response.occurrences: (favorite_link, volunteer_link, evaluate, highlight, vol_disable_msg) = build_icon_links( occurrence, eval_occurrences, item.calendar_type, (self.conference.status == "completed"), personal_schedule_items) scheduled_events += [{ 'occurrence': occurrence, 'favorite_link': favorite_link, 'volunteer_link': volunteer_link, 'highlight': highlight, 'evaluate': evaluate, 'vol_disable_msg': vol_disable_msg, 'approval_needed': occurrence.approval_needed, }] people_response = get_bookings( [occurrence.pk], roles=["Teacher", "Moderator", "Panelist"]) for person in people_response.people: if person.public_class != "Profile": presenter = Performer.objects.get(pk=person.public_id) if presenter not in presenters: presenters += [presenter] if len(presenters) == 0 and item.calendar_type == "Conference": presenters += [item.teacher] events += [{ 'eventitem': item, 'scheduled_events': scheduled_events, 'presenters': presenters, 'detail': reverse('detail_view', urlconf='gbe.scheduling.urls', args=[item.eventitem_id]) }] context['events'] = events return render(request, self.template, context)
def get_rehearsal_forms(self, initial, manage_slot_info, conference, request, errorcontext, occurrence_id): ''' Generate the forms to allocate, edit, or delete volunteer opportunities associated with a scheduler event. ''' actionform = [] context = {} response = get_occurrences(parent_event_id=occurrence_id) for rehearsal_slot in response.occurrences: rehearsal = None try: rehearsal = GenericEvent.objects.get( eventitem_id=rehearsal_slot.foreign_event_id, type="Rehearsal Slot") except: pass if rehearsal is not None: if (errorcontext and 'error_slot_form' in errorcontext and errorcontext['error_slot_occurrence_id' ] == int(rehearsal_slot.pk)): actionform.append(errorcontext['error_slot_form']) else: max_commitments = rehearsal_slot.max_commitments date = rehearsal_slot.start_time.date() time = rehearsal_slot.start_time.time day = get_conference_day( conference=rehearsal.e_conference, date=date) location = rehearsal_slot.location if location: room = location.room elif self.occurrence.location: room = self.occurrence.location.room response = get_bookings( [rehearsal_slot.pk], roles=["Performer"]) actionform.append( RehearsalSlotForm( instance=rehearsal, initial={'opp_event_id': rehearsal.event_id, 'opp_sched_id': rehearsal_slot.pk, 'current_acts': len(response.people), 'max_volunteer': max_commitments, 'day': day, 'time': time, 'location': room, }, ) ) context['slotactionform'] = actionform if errorcontext and 'createslotform' in errorcontext: createform = errorcontext['createslotform'] else: createform = RehearsalSlotForm( prefix='new_slot', initial=initial, conference=conference) actionheaders = ['Title', 'Booked/', 'Available', 'Duration', 'Day', 'Time', 'Location'] context.update({'createslotform': createform, 'slotactionheaders': actionheaders, 'manage_slot_url': manage_slot_info}), return context
def do_additional_actions(self, request): response = None context = None if ('create_slot' in list(request.POST.keys())) or ( 'duplicate_slot' in list(request.POST.keys())): self.create = True if 'create_slot' in list(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, max_commitments=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 list(request.POST.keys()): self.event = get_object_or_404( GenericEvent, event_id=request.POST['opp_event_id']) casting_response = get_bookings( [int(request.POST['opp_sched_id'])], roles=["Performer"]) self.event_form = RehearsalSlotForm( request.POST, instance=self.event, initial={'current_acts': len(casting_response.people)}) 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, max_commitments=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 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_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 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(self, request, *args, **kwargs): self.groundwork(request, args, kwargs) viewer_profile = self.viewer_profile context = {} bids_to_review = [] person = Person(user=viewer_profile.user_object, public_id=viewer_profile.pk, public_class="Profile") for bid in viewer_profile.bids_to_review(): bids_to_review += [{ 'bid': bid, 'url': reverse('%s_review' % bid.__class__.__name__.lower(), urlconf='gbe.urls', args=[str(bid.id)]), 'action': "Review", 'bid_type': bid.__class__.__name__ }] personae, troupes = viewer_profile.get_performers(organize=True) bookings = [] booking_ids = [] manage_shows = [] shows = [] classes = [] acts = Act.objects.filter( Q(performer__in=personae) | Q(performer__in=troupes)) for booking in get_schedule(viewer_profile.user_object).schedule_items: gbe_event = booking.event.eventitem.child() booking_item = { 'id': booking.event.pk, 'role': booking.role, 'conference': gbe_event.e_conference, 'starttime': booking.event.starttime, 'interested': get_bookings([booking.event.pk], roles=["Interested"]).people, 'eventitem_id': gbe_event.eventitem_id, 'title': gbe_event.e_title, } if gbe_event.calendar_type == "Conference" and ( booking.role not in ("Teacher", "Performer", "Moderator")): eval_check = get_eval_info(booking.event.pk, person) if len(eval_check.questions) > 0: if len(eval_check.answers) > 0: booking_item['evaluate'] = "disabled" else: booking_item['evaluate'] = reverse( 'eval_event', args=[ booking.event.pk, ], urlconf='gbe.scheduling.urls') elif gbe_event.calendar_type == "Conference": classes += [booking_item] if gbe_event.e_conference.status != "completed": if gbe_event.calendar_type == "General" and (booking.commitment is not None): shows += [(gbe_event, acts.get(id=booking.commitment.class_id))] # roles assigned direct to shows if booking.role in ('Stage Manager', 'Technical Director', 'Producer'): manage_shows += [booking.event] # staff leads often work a volunteer slot in the show elif self.is_staff_lead and hasattr(booking.event, 'container_event'): parent = booking.event.container_event.parent_event if parent not in manage_shows and Show.objects.filter( eventitem_id=parent.eventitem.eventitem_id).exists( ) and parent not in manage_shows: manage_shows += [parent] if booking.event.pk not in booking_ids: bookings += [booking_item] booking_ids += [booking.event.pk] current_conf = get_current_conference() # filter for conf AFTER bookings if self.historical: acts = acts.filter(b_conference__status="completed") else: acts = acts.exclude(b_conference__status="completed") context = { 'profile': viewer_profile, 'historical': self.historical, 'alerts': viewer_profile.alerts(shows, classes), 'personae': personae, 'troupes': troupes, 'manage_shows': manage_shows, 'businesses': viewer_profile.business_set.all(), 'acts': acts, 'shows': shows, 'proposed_classes': viewer_profile.proposed_classes(self.historical), 'vendors': viewer_profile.vendors(self.historical), 'costumes': viewer_profile.get_costumebids(self.historical), 'review_items': bids_to_review, 'tickets': get_purchased_tickets(viewer_profile.user_object), 'acceptance_states': acceptance_states, 'admin_message': self.admin_message, 'bookings': bookings, 'act_paid': verify_performer_app_paid(viewer_profile.user_object.username, current_conf), 'vendor_paid': verify_vendor_app_paid(viewer_profile.user_object.username, current_conf), 'logged_in_message': UserMessage.objects.get_or_create(view="LandingPageView", code="GENERAL_MESSAGE", defaults={ 'summary': "Left hand sidebar message", 'description': '' })[0].description } if not self.historical: user_message = UserMessage.objects.get_or_create( view="LandingPageView", code="ABOUT_INTERESTED", defaults={ 'summary': "About Interested Attendees", 'description': interested_explain_msg }) right_side_msg = UserMessage.objects.get_or_create( view="LandingPageView", code="CURRENT_BID_INSTRUCTION", defaults={ 'summary': "Right Hand Sidebar - Current Bid Message", 'description': current_bid_msg }) context['interested_info'] = user_message[0].description else: right_side_msg = UserMessage.objects.get_or_create( view="LandingPageView", code="HISTORICAL_BID_INSTRUCTION", defaults={ 'summary': "Right Hand Sidebar - Historical Bid Message", 'description': historic_bid_msg }) context['right_side_intro'] = right_side_msg[0].description return render(request, 'gbe/landing_page.tmpl', context)