gallery.accords-library.com/server/szurubooru/func/versions.py

18 lines
528 B
Python
Raw Normal View History

from szurubooru import errors, rest, model
def verify_version(
entity: model.Base,
context: rest.Context,
2017-04-24 21:30:53 +00:00
field_name: str = 'version') -> None:
actual_version = context.get_param_as_int(field_name)
expected_version = entity.version
if actual_version != expected_version:
raise errors.IntegrityError(
'Someone else modified this in the meantime. ' +
'Please try again.')
def bump_version(entity: model.Base) -> None:
entity.version = entity.version + 1