2015-09-16 19:34:20 +00:00
|
|
|
from data.database import db, db_transaction
|
2015-07-15 21:25:41 +00:00
|
|
|
|
|
|
|
|
2015-07-06 19:00:07 +00:00
|
|
|
class DataModelException(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-07-18 22:20:00 +00:00
|
|
|
class InvalidLabelKeyException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidMediaTypeException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-07-15 21:25:41 +00:00
|
|
|
class BlobDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2016-07-18 22:20:00 +00:00
|
|
|
|
2015-12-31 19:09:50 +00:00
|
|
|
class TorrentInfoDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2015-07-15 21:25:41 +00:00
|
|
|
|
2015-08-12 20:39:32 +00:00
|
|
|
class InvalidBlobUpload(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-07-15 21:25:41 +00:00
|
|
|
class InvalidEmailAddressException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidOrganizationException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidPasswordException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidRobotException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidUsernameException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidRepositoryBuildException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidBuildTriggerException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTokenException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidNotificationException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidImageException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class UserAlreadyInTeam(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTeamException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTeamMemberException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-08-12 20:39:32 +00:00
|
|
|
class InvalidManifestException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-03-16 19:49:25 +00:00
|
|
|
class ServiceKeyDoesNotExist(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-03-23 22:16:03 +00:00
|
|
|
class ServiceKeyAlreadyApproved(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-04-14 20:56:15 +00:00
|
|
|
class ServiceNameInvalid(DataModelException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-08-29 15:58:18 +00:00
|
|
|
class TagAlreadyCreatedException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2017-02-21 17:51:39 +00:00
|
|
|
class StaleTagException(DataModelException):
|
|
|
|
pass
|
|
|
|
|
2016-08-29 15:58:18 +00:00
|
|
|
|
2015-07-15 21:25:41 +00:00
|
|
|
class TooManyLoginAttemptsException(Exception):
|
|
|
|
def __init__(self, message, retry_after):
|
|
|
|
super(TooManyLoginAttemptsException, self).__init__(message)
|
|
|
|
self.retry_after = retry_after
|
|
|
|
|
|
|
|
|
2015-07-06 19:00:07 +00:00
|
|
|
class Config(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.app_config = None
|
|
|
|
self.store = None
|
2016-12-22 19:27:42 +00:00
|
|
|
self.image_cleanup_callbacks = []
|
|
|
|
|
|
|
|
def register_image_cleanup_callback(self, callback):
|
|
|
|
self.image_cleanup_callbacks.append(callback)
|
2015-07-06 19:00:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
config = Config()
|
|
|
|
|
|
|
|
|
2015-07-15 21:25:41 +00:00
|
|
|
# There MUST NOT be any circular dependencies between these subsections. If there are fix it by
|
|
|
|
# moving the minimal number of things to _basequery
|
2016-07-18 22:20:00 +00:00
|
|
|
from data.model import (
|
|
|
|
blob,
|
|
|
|
build,
|
|
|
|
image,
|
|
|
|
label,
|
|
|
|
log,
|
2016-10-07 19:56:58 +00:00
|
|
|
message,
|
2016-07-18 22:20:00 +00:00
|
|
|
modelutil,
|
|
|
|
notification,
|
|
|
|
oauth,
|
|
|
|
organization,
|
|
|
|
permission,
|
2017-03-17 17:51:45 +00:00
|
|
|
repositoryactioncount,
|
2016-07-18 22:20:00 +00:00
|
|
|
release,
|
|
|
|
repository,
|
|
|
|
service_keys,
|
|
|
|
storage,
|
|
|
|
tag,
|
|
|
|
team,
|
|
|
|
token,
|
|
|
|
user,
|
|
|
|
)
|