示例#1
0
def show_gig(request, band_id, entry_id):
    context = {}
    try:
        band = bands_manager.get_band(band_id)
        if not band.is_member(request.user):
            raise Exception("You have no permission to view this band's events cause you are not a member of it.")

        gig = bands_manager.get_gig(entry_id)

        # calculates the band diff setlist (band setlist songs minus gig setlist songs)
        diff_setlist = []

        for song in band.setlist.song_list:
            if not gig.setlist.contains(song):
                diff_setlist.append(song)

        context['diff_setlist'] = diff_setlist

        context['band'] = band
        context['gig'] = gig

        if gig.contract is None:
            view_url = reverse('project.views_gig.upload_contract', args=[band.id, gig.id])
            upload_url, upload_data = prepare_upload(request, view_url)
            context["contract_form"] = UploadBandFileForm()
            context['contract_url'] = upload_url
            context['contract_data'] = upload_data
            context['form'] = True
        else:
            context["contract"] = gig.contract
            context['form'] = False
    except Exception as exc:
        # 500
        context['error_msg'] = "Error ocurred: %s" % exc.message
    return render_to_response('band/events/gig/show.html', context, context_instance=RequestContext(request))
示例#2
0
def edit_gig(request, band_id, entry_id):
    context = {}

    try:
        band = bands_manager.get_band(band_id)
        context['band'] = band

        gig = bands_manager.get_gig(entry_id)

        if not band.is_member(request.user):
            raise Exception("You have no permission to edit this band's events cause you are not a member of it.")

        if request.method == 'POST':
            form = GigEntryForm(request.POST)
            context['form'] = form
            if form.is_valid():
                date_start = form.cleaned_data['date_start']
                time_start = form.cleaned_data['time_start']
                time_end = form.cleaned_data['time_end']
                place = form.cleaned_data['place']
                costs = form.cleaned_data['costs']
                ticket = form.cleaned_data['ticket']

                gig = bands_manager.update_gig_entry(entry_id, date_start, time_start, time_end, place, costs, ticket)
                request.flash['success'] = "Gig updated successfully!"
                return redirect('/band/%d/events' % band.id)
        else: # GET
            if gig.band != band:
                raise Exception("There is no gig for this band with the given Id.")

            data = {'date_start' : gig.date_start,
                    'date_end' : gig.date_end,
                    'time_start' : gig.time_start,
                    'time_end' : gig.time_end,
                    'place' : gig.place,
                    'costs' : gig.costs,
                    'ticket' : gig.ticket
                    }
            form = GigEntryForm(data)

        context['gig'] = gig
        context['form'] = form
    except Exception as exc:
        # 404
        context['error_msg'] = "Error ocurred: %s" % exc.message

    return render_to_response('band/events/gig/edit.html', context, context_instance=RequestContext(request))
示例#3
0
def gig_setlist(request, band_id, entry_id):
    context = {}

    try:
        band = bands_manager.get_band(band_id)
        context['band'] = band

        if not band.is_member(request.user):
            raise Exception("You have no permission to view this band's event cause you are not a member of it.")

        gig = bands_manager.get_gig(entry_id)
        context['gig'] = gig

        # calculates the band diff setlist (band setlist songs minus gig setlist songs)
        diff_setlist = []
        for song in band.setlist.song_list:
            if not gig.setlist.contains(song):
                diff_setlist.append(song)

        context['diff_setlist'] = diff_setlist

    except Exception as exc:
        context['error_msg'] = "Error ocurred: %s" % exc.message
    return render_to_response('band/events/gig/setlist.html', context, context_instance=RequestContext(request))