Ejemplo n.º 1
0
def delete_warning(request, user, warning):
    request.acl.warnings.allow_delete_warning()

    if user.is_warning_active(warning):
        alerts.your_warn_has_been_canceled(request.user, user)
        user.decrease_warning_level()
    warning.delete()

    messages.success(request, _("Selected warning has been deleted."))
Ejemplo n.º 2
0
def cancel_warning(request, user, warning):
    request.acl.warnings.allow_cancel_warning(
        request.user, user, warning)

    user.decrease_warning_level()
    warning.canceled = True
    warning.canceled_on = timezone.now()
    warning.canceler = request.user
    warning.canceler_username = request.user.username
    warning.canceler_slug = request.user.username_slug
    warning.canceler_ip = request.session.get_ip(request)
    warning.canceler_agent = request.META.get('HTTP_USER_AGENT')
    warning.save(force_update=True)

    alerts.your_warn_has_been_canceled(request.user, user)
    messages.success(request, _("Selected warning has been canceled."))