示例#1
0
def delete_credit(request, production_id, nick_id):
    production = get_object_or_404(Production, id=production_id)
    nick = get_object_or_404(Nick, id=nick_id)
    if request.method == "POST":
        if request.POST.get("yes"):
            credits = Credit.objects.filter(nick=nick, production=production)
            if credits:
                credits.delete()
                production.updated_at = datetime.datetime.now()
                production.has_bonafide_edits = True
                production.save()
                Edit.objects.create(
                    action_type="delete_credit",
                    focus=production,
                    focus2=nick.releaser,
                    description=(u"Deleted %s's credit on %s" % (nick, production)),
                    user=request.user,
                )
        return render_credits_update(request, production)
    else:
        return modal_workflow_confirmation(
            request,
            reverse("production_delete_credit", args=[production_id, nick_id]),
            "Are you sure you want to delete %s's credit from %s?" % (nick.name, production.title),
            html_title="Deleting %s's credit from %s" % (nick.name, production.title),
        )
示例#2
0
def delete_credit(request, production_id, nick_id):
    production = get_object_or_404(Production, id=production_id)
    if not production.editable_by_user(request.user):
        raise PermissionDenied
    nick = get_object_or_404(Nick, id=nick_id)
    if request.method == 'POST':
        if request.POST.get('yes'):
            credits = Credit.objects.filter(nick=nick, production=production)
            if credits:
                credits.delete()
                production.updated_at = datetime.datetime.now()
                production.has_bonafide_edits = True
                production.save()
                Edit.objects.create(
                    action_type='delete_credit', focus=production, focus2=nick.releaser,
                    description=(u"Deleted %s's credit on %s" % (nick, production)), user=request.user
                )
        return render_credits_update(request, production)
    else:
        return modal_workflow_confirmation(
            request,
            reverse('production_delete_credit', args=[production_id, nick_id]),
            "Are you sure you want to delete %s's credit from %s?" % (nick.name, production.title),
            html_title="Deleting %s's credit from %s" % (nick.name, production.title)
        )