2016-08-14 18:30:48 +00:00
|
|
|
from szurubooru import errors
|
|
|
|
|
|
|
|
|
|
|
|
def verify_version(entity, context, field_name='version'):
|
|
|
|
actual_version = context.get_param_as_int(field_name, required=True)
|
|
|
|
expected_version = entity.version
|
|
|
|
if actual_version != expected_version:
|
2016-09-10 08:37:28 +00:00
|
|
|
raise errors.IntegrityError(
|
2016-08-14 18:30:48 +00:00
|
|
|
'Someone else modified this in the meantime. ' +
|
|
|
|
'Please try again.')
|
|
|
|
|
|
|
|
|
|
|
|
def bump_version(entity):
|
|
|
|
entity.version = entity.version + 1
|