Example #1
0
def lock(obj, user, steal=False):
    """
    Locks the object for the user. If it is already locked and "steal" is not
    activated, a "LockExistsException" is thrown.
    """
    if not steal:
        assert_no_lock_exists(obj, user)
    unlock(obj)
    content_type_id = ContentType.objects.get_for_model(obj).pk
    Lock(
        user = user,
        until = time.time() + ADMIN_LOCKING['lock_duration'],
        content_type_id = content_type_id,
        object_id = obj.pk,
    ).save()
 def assertions(obj, request):
     assert_no_lock_exists(obj, request.user)
     load_time = request.POST['admin_locking_page_load_time']
     assert_object_not_changed_since(obj, load_time)