Ejemplo n.º 1
0
def edit_blurb(request, production_id, blurb_id):
    production = get_object_or_404(Production, id=production_id)
    if not request.user.is_staff:
        return HttpResponseRedirect(production.get_absolute_url())
    blurb = get_object_or_404(ProductionBlurb, production=production, id=blurb_id)

    if request.POST:
        form = ProductionBlurbForm(request.POST, instance=blurb)
        if form.is_valid():
            form.save()
            Edit.objects.create(
                action_type="edit_production_blurb",
                focus=production,
                description="Edited blurb",
                user=request.user,
                admin_only=True,
            )
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = ProductionBlurbForm(instance=blurb)

    return render(
        request,
        "productions/edit_blurb_form.html",
        {
            "form": form,
            "production": production,
            "blurb": blurb,
            "action_url": reverse("production_edit_blurb", args=[production.id, blurb.id]),
        },
    )
Ejemplo n.º 2
0
def add_blurb(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    if not request.user.is_staff:
        return HttpResponseRedirect(production.get_absolute_url())

    blurb = ProductionBlurb(production=production)
    if request.POST:
        form = ProductionBlurbForm(request.POST, instance=blurb)
        if form.is_valid():
            form.save()
            production.has_bonafide_edits = True
            production.save()
            Edit.objects.create(
                action_type='add_production_blurb', focus=production,
                description="Added blurb", user=request.user, admin_only=True
            )
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = ProductionBlurbForm(instance=blurb)

    return render(request, 'shared/simple_form.html', {
        'form': form,
        'title': 'Adding blurb for %s:' % production.title,
        'html_title': 'Adding blurb for %s' % production.title,
        'action_url': reverse('production_add_blurb', args=[production.id]),
    })
Ejemplo n.º 3
0
def add_blurb(request, production_id):
    production = get_object_or_404(Production, id=production_id)
    if not request.user.is_staff:
        return HttpResponseRedirect(production.get_absolute_url())

    blurb = ProductionBlurb(production=production)
    if request.POST:
        form = ProductionBlurbForm(request.POST, instance=blurb)
        if form.is_valid():
            form.save()
            production.has_bonafide_edits = True
            production.save()
            Edit.objects.create(
                action_type="add_production_blurb",
                focus=production,
                description="Added blurb",
                user=request.user,
                admin_only=True,
            )
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = ProductionBlurbForm(instance=blurb)

    return render(
        request,
        "shared/simple_form.html",
        {
            "form": form,
            "title": "Adding blurb for %s:" % production.title,
            "html_title": "Adding blurb for %s" % production.title,
            "action_url": reverse("production_add_blurb", args=[production.id]),
        },
    )
Ejemplo n.º 4
0
def edit_blurb(request, production_id, blurb_id):
    production = get_object_or_404(Production, id=production_id)
    if not request.user.is_staff:
        return HttpResponseRedirect(production.get_absolute_url())
    blurb = get_object_or_404(ProductionBlurb,
                              production=production,
                              id=blurb_id)

    if request.POST:
        form = ProductionBlurbForm(request.POST, instance=blurb)
        if form.is_valid():
            form.save()
            Edit.objects.create(action_type='edit_production_blurb',
                                focus=production,
                                description="Edited blurb",
                                user=request.user,
                                admin_only=True)
            return HttpResponseRedirect(production.get_absolute_url())
    else:
        form = ProductionBlurbForm(instance=blurb)

    return render(
        request, 'productions/edit_blurb_form.html', {
            'form':
            form,
            'production':
            production,
            'blurb':
            blurb,
            'action_url':
            reverse('production_edit_blurb', args=[production.id, blurb.id]),
        })