Esempio n. 1
0
    def groundwork(self, request, args, kwargs):
        self.shows = []
        self.rehearsals = {}
        self.next_page = request.GET.get('next',
                                         reverse('home', urlconf='gbe.urls'))
        profile = validate_profile(request, require=False)
        if not profile:
            return HttpResponseRedirect(
                reverse('profile_update', urlconf='gbe.urls'))
        act_id = kwargs.get("act_id")
        self.act = get_object_or_404(Act, id=act_id)
        if self.act.performer.contact != profile:
            validate_perms(request, self.permissions)
        response = get_schedule(labels=[self.act.b_conference.conference_slug],
                                commitment=self.act)

        for item in response.schedule_items:
            # group acts will have multiple items for same show
            if item.event not in self.shows and Show.objects.filter(
                    eventitem_id=item.event.eventitem.eventitem_id).exists():
                self.shows += [item.event]
            elif GenericEvent.objects.filter(
                    eventitem_id=item.event.eventitem.eventitem_id,
                    type='Rehearsal Slot').exists():
                show_key = item.event.container_event.parent_event.pk
                self.rehearsals[show_key] = item
        if len(self.shows) == 0:
            raise Http404
Esempio n. 2
0
def ViewTroupeView(request, troupe_id=None):
    '''
    Show troupes to troupe members, only contact should edit.
    '''
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('profile_update',
                                            urlconf='gbe.urls') +
                                    '?next=' +
                                    reverse('troupe-add',
                                            urlconf='gbe.urls'))

    troupe = get_object_or_404(Troupe, resourceitem_id=troupe_id)
    if not (troupe.contact.profile == profile or troupe.membership.filter(
            performer_profile=profile).exists() or validate_perms(
            request, ('Registrar',
                      'Volunteer Coordinator',
                      'Act Coordinator',
                      'Conference Coordinator',
                      'Vendor Coordinator',
                      'Ticketing - Admin'), require=False)):
        raise Http404
    performer_form = TroupeForm(instance=troupe,
                                prefix="The Troupe")
    performer_form.fields['membership'] = ModelMultipleChoiceField(
        queryset=troupe.membership.all())
    owner = get_participant_form(
            troupe.contact,
            prefix='Troupe Contact')
    return render(request,
                  'gbe/bid_view.tmpl',
                  {'readonlyform': [performer_form, owner]})
    def get_queryset(self):
        profile = validate_profile(self.request, require=True)
        if not profile:
            return Business.objects.none()

        qs = Business.objects.filter(owners=profile)

        if self.q:
            qs = qs.filter(Q(name__icontains=self.q))

        return qs
    def get_queryset(self):
        profile = validate_profile(self.request, require=True)
        if not profile:
            return Persona.objects.none()

        qs = Persona.objects.filter(contact=profile)

        if self.q:
            qs = qs.filter(
                Q(name__icontains=self.q) | Q(label__icontains=self.q))

        return qs
def SubmitActView(request, act_id):
    submitter = validate_profile(request, require=True)
    try:
        the_act = Act.objects.get(id=act_id)
    except Act.DoesNotExist:
        raise Http404
    if the_act not in submitter.get_acts():
        return render(request, 'gbe/error.tmpl',
                      {'error': "You don't own that act."})
    else:
        the_act.submitted = True
        the_act.save()
        return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
    def get_queryset(self):
        if not validate_profile(self.request, require=True):
            return Persona.objects.none()

        qs = Persona.objects.filter(
            contact__user_object__is_active=True)

        if self.q:
            qs = qs.filter(
                Q(name__icontains=self.q) |
                Q(performer_profile__display_name__icontains=self.q) |
                Q(label__icontains=self.q))

        return qs
