commit
c55bb5eff2
@ -87,8 +87,11 @@ class RecordVersion(db.Model):
|
|||||||
order_by=id,
|
order_by=id,
|
||||||
cascade='all,delete'))
|
cascade='all,delete'))
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, record=None):
|
||||||
"""Initialize a record version."""
|
"""Initialize a record version."""
|
||||||
|
if record:
|
||||||
|
self.record = record
|
||||||
|
self.record_id = record.id
|
||||||
self.creation_date = datetime.datetime.utcnow()
|
self.creation_date = datetime.datetime.utcnow()
|
||||||
|
|
||||||
def update(self, someData):
|
def update(self, someData):
|
||||||
@ -128,8 +131,11 @@ class Record(db.Model):
|
|||||||
uselist=False,
|
uselist=False,
|
||||||
cascade='save-update, merge, delete, delete-orphan')
|
cascade='save-update, merge, delete, delete-orphan')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, user=None):
|
||||||
"""Initialize a record."""
|
"""Initialize a record."""
|
||||||
|
if user:
|
||||||
|
self.user_id = user.id
|
||||||
|
self.version = 1
|
||||||
self.creation_date = datetime.datetime.utcnow()
|
self.creation_date = datetime.datetime.utcnow()
|
||||||
|
|
||||||
def update(self, data, record_version):
|
def update(self, data, record_version):
|
||||||
@ -139,10 +145,7 @@ class Record(db.Model):
|
|||||||
self.api_version = data['version']
|
self.api_version = data['version']
|
||||||
self.update_date = datetime.datetime.now()
|
self.update_date = datetime.datetime.now()
|
||||||
self.current_record_version = record_version
|
self.current_record_version = record_version
|
||||||
if self.version:
|
self.version += 1
|
||||||
self.version += 1
|
|
||||||
else:
|
|
||||||
self.version = 1
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -140,8 +140,9 @@ def pm():
|
|||||||
"""Main request handler."""
|
"""Main request handler."""
|
||||||
method = request.form['method']
|
method = request.form['method']
|
||||||
if method not in globals():
|
if method not in globals():
|
||||||
|
app.logger.error(method)
|
||||||
raise InvalidUsage('This method is not yet implemented',
|
raise InvalidUsage('This method is not yet implemented',
|
||||||
status_code=501)
|
status_code=501)
|
||||||
handler = globals()[method]()
|
|
||||||
app.logger.debug(method)
|
app.logger.debug(method)
|
||||||
|
handler = globals()[method]()
|
||||||
return handler.handle_request(request)
|
return handler.handle_request(request)
|
||||||
|
@ -3,16 +3,13 @@ import os
|
|||||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
CSRF_ENABLED = True
|
|
||||||
|
|
||||||
|
|
||||||
if os.environ.get('DATABASE_URL') is None:
|
if os.environ.get('DATABASE_URL') is None:
|
||||||
SQLALCHEMY_DATABASE_URI = ('sqlite:///' + os.path.join(basedir, 'app.db') +
|
SQLALCHEMY_DATABASE_URI = ('sqlite:///' + os.path.join(basedir, 'app.db') +
|
||||||
'?check_same_thread=False')
|
'?check_same_thread=False')
|
||||||
else:
|
else:
|
||||||
SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']
|
SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']
|
||||||
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
|
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
|
||||||
SQLALCHEMY_RECRD_QUERIES = True
|
SQLALCHEMY_RECORD_QUERIES = True
|
||||||
|
|
||||||
ADMINS = ['you@example.com']
|
ADMINS = ['you@example.com']
|
||||||
|
|
||||||
@ -20,15 +17,20 @@ ADMINS = ['you@example.com']
|
|||||||
class Config(object):
|
class Config(object):
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TESTING = False
|
TESTING = False
|
||||||
SQLALCHEMY_ECHO = False
|
CSRF_ENABLED = True
|
||||||
WTF_CSRF_ENABLED = True
|
WTF_CSRF_ENABLED = True
|
||||||
SECRET_KEY = 'you-will-never-guess'
|
SECRET_KEY = 'you-will-never-guess'
|
||||||
sessionTimeout = datetime.timedelta(minutes=-2)
|
sessionTimeout = datetime.timedelta(minutes=-2)
|
||||||
|
|
||||||
|
SQLALCHEMY_ECHO = False
|
||||||
|
SQLALCHEMY_DATABASE_URI = SQLALCHEMY_DATABASE_URI
|
||||||
|
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
|
||||||
|
|
||||||
|
|
||||||
class DevelopmentConfig(Config):
|
class DevelopmentConfig(Config):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
SQLALCHEMY_ECHO = True
|
SQLALCHEMY_ECHO = True
|
||||||
|
SQLALCHEMY_RECORD_QUERIES = True
|
||||||
|
|
||||||
|
|
||||||
class TestingConfig(Config):
|
class TestingConfig(Config):
|
||||||
|
Loading…
Reference in New Issue
Block a user