def patch_weight(request, thread, value): allow_pin_thread(request.user, thread) if not thread.acl.get('can_pin_globally') and thread.weight == 2: raise PermissionDenied(_("You can't change globally pinned threads weights in this category.")) if value == 2: if thread.acl.get('can_pin_globally'): moderation.pin_thread_globally(request, thread) else: raise PermissionDenied(_("You can't pin threads globally in this category.")) elif value == 1: moderation.pin_thread_locally(request, thread) elif value == 0: moderation.unpin_thread(request, thread) return {'weight': thread.weight}
def patch_weight(request, thread, value): allow_pin_thread(request.user, thread) if not thread.acl.get('can_pin_globally') and thread.weight == 2: raise PermissionDenied(_("You can't change globally pinned threads weights in this category.")) if value == 2: if thread.acl.get('can_pin_globally'): moderation.pin_thread_globally(request, thread) else: raise PermissionDenied(_("You can't pin threads globally in this category.")) elif value == 1: moderation.pin_thread_locally(request, thread) elif value == 0: moderation.unpin_thread(request, thread) return {'weight': thread.weight}