Esempio n. 7
0
def EditPersonaView(request, persona_id):
    '''
    Modify an existing Persona object.
    '''
    page_title = 'Manage Persona'
    view_title = 'Tell Us About Your Stage Persona'
    submit_button = 'Save Persona'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('profile_update',
                                            urlconf='gbe.urls'))
    persona = get_object_or_404(Persona, resourceitem_id=persona_id)
    if persona.performer_profile != profile:
        raise PermissionDenied

    if request.method == 'POST':
        form = PersonaForm(request.POST,
                           request.FILES,
                           instance=persona)
        if form.is_valid():
            performer = form.save(commit=True)
            user_message = UserMessage.objects.get_or_create(
                view='EditPersonaView',
                code="UPDATE_PERSONA",
                defaults={
                    'summary': "Create Persona Success",
                    'description': default_edit_persona_msg})
            messages.success(request, user_message[0].description)
            return HttpResponseRedirect(reverse('home',
                                                urlconf='gbe.urls'))
        else:
            return render(request,
                          'gbe/bid.tmpl',
                          {'forms': [form],
                           'nodraft': submit_button,
                           'page_title': page_title,
                           'view_title': view_title,
                           })
    else:
        form = PersonaForm(instance=persona)
        return render(request,
                      'gbe/bid.tmpl',
                      {'forms': [form],
                       'nodraft': submit_button,
                       'page_title': page_title,
                       'view_title': view_title,
                       })
Esempio n. 8
0
def EditPersonaView(request, persona_id):
    '''
    Modify an existing Persona object.
    '''
    page_title = 'Manage Persona'
    view_title = 'Tell Us About Your Stage Persona'
    submit_button = 'Save Persona'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('profile_update',
                                            urlconf='gbe.urls'))
    persona = get_object_or_404(Persona, resourceitem_id=persona_id)
    if persona.performer_profile != profile:
        raise PermissionDenied

    if request.method == 'POST':
        form = PersonaForm(request.POST,
                           request.FILES,
                           instance=persona)
        if form.is_valid():
            performer = form.save(commit=True)
            user_message = UserMessage.objects.get_or_create(
                view='EditPersonaView',
                code="UPDATE_PERSONA",
                defaults={
                    'summary': "Create Persona Success",
                    'description': default_edit_persona_msg})
            messages.success(request, user_message[0].description)
            return HttpResponseRedirect(reverse('home',
                                                urlconf='gbe.urls'))
        else:
            return render(request,
                          'gbe/bid.tmpl',
                          {'forms': [form],
                           'nodraft': submit_button,
                           'page_title': page_title,
                           'view_title': view_title,
                           })
    else:
        form = PersonaForm(instance=persona)
        return render(request,
                      'gbe/bid.tmpl',
                      {'forms': [form],
                       'nodraft': submit_button,
                       'page_title': page_title,
                       'view_title': view_title,
                       })
Esempio n. 9
0
 def groundwork(self, request, args, kwargs):
     self.profile = validate_profile(request, require=False)
     if not self.profile:
         self.profile = Profile()
         self.profile.user_object = request.user
         self.profile.save()
         self.profile.preferences = ProfilePreferences()
         self.profile.preferences.save()
         self.profile.save()
     email_pref_message = UserMessage.objects.get_or_create(
         view=self.__class__.__name__,
         code="EMAIL_PREF_NOTE",
         defaults={
             'summary': "Email Preference Settings Note",
             'description': email_pref_note
         })
     return email_pref_message
Esempio n. 10
0
def RegisterPersonaView(request, **kwargs):
    page_title = 'Stage Persona'
    view_title = 'Tell Us About Your Stage Persona'
    submit_button = 'Save Persona'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
    if request.method == 'POST':
        form = PersonaForm(request.POST, request.FILES)
        if form.is_valid():
            performer = form.save(commit=True)
            pid = profile.pk
            if request.GET.get('next', None):
                redirect_to = request.GET['next']
            else:
                redirect_to = reverse('home', urlconf='gbe.urls')
                user_message = UserMessage.objects.get_or_create(
                    view='RegisterPersonaView',
                    code="CREATE_PERSONA",
                    defaults={
                        'summary': "Create Persona Success",
                        'description': default_create_persona_msg
                    })
                messages.success(request, user_message[0].description)
            return HttpResponseRedirect(redirect_to)
        else:
            return render(
                request, 'gbe/bid.tmpl', {
                    'forms': [form],
                    'nodraft': submit_button,
                    'page_title': page_title,
                    'view_title': view_title,
                })
    else:
        form = PersonaForm(initial={
            'performer_profile': profile,
            'contact': profile,
        })
        return render(
            request, 'gbe/bid.tmpl', {
                'forms': [form],
                'nodraft': submit_button,
                'page_title': page_title,
                'view_title': view_title,
            })
