from functools import wraps

from pycs import db

def commit_on_return(method):

	@warps(method)
	def inner(self, *args, commit: bool = True, **kwargs):

		res = method(self, *args, **kwargs)

		if commit:
			db.session.commit()

		return res

	return inner

