コード例 #1
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_role_add(request, project):
    project = get_project(request, project, 'manage_roles')

    if request.POST:
        form_role = RoleForm(request.POST)
        form_picture = RolePictureForm(request.POST, request.FILES)
        if form_role.is_valid():
            role = form_role.save(commit=False)
            if form_picture.is_valid():
                picture = form_picture.save(commit=False)
                if role.actor:
                    picture.title = _(u'%s als %s' % (role.actor, role.name))
                else:
                    picture.title = role.name
                picture.save()
                role.picture = picture

            role.project = project
            role.save()
            message_object_created(request, role)
            return redirect('bs-role-list', project=project.pk)
    else:
        form_role = RoleForm()
        form_picture = RolePictureForm()

    return render(request, 'project/role-form.html',
                  get_context_backstage_project(request, project, 'bs-role-form',
                                                {'project': project, 'form_role': form_role,
                                                 'form_picture': form_picture}))
コード例 #2
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_fee_form(request, project, fee):
    project = get_project(request, project, 'is_manager')
    fee = get_object_or_404(Fee, pk=fee)

    if request.POST:
        if request.POST.get('delete'):
            message_object_deleted(request, fee)
            fee.delete()
            return redirect('bs-fee-list', project=project.pk)

        form = FeeForm(request.POST, instance=fee)
        if form.is_valid():
            form.save()
            message_object_updated(request, fee)
            return redirect('bs-fee-list', project=project.pk)
    else:
        form = FeeForm(instance=fee)

    c = {
        'project': project,
        'view_title': Fee.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-fee-list',
        'form': form,
        'object': fee
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-fee-form', c))
コード例 #3
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_project_publish(request, project):
    project = get_project(request, project, 'is_manager')
    project.visibility = True
    messages.success(request, _(
        u'%s <em>%s</em> wurde öffentlich sichtbar geschaltet!' % (project._meta.verbose_name, project.title)))
    project.save()
    return redirect('bs-dashboard', project=project.pk)
コード例 #4
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_gallery_form(request, project):
    project = get_project(request, project, 'manage_content')
    slider = Slider.objects.get_or_create(name='gallery_%s' % project.pk)[0]

    if request.POST and request.FILES:
        form = SliderSinglePictureForm(request.POST, request.FILES)
        if form.is_valid():
            picture = form.save()
            slider.add(picture)
            message_object_created(request, picture)
    else:
        form = SliderSinglePictureForm()

    if request.POST and not request.FILES:
        if request.POST.get('delete'):
            picture = SliderPicture.objects.get(pk=request.POST.get('delete'))
            message_object_deleted(request, picture)
            picture.delete()
        if request.POST.get('up'):
            SliderPicture.objects.get(pk=request.POST.get('up')).up()
        if request.POST.get('down'):
            SliderPicture.objects.get(pk=request.POST.get('down')).down()

    return render(request, 'project/gallery-form.html',
                  get_context_backstage_project(request, project, 'bs-gallery',
                                                {'project': project, 'gallery': slider, 'form': form}))
コード例 #5
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_event_form(request, project, event):
    project = get_project(request, project, 'manage_dates')
    event = get_object_or_404(Event, pk=event, project=project)

    if request.POST:
        if request.POST.get('delete'):
            message_object_deleted(request, event)
            event.delete()
            return redirect('bs-event-list', project=project.pk)

        form = EventForm(request.POST, instance=event)
        if form.is_valid():
            form.save()
            message_object_updated(request, event)
            return redirect('bs-event-list', project=project.pk)
    else:
        form = EventForm(instance=event)

    c = {
        'project': project,
        'view_title': Event.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-event-list',
        'form': form,
        'object': event
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-event-form', c))
コード例 #6
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_reservation_delete(request, project, event, reservation):
    project = get_project(request, project, 'manage_reservations')
    event = get_object_or_404(Event, project=project, pk=event)
    reservation = get_object_or_404(Reservation, event=event, pk=reservation)

    message_object_deleted(request, reservation)
    reservation.delete()

    return redirect('bs-reservation-list', project=project.pk, event=event.pk)
コード例 #7
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_event_list(request, project):
    project = get_project(request, project, 'view_backstage')
    c = {
        'project': project,
        'object_list': project.get_events(),
        'list_title': Event.objects.model._meta.verbose_name_plural,
        'list_url_add': 'bs-event-add'
    }
    return render(request, 'project/event-list.html',
                  get_context_backstage_project(request, project, 'bs-event-list', c))
コード例 #8
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_fee_list(request, project):
    project = get_project(request, project, 'is_manager')
    fees = project.get_fees()
    c = {
        'project': project,
        'object_list': fees,
        'list_title': Fee.objects.model._meta.verbose_name_plural,
        'list_url_add': 'bs-fee-add'
    }
    return render(request, 'project/fees-list.html',
                  get_context_backstage_project(request, project, 'bs-fee-list', c))
コード例 #9
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_role_list(request, project):
    project = get_project(request, project, 'view_backstage')
    roles = Role.objects.filter(project=project)
    c = {
        'project': project,
        'object_list': roles,
        'list_title': Role.objects.model._meta.verbose_name_plural,
        'list_url_add': 'bs-role-add'
    }
    return render(request, 'project/roles-list.html',
                  get_context_backstage_project(request, project, 'bs-role-list', c))
コード例 #10
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_content_form(request, project):
    project = get_project(request, project, 'manage_content')

    if request.POST:
        form = ProjectForm(request.POST, instance=project)
        if form.is_valid():
            form.save()
            message_object_updated(request, project)
    else:
        form = ProjectForm(instance=project)

    return render(request, 'project/content-form.html',
                  get_context_backstage_project(request, project, 'bs-content',
                                                {'project': project, 'form': form}))
コード例 #11
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_reservation_list(request, project, event):
    project = get_project(request, project, 'view_reservations')
    event = get_object_or_404(Event, project=project, pk=event)
    fees = project.get_fees()

    reservations = Reservation.objects.filter(event=event)

    fees_total = []
    for fee in fees:
        fees_total.append(event.seats_by_fee(fee=fee))

    return render(request, 'project/reservation-list.html',
                  get_context_backstage_project(request, project, 'bs-reservation-list',
                                                {'project': project, 'event': event, 'fees': fees,
                                                 'fees_total': fees_total, 'reservations': reservations}))
コード例 #12
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_fee_add(request, project):
    project = get_project(request, project, 'is_manager')
    if request.POST:
        form = FeeForm(request.POST)
        if form.is_valid():
            fee = form.save(commit=False)
            fee.project = project
            fee.save()
            message_object_created(request, fee)
            return redirect('bs-fee-list', project=project.pk)
    else:
        form = FeeForm()

    c = {
        'project': project,
        'view_title': Fee.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-fee-list',
        'form': form,
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-fee-add', c))
コード例 #13
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_event_add(request, project):
    project = get_project(request, project, 'manage_dates')
    if request.POST:
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.project = project
            event.save()
            message_object_created(request, event)
            return redirect('bs-event-list', project=project.pk)
    else:
        form = EventForm()

    c = {
        'project': project,
        'view_title': Event.objects.model._meta.verbose_name_plural,
        'view_url_list': 'bs-event-list',
        'form': form,
    }

    return render(request, 'project/form.html',
                  get_context_backstage_project(request, project, 'bs-event-add', c))
コード例 #14
0
ファイル: views.py プロジェクト: omeinusch/Palco
def backstage_role_form(request, project, role):
    project = get_project(request, project, 'manage_roles')
    role = get_object_or_404(Role, pk=role, project=project)

    if request.POST:
        if request.POST.get('delete'):
            message_object_deleted(request, role)
            role.delete()
            message_object_deleted(request, role)
            return redirect('bs-role-list', project=project.pk)

        form_role = RoleForm(request.POST, instance=role)
        form_picture = RolePictureForm(request.POST, request.FILES, instance=role.picture)
        if form_role.is_valid():
            role = form_role.save(commit=False)

            if form_picture.is_valid():
                picture = form_picture.save(commit=False)
                if role.actor:
                    picture.title = _(u'%s als %s' % (role.actor, role.name))
                else:
                    picture.title = role.name
                picture.save()
                role.picture = picture

            role.save()
            message_object_updated(request, role)
            return redirect('bs-role-list', project=project.pk)

    else:
        form_role = RoleForm(instance=role)
        form_picture = RolePictureForm(instance=role.picture)

    return render(request, 'project/role-form.html',
                  get_context_backstage_project(request, project, 'bs-role-form',
                                                {'project': project, 'role': role, 'form_role': form_role,
                                                 'form_picture': form_picture}))
コード例 #15
0
ファイル: views.py プロジェクト: omeinusch/Palco
def dashboard(request, project):
    project = get_project(request, project, 'view_backstage')
    return render(request, 'project/dashboard.html',
                  get_context_backstage_project(request, project, 'bs-dashboard',
                                                {'project': project}))