Esempio n. 11
0
def RegisterPersonaView(request, **kwargs):
    page_title = 'Stage Persona'
    view_title = 'Tell Us About Your Stage Persona'
    submit_button = 'Save Persona'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('home',
                                            urlconf='gbe.urls'))
    if request.method == 'POST':
        form = PersonaForm(request.POST, request.FILES)
        if form.is_valid():
            performer = form.save(commit=True)
            pid = profile.pk
            if request.GET.get('next', None):
                redirect_to = request.GET['next']
            else:
                redirect_to = reverse('home', urlconf='gbe.urls')
                user_message = UserMessage.objects.get_or_create(
                    view='RegisterPersonaView',
                    code="CREATE_PERSONA",
                    defaults={
                        'summary': "Create Persona Success",
                        'description': default_create_persona_msg})
                messages.success(request, user_message[0].description)
            return HttpResponseRedirect(redirect_to)
        else:
            return render(request, 'gbe/bid.tmpl',
                          {'forms': [form],
                           'nodraft': submit_button,
                           'page_title': page_title,
                           'view_title': view_title,
                           })
    else:
        form = PersonaForm(initial={'performer_profile': profile,
                                    'contact': profile,
                                    })
        return render(request, 'gbe/bid.tmpl',
                      {'forms': [form],
                       'nodraft': submit_button,
                       'page_title': page_title,
                       'view_title': view_title,
                       })
Esempio n. 12
0
    def groundwork(self, request, args, kwargs):
        self.historical = "historical" in list(request.GET.keys())
        self.is_staff_lead = False
        self.admin_message = None

        if "profile_id" in kwargs:
            profile_id = kwargs.get("profile_id")
            self.admin_profile = validate_perms(
                request, ('Registrar', 'Volunteer Coordinator',
                          'Act Coordinator', 'Class Coordinator',
                          'Vendor Coordinator', 'Ticketing - Admin'))
            self.viewer_profile = get_object_or_404(Profile, pk=profile_id)
            self.admin_message = "You are viewing a user's profile, " + \
                "not your own."
        else:
            self.viewer_profile = validate_profile(request, require=False)
        self.is_staff_lead = validate_perms(request, [
            'Staff Lead',
        ],
                                            require=False)
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
        })
Esempio n. 14
0
    def groundwork(self, request, args, kwargs):
        self.owner = validate_profile(request, require=False)
        if not self.owner or not self.owner.complete:
            user_message = UserMessage.objects.get_or_create(
                view=self.__class__.__name__,
                code="PROFILE_INCOMPLETE",
                defaults={
                    'summary': "%s Profile Incomplete",
                    'description': no_profile_msg})
            messages.warning(request, user_message[0].description)
            return '%s?next=%s' % (
                reverse('profile_update', urlconf='gbe.urls'),
                reverse('%s_create' % self.bid_type.lower(),
                        urlconf='gbe.urls'))

        self.bid_object = None
        if "bid_id" in kwargs:
            bid_id = kwargs.get("bid_id")
            self.bid_object = get_object_or_404(self.bid_class, pk=bid_id)
            self.conference = self.bid_object.b_conference
        else:
            self.conference = Conference.objects.filter(
                    accepting_bids=True).first()
