def get_people(parent_event_ids=[],
               foreign_event_ids=[],
               labels=[],
               label_sets=[],
               roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(errors=[
            Error(code="INVALID_REQUEST",
                  details="labels and label_sets are not compatible"),
        ])
    people = []
    bookings = ResourceAllocation.objects.all()
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(
            Q(event__container_event__parent_event__eventitem__eventitem_id__in
              =(parent_event_ids))
            | Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if len(foreign_event_ids) > 0:
        bookings = bookings.filter(
            event__eventitem__eventitem_id__in=foreign_event_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(booking=booking)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]

    return PeopleResponse(people=people)
 def people(self):
     people = []
     for booking in self.resources_allocated.all():
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(booking=booking)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Ejemplo n.º 3
0
 def people(self):
     people = []
     for booking in ResourceAllocation.objects.filter(event=self):
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(booking_id=booking.pk,
                             worker=booking.resource.worker)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Ejemplo n.º 4
0
 def people(self):
     people = []
     for booking in ResourceAllocation.objects.filter(event=self):
         if booking.resource.as_subtype.__class__.__name__ == "Worker":
             person = Person(
                 booking_id=booking.pk,
                 worker=booking.resource.worker)
             if hasattr(booking, 'label'):
                 person.label = booking.label.text
             people += [person]
     return people
Ejemplo n.º 5
0
def get_all_container_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(
        Q(event__pk__in=occurrence_ids) |
        Q(event__contained_events__child_event__pk__in=occurrence_ids)
        ).distinct()
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(booking=booking)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
def get_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(event__pk__in=occurrence_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Ejemplo n.º 9
0
def get_bookings(occurrence_ids, roles=[]):
    people = []
    bookings = ResourceAllocation.objects.filter(event__pk__in=occurrence_ids)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
            )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Ejemplo n.º 10
0
 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
Ejemplo n.º 11
0
def get_people(parent_event_ids=[], labels=[], label_sets=[], roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(
            errors=[Error(
                code="INVALID_REQUEST",
                details="labels and label_sets are not compatible"), ])
    people = []
    bookings = ResourceAllocation.objects.all()
    act_bookings = []
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(Q(
            event__container_event__parent_event__eventitem__eventitem_id__in=(
                parent_event_ids)) |
            Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if "Performer" in roles:
        act_bookings = bookings.filter(resource__actresource__pk__gt=0)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    for booking in act_bookings:
        if booking.resource.as_subtype.__class__.__name__ == "ActResource":
            performer = booking.resource.actresource.item.as_subtype.performer
            person = Person(
                booking_id=booking.pk,
                user=performer.user_object,
                role="Performer",
                public_class=performer.__class__.__name__,
                public_id=performer.pk
                )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
    def get(self, request, *args, **kwargs):
        eventitem_id = kwargs['eventitem_id']
        schedule_items = []
        personal_schedule_items = []
        eventitem_view = get_event_display_info(eventitem_id)
        person = None
        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")
            all_roles = []
            for n, m in role_options:
                all_roles += [m]
            personal_schedule_items = get_schedule(
                request.user,
                labels=[
                    eventitem_view['event'].calendar_type,
                    eventitem_view['event'].e_conference.conference_slug],
                roles=all_roles,
                ).schedule_items
            if eventitem_view['event'].calendar_type == "Conference":
                eval_response = get_eval_info(person=person)
                if len(eval_response.questions) > 0:
                    eval_occurrences = eval_response.occurrences
                else:
                    eval_occurrences = None

        for occurrence in eventitem_view['scheduled_events']:
            (favorite_link,
             volunteer_link,
             evaluate,
             highlight,
             vol_disable_msg) = build_icon_links(
                occurrence,
                eval_occurrences,
                eventitem_view['event'].calendar_type,
                (eventitem_view['event'].e_conference.status == "completed"),
                personal_schedule_items)

            schedule_items += [{
                'occurrence': occurrence,
                'favorite_link': favorite_link,
                'volunteer_link': volunteer_link,
                'highlight': highlight,
                'evaluate': evaluate,
                'approval_needed': occurrence.approval_needed,
                'vol_disable_msg': vol_disable_msg,
            }]
        template = 'gbe/scheduling/event_detail.tmpl'
        return render(request,
                      template,
                      {'eventitem': eventitem_view,
                       'show_tickets': True,
                       'tickets': eventitem_view['event'].get_tickets,
                       'user_id': request.user.id,
                       'schedule_items': schedule_items})
Ejemplo n.º 13
0
 def groundwork(self, request, args, kwargs):
     this_url = reverse('eval_event',
                        args=[
                            kwargs['occurrence_id'],
                        ],
                        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.person = Person(user=response['owner'].user_object,
                          public_id=response['owner'].pk,
                          public_class="Profile")
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
    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)
Ejemplo n.º 16
0
    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)
Ejemplo n.º 17
0
def update_event(scheduling_form, occurrence_id, people_formset=[]):
    room = get_object_or_404(Room,
                             name=scheduling_form.cleaned_data['location'])
    start_time = get_start_time(scheduling_form.cleaned_data)
    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 = update_occurrence(occurrence_id,
                                 start_time,
                                 scheduling_form.cleaned_data['max_volunteer'],
                                 people=people,
                                 locations=[room])
    return response
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
def get_people(parent_event_ids=[], labels=[], label_sets=[], roles=[]):
    if len(labels) > 0 and len(label_sets) > 0:
        return PeopleResponse(errors=[
            Error(code="INVALID_REQUEST",
                  details="labels and label_sets are not compatible"),
        ])
    people = []
    bookings = ResourceAllocation.objects.all()
    act_bookings = []
    if len(labels) > 0:
        bookings = bookings.filter(event__eventlabel__text__in=labels)
    for label_set in label_sets:
        bookings = bookings.filter(event__eventlabel__text__in=label_set)
    if len(parent_event_ids) > 0:
        bookings = bookings.filter(
            Q(event__container_event__parent_event__eventitem__eventitem_id__in
              =(parent_event_ids))
            | Q(event__eventitem__eventitem_id__in=parent_event_ids))
    if "Performer" in roles:
        act_bookings = bookings.filter(resource__actresource__pk__gt=0)
    if len(roles) > 0:
        bookings = bookings.filter(resource__worker__role__in=roles)
    for booking in bookings:
        if booking.resource.as_subtype.__class__.__name__ == "Worker":
            person = Person(
                booking_id=booking.pk,
                worker=booking.resource.worker,
                role=booking.resource.worker.role,
            )
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    for booking in act_bookings:
        if booking.resource.as_subtype.__class__.__name__ == "ActResource":
            performer = booking.resource.actresource.item.as_subtype.performer
            person = Person(booking_id=booking.pk,
                            user=performer.user_object,
                            role="Performer",
                            public_class=performer.__class__.__name__,
                            public_id=performer.pk)
            if hasattr(booking, 'label'):
                person.label = booking.label.text
            people += [person]
    return PeopleResponse(people=people)
Ejemplo n.º 20
0
def update_event(scheduling_form,
                 occurrence_id,
                 roles=None,
                 people_formset=[]):
    start_time = get_start_time(scheduling_form.cleaned_data)
    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'])]
    if len(people) == 0:
        people = None
    response = update_occurrence(
        occurrence_id,
        start_time,
        scheduling_form.cleaned_data['max_volunteer'],
        people=people,
        roles=roles,
        locations=[scheduling_form.cleaned_data['location']],
        approval=scheduling_form.cleaned_data['approval'])
    return response
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
0
    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)
Ejemplo n.º 24
0
 def post(self, request, *args, **kwargs):
     form = WorkerAllocationForm(request.POST)
     response = None
     email_status = None
     if not form.is_valid():
         context = None
         if request.POST['alloc_id'] == '-1':
             form.data['alloc_id'] = -1
             context = {'new_worker_alloc_form': form}
         else:
             is_present = test_booking(
                 int(request.POST['alloc_id']), self.occurrence.pk)
             if not is_present:
                 response = PersonResponse(errors=[Error(
                     code="BOOKING_NOT_FOUND",
                     details="Booking id %s for occurrence %d not found" % (
                         request.POST['alloc_id'], self.occurrence.pk)), ])
             context = {'worker_alloc_forms': form}
         return self.make_post_response(request,
                                        response=response,
                                        errorcontext=context)
     else:
         data = form.cleaned_data
         if 'delete' in request.POST.keys():
             if ('alloc_id' not in request.POST) or (len(
                     request.POST['alloc_id']) == 0):
                 return self.make_post_response(
                     request,
                     PersonResponse(errors=[Error(
                         code="NO_BOOKING",
                         details="No booking id for occurrence id %d." % (
                             self.occurrence.pk))]))
             response = remove_booking(
                 self.occurrence.pk,
                 booking_id=int(request.POST['alloc_id']))
             if response.booking_id:
                 email_status = send_schedule_update_mail(
                     "Volunteer", data['worker'].workeritem.as_subtype)
         elif data.get('worker', None):
             if data['role'] == "Volunteer":
                 data['worker'].workeritem.as_subtype.check_vol_bid(
                     self.item.e_conference)
             person = Person(
                 user=data['worker'].workeritem.as_subtype.user_object,
                 public_id=data['worker'].workeritem.as_subtype.pk,
                 role=data['role'],
                 label=data['label'],
                 worker=None)
             if int(data['alloc_id']) > -1:
                 person.booking_id = int(data['alloc_id'])
             response = set_person(
                 self.occurrence.pk,
                 person
             )
             email_status = send_schedule_update_mail("Volunteer",
                                                      data['worker'])
         if email_status:
             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)
         self.success_url = reverse('edit_event',
                                    urlconf='gbe.scheduling.urls',
                                    args=[self.conference.conference_slug,
                                          self.occurrence.pk])
     return self.make_post_response(request,
                                    response=response)
Ejemplo n.º 25
0
    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
Ejemplo n.º 26
0
    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)
Ejemplo n.º 27
0
    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)