Esempio n. 15
0
def ConferenceVolunteerView(request):
    '''
    Volunteer to chair or sit on a panel or teach a class.
    Builds out from Class Proposal
    '''
    page_title = "Apply to Present"
    view_title = "Apply to Present"
    owner = validate_profile(request, require=False)
    if not owner:
        return HttpResponseRedirect(
            reverse('profile_update', urlconf='gbe.urls'))
    presenters = owner.personae.all()
    classes = ClassProposal.objects.filter(display=True).order_by(
        'type', 'title')
    # if there's no classes to work with, save the user the bother, and
    # just let them know
    if len(classes) == 0:
        return render(request, 'gbe/conf_volunteer_list.tmpl', {
            'view_title': view_title,
            'page_title': page_title
        })
    if len(presenters) == 0:
        return HttpResponseRedirect(
            reverse('persona_create', urlconf='gbe.urls') + '?next=' +
            reverse('conference_volunteer', urlconf='gbe.urls'))
    header = ClassProposal().presenter_bid_header
    header += ConferenceVolunteer().presenter_bid_header

    if request.method == 'POST':
        for aclass in classes:
            if str(aclass.id) + '-volunteering' in request.POST.keys():
                form = ConferenceVolunteerForm(request.POST,
                                               prefix=str(aclass.id))
                if not form.is_valid():
                    return render(request, 'gbe/error.tmpl',
                                  {'error': conf_volunteer_save_error})
                volunteer, created = ConferenceVolunteer.objects.get_or_create(
                    presenter=form.cleaned_data['presenter'],
                    bid=aclass,
                    defaults=form.cleaned_data)

                if not created:  # didn't create, so need to update
                    form = ConferenceVolunteerForm(request.POST,
                                                   instance=volunteer,
                                                   prefix=str(aclass.id))
                    if form.is_valid():
                        form.save()
                    else:
                        return render(request, 'gbe/error.tmpl',
                                      {'error': conf_volunteer_save_error})
        return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
    else:
        how = 'how_volunteer'
        rows = []
        for aclass in classes:
            form = ConferenceVolunteerForm(initial={
                'bid': aclass,
                'presenter': presenters[0]
            },
                                           prefix=str(aclass.id))
            form.fields['presenter'] = ModelChoiceField(
                queryset=Performer.objects.filter(contact=owner),
                empty_label=None)
            if aclass.type == "Class":
                form.fields[how] = ChoiceField(
                    choices=class_participation_types)
                form.fields[how].widget.attrs['readonly'] = True
            elif aclass.type == "Panel":
                form.fields[how] = ChoiceField(
                    choices=panel_participation_types, initial="Panelist")
            else:
                form.fields[how] = ChoiceField(
                    choices=conference_participation_types)
            form.fields[how].widget.attrs['class'] = how
            bid_row = {}
            bid_row['conf_item'] = aclass.presenter_bid_info
            bid_row['form'] = form
            rows.append(bid_row)

    return render(
        request, 'gbe/conf_volunteer_list.tmpl', {
            'view_title': view_title,
            'page_title': page_title,
            'header': header,
            'rows': rows
        })
Esempio n. 16
0
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))
Esempio n. 17
0
def EditActTechInfoView(request, act_id):
    '''
    Modify tech info for an existing act
    '''
    page_title = 'Edit Act Technical Information'
    view_title = 'Edit Act Technical Information'
    submit_button = 'Submit'

    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('profile_update',
                                            urlconf='gbe.urls'))

    act = get_object_or_404(Act, id=act_id)
    if act.performer.contact != profile:
        validate_perms(request, ('Tech Crew', ))

    audio_info = act.tech.audio
    stage_info = act.tech.stage
    audio_info = act.tech.audio
    lighting_info = act.tech.lighting
    cue_objects = [CueInfo.objects.get_or_create(techinfo=act.tech,
                                                 cue_sequence=i)[0]
                   for i in range(3)]

    shows = act.get_scheduled_shows()
    show_detail = get_object_or_404(Show, eventitem_id=shows[0].eventitem.pk)

    if show_detail.cue_sheet == 'Theater':
        formtype = CueInfoForm
    elif show_detail.cue_sheet == 'Alternate':
        formtype = VendorCueInfoForm
    else:
        formtype = "None"

    form = ActTechInfoForm(instance=act,
                           prefix='act_tech_info')
    q = Performer.objects.filter(contact=profile)
    form.fields['performer'] = ModelChoiceField(queryset=q)

    rehearsal_forms = set_rehearsal_forms(shows, act)

    if request.method == 'POST':
        if 'rehearsal' in request.POST:
            rehearsal = get_object_or_404(sEvent,
                                          id=request.POST['rehearsal'])
            show = get_object_or_404(
                Show,
                eventitem_id=request.POST['show_private']
                ).scheduler_events.first()
            act.set_rehearsal(show, rehearsal)
        audioform = AudioInfoSubmitForm(request.POST,
                                        request.FILES,
                                        prefix='audio_info',
                                        instance=audio_info)
        stageform = StageInfoSubmitForm(request.POST,
                                        prefix='stage_info',
                                        instance=stage_info)
        lightingform = LightingInfoForm(request.POST,
                                        prefix='lighting_info',
                                        instance=lighting_info)
        cue_fail = False
        if formtype != "None":
            cue_forms = [formtype(request.POST,
                                  prefix='cue%d' % i,
                                  instance=cue_objects[i]) for i in range(3)]
            cue_forms[0].fields['cue_off_of'] = ChoiceField(
                choices=starting_cues,
                initial=starting_cues[0])
            cue_fail = not cue_forms[0].is_valid()
            for f in cue_forms:
                if f.is_valid():
                    f.save()

        techforms = [lightingform,  audioform, stageform, ]

        forms_valid = True
        for f in techforms:
            forms_valid = f.is_valid() and forms_valid
        if forms_valid:
            for f in techforms:
                f.save()
        tech = act.tech
        if forms_valid and tech.is_complete and not cue_fail:
            user_message = UserMessage.objects.get_or_create(
                view='EditActTechInfoView',
                code="UPDATE_ACT_TECH",
                defaults={
                    'summary': "Update Act Tech Info Success",
                    'description': default_update_act_tech})
            messages.success(request, user_message[0].description)
            return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
        else:
            form_data = {'readonlyform': [form],
                         'rehearsal_forms': rehearsal_forms,
                         'forms': techforms,
                         'page_title': page_title,
                         'view_title': view_title,
                         'showheader': False,
                         'nodraft': submit_button,
                         'hide_list_details': True,
                         'cue_type': show_detail.cue_sheet
                         }
            if formtype != "None":
                form_data['cues'] = cue_forms

            return render(request,
                          'gbe/act_techinfo.tmpl',
                          form_data)
    else:
        audioform = AudioInfoSubmitForm(prefix='audio_info',
                                        instance=audio_info)
        stageform = StageInfoSubmitForm(prefix='stage_info',
                                        instance=stage_info)
        lightingform = LightingInfoForm(prefix='lighting_info',
                                        instance=lighting_info)
        techforms = [lightingform, audioform, stageform, ]

        form_data = {'readonlyform': [form],
                     'rehearsal_forms': rehearsal_forms,
                     'forms': techforms,
                     'page_title': page_title,
                     'view_title': view_title,
                     'showheader': False,
                     'nodraft': submit_button,
                     'hide_list_details': True,
                     'cue_type': show_detail.cue_sheet}

        if formtype != "None":
            cue_forms = [formtype(prefix='cue%d' % i, instance=cue_objects[i])
                         for i in range(3)]
            cue_forms[0].fields['cue_off_of'] = ChoiceField(
                choices=starting_cues,
                initial=starting_cues[0])
            form_data['cues'] = cue_forms

        return render(request,
                      'gbe/act_techinfo.tmpl',
                      form_data)
Esempio n. 18
0
def UpdateProfileView(request):
    profile = validate_profile(request, require=False)
    if not profile:
        profile = Profile()
        profile.user_object = request.user
        profile.save()
        profile.preferences = ProfilePreferences()
        profile.preferences.save()
        profile.save()

    if request.method == 'POST':
        form = ParticipantForm(request.POST,
                               instance=profile,
                               initial={'email': profile.user_object.email
                                        })
        prefs_form = ProfilePreferencesForm(request.POST,
                                            instance=profile.preferences,
                                            prefix='prefs')
        if form.is_valid():
            form.save(commit=True)
            if profile.purchase_email.strip() == '':
                profile.purchase_email = request.user.email.strip()
            if prefs_form.is_valid():
                prefs_form.save(commit=True)
                profile.preferences = prefs_form.save()
            profile.save()

            form.save()
            user_message = UserMessage.objects.get_or_create(
                view='UpdateProfileView',
                code="UPDATE_PROFILE",
                defaults={
                    'summary': "Update Profile Success",
                    'description': default_update_profile_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)
        else:
            return render(request, 'gbe/update_profile.tmpl',
                          {'left_forms': [form], 'right_forms': [prefs_form]})

    else:
        if profile.display_name.strip() == '':
            display_name = "%s %s" % (request.user.first_name.strip(),
                                      request.user.last_name.strip())
        else:
            display_name = profile.display_name
        if len(profile.how_heard.strip()) > 0:
            how_heard_initial = eval(profile.how_heard)
        else:
            how_heard_initial = []
        form = ParticipantForm(instance=profile,
                               initial={'email': request.user.email,
                                        'first_name': request.user.first_name,
                                        'last_name': request.user.last_name,
                                        'display_name': display_name,
                                        'how_heard': how_heard_initial})
        if len(profile.preferences.inform_about.strip()) > 0:
            inform_initial = eval(profile.preferences.inform_about)
        else:
            inform_initial = []
        prefs_form = ProfilePreferencesForm(prefix='prefs',
                                            instance=profile.preferences,
                                            initial={'inform_about':
                                                     inform_initial})

        return render(request, 'gbe/update_profile.tmpl',
                      {'left_forms': [form], 'right_forms': [prefs_form]})
Esempio n. 19
0
def UpdateProfileView(request):
    profile = validate_profile(request, require=False)
    if not profile:
        profile = Profile()
        profile.user_object = request.user
        profile.save()
        profile.preferences = ProfilePreferences()
        profile.preferences.save()
        profile.save()

    if request.method == 'POST':
        form = ParticipantForm(request.POST,
                               instance=profile,
                               initial={'email': profile.user_object.email})
        prefs_form = ProfilePreferencesForm(request.POST,
                                            instance=profile.preferences,
                                            prefix='prefs')
        if form.is_valid():
            form.save(commit=True)
            if profile.purchase_email.strip() == '':
                profile.purchase_email = request.user.email.strip()
            if prefs_form.is_valid():
                prefs_form.save(commit=True)
                profile.preferences = prefs_form.save()
            profile.save()

            form.save()
            user_message = UserMessage.objects.get_or_create(
                view='UpdateProfileView',
                code="UPDATE_PROFILE",
                defaults={
                    'summary': "Update Profile Success",
                    'description': default_update_profile_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)
        else:
            return render(request, 'gbe/update_profile.tmpl', {
                'left_forms': [form],
                'right_forms': [prefs_form]
            })

    else:
        if profile.display_name.strip() == '':
            display_name = "%s %s" % (request.user.first_name.strip(),
                                      request.user.last_name.strip())
        else:
            display_name = profile.display_name
        if len(profile.how_heard.strip()) > 0:
            how_heard_initial = eval(profile.how_heard)
        else:
            how_heard_initial = []
        form = ParticipantForm(instance=profile,
                               initial={
                                   'email': request.user.email,
                                   'first_name': request.user.first_name,
                                   'last_name': request.user.last_name,
                                   'display_name': display_name,
                                   'how_heard': how_heard_initial
                               })
        if len(profile.preferences.inform_about.strip()) > 0:
            inform_initial = eval(profile.preferences.inform_about)
        else:
            inform_initial = []
        prefs_form = ProfilePreferencesForm(
            prefix='prefs',
            instance=profile.preferences,
            initial={'inform_about': inform_initial})

        return render(request, 'gbe/update_profile.tmpl', {
            'left_forms': [form],
            'right_forms': [prefs_form]
        })
Esempio n. 20
0
def EditTroupeView(request, troupe_id=None):
    page_title = 'Manage Troupe'
    view_title = 'Tell Us About Your Troupe'
    submit_button = 'Save Troupe'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(
            reverse('profile_update', urlconf='gbe.urls') + '?next=' +
            reverse('troupe_create', urlconf='gbe.urls'))
    personae = profile.personae.all()
    if len(personae) == 0:
        return HttpResponseRedirect(
            reverse('persona_create', urlconf='gbe.urls') + '?next=' +
            reverse('troupe_create', urlconf='gbe.urls'))
    if troupe_id:
        troupe = get_object_or_404(Troupe, resourceitem_id=troupe_id)
    else:
        troupe = Troupe()

    if (troupe_id > 0 and request.user
            and troupe.contact != request.user.profile):
        return HttpResponseRedirect(
            reverse('troupe_view', urlconf='gbe.urls', args=[str(troupe_id)]))

    if request.method == 'POST':
        form = TroupeForm(request.POST, request.FILES, instance=troupe)
        if form.is_valid():
            form.save(commit=True)
            user_message = UserMessage.objects.get_or_create(
                view='EditTroupeView',
                code="UPDATE_TROUPE",
                defaults={
                    'summary': "Update Troupe Success",
                    'description': default_edit_troupe_msg
                })
            messages.success(request, user_message[0].description)
            return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
        else:
            q = Profile.objects.filter(resourceitem_id=profile.resourceitem_id)
            form.fields['contact'] = ModelChoiceField(
                queryset=q, empty_label=None, label=persona_labels['contact'])
            return render(
                request, 'gbe/bid.tmpl', {
                    'forms': [form],
                    'nodraft': submit_button,
                    'page_title': page_title,
                    'view_title': view_title,
                    'view_header_text': troupe_header_text
                })
    else:
        form = TroupeForm(instance=troupe, initial={'contact': profile})
        q = Profile.objects.filter(resourceitem_id=profile.resourceitem_id)
        form.fields['contact'] = ModelChoiceField(
            queryset=q, empty_label=None, label=persona_labels['contact'])
        return render(
            request, 'gbe/bid.tmpl', {
                'forms': [form],
                'nodraft': submit_button,
                'page_title': page_title,
                'view_title': view_title,
                'view_header_text': troupe_header_text
            })
Esempio n. 21
0
def EditTroupeView(request, troupe_id=None):
    page_title = 'Manage Troupe'
    view_title = 'Tell Us About Your Troupe'
    submit_button = 'Save Troupe'
    profile = validate_profile(request, require=False)
    if not profile:
        return HttpResponseRedirect(reverse('profile_update',
                                            urlconf='gbe.urls') +
                                    '?next=' +
                                    reverse('troupe_create',
                                            urlconf='gbe.urls'))
    personae = profile.personae.all()
    if len(personae) == 0:
        return HttpResponseRedirect(reverse('persona_create',
                                            urlconf='gbe.urls') +
                                    '?next=' +
                                    reverse('troupe_create',
                                            urlconf='gbe.urls'))
    if troupe_id:
        troupe = get_object_or_404(Troupe, resourceitem_id=troupe_id)
    else:
        troupe = Troupe()

    if (troupe_id > 0 and
            request.user and
            troupe.contact != request.user.profile):
        return HttpResponseRedirect(reverse('troupe_view',
                                            urlconf='gbe.urls',
                                            args=[str(troupe_id)]))

    if request.method == 'POST':
        form = TroupeForm(request.POST, request.FILES, instance=troupe)
        if form.is_valid():
            form.save(commit=True)
            user_message = UserMessage.objects.get_or_create(
                view='EditTroupeView',
                code="UPDATE_TROUPE",
                defaults={
                    'summary': "Update Troupe Success",
                    'description': default_edit_troupe_msg})
            messages.success(request, user_message[0].description)
            return HttpResponseRedirect(reverse('home', urlconf='gbe.urls'))
        else:
            q = Profile.objects.filter(resourceitem_id=profile.resourceitem_id)
            form.fields['contact'] = ModelChoiceField(
                queryset=q,
                empty_label=None,
                label=persona_labels['contact'])
            return render(request,
                          'gbe/bid.tmpl',
                          {'forms': [form],
                           'nodraft': submit_button,
                           'page_title': page_title,
                           'view_title': view_title,
                           'view_header_text': troupe_header_text})
    else:
        form = TroupeForm(instance=troupe, initial={'contact': profile})
        q = Profile.objects.filter(resourceitem_id=profile.resourceitem_id)
        form.fields['contact'] = ModelChoiceField(
            queryset=q,
            empty_label=None,
            label=persona_labels['contact'])
        return render(request, 'gbe/bid.tmpl',
                      {'forms': [form],
                       'nodraft': submit_button,
                       'page_title': page_title,
                       'view_title': view_title,
                       'view_header_text': troupe_header_text})