class BMingModel(MappedClass): class __mongometa__: session = ming_session name = "bmodel" _id = s.ObjectId() value = s.String()
def __init__(self, permissions, **kwargs): if permissions is None: permission = S.String() else: permission = S.OneOf('*', *permissions) super(ACE, self).__init__(fields=dict(access=S.OneOf(self.ALLOW, self.DENY), role_id=S.ObjectId(), permission=permission), **kwargs)
class Login(MappedClass): class __mongometa__: session = MingSession name = "logins" _id = s.ObjectId() id = s.Int() device_id = s.Int() datetime = s.DateTime() def __str__(self): return f"<Login(mongo) device_id={self.device_id} datetime={self.datetime}>"
def filesystem(*args, **kwargs): fields, indexes, collection_name, bases, session = _process_collection_args( args, kwargs) field_index = dict((f.name, f) for f in fields) field_index.setdefault('filename', Field('filename', str, index=True)) field_index.setdefault('content_type', Field('contentType', str, index=True)) field_index.setdefault('_id', Field('_id', S.ObjectId())) field_index.setdefault('chunkSize', Field('chunkSize', int)) field_index.setdefault('length', Field('length', int)) field_index.setdefault('md5', Field('md5', str)) field_index.setdefault('uploadDate', Field('uploadDate', datetime)) dct = dict((k, _FieldDescriptor(f)) for k, f in field_index.items()) cls = type('Filesystem<%s>' % collection_name, bases, dct) fields = field_index.values() m = _FSClassManager(cls, collection_name, session, fields, indexes, **kwargs) cls.m = _ManagerDescriptor(m) return cls
for role in self.query.find({'_id': checking}).all(): if role not in found_roles: found_roles.append(role) to_check = to_check + role.roles return found_roles def users_with_role(self, project=None): if not project: project = c.project return self.query.find(dict(project_id=project._id, user_id={'$ne': None}, roles=self._id)).all() audit_log = collection( str('audit_log'), main_doc_session, Field('_id', S.ObjectId()), Field('project_id', S.ObjectId, if_missing=None, index=True), # main view of audit log queries by project_id Field('user_id', S.ObjectId, if_missing=None, index=True), Field('timestamp', datetime, if_missing=datetime.utcnow), Field('url', str), Field('message', str)) class AuditLog(object): @property def timestamp_str(self): return self.timestamp.strftime('%Y-%m-%d %H:%M:%S') @property def message_html(self):
'.phtml', '.txt', '.bat', '.ps1', '.xhtml', '.css', '.cfm', '.jsp', '.jspx', '.pl', '.php4', '.php3', '.rhtml', '.svg', '.markdown', '.json', '.ini', '.tcl', '.vbs', '.xsl' ] DIFF_SIMILARITY_THRESHOLD = .5 # used for determining file renames # Basic commit information # One of these for each commit in the physical repo on disk. The _id is the # hexsha of the commit (for Git and Hg). CommitDoc = collection('repo_ci', main_doc_session, Field('_id', str), Field('tree_id', str), Field('committed', SUser), Field('authored', SUser), Field('message', str), Field('parent_ids', [str], index=True), Field('child_ids', [str], index=True), Field('repo_ids', [S.ObjectId()], index=True)) # Basic tree information (also see TreesDoc) TreeDoc = collection( 'repo_tree', main_doc_session, Field('_id', str), Field('tree_ids', [dict(name=str, id=str)]), Field('blob_ids', [dict(name=str, id=str)]), Field('other_ids', [dict(name=str, id=str, type=SObjType)])) LastCommitDoc_old = collection( 'repo_last_commit', project_doc_session, Field('_id', str), Field('object_id', str, index=True), Field('name', str), Field( 'commit_info', dict(id=str, date=datetime,
from .session import main_doc_session, main_orm_session from .project import Project import six log = logging.getLogger(__name__) # Collection definitions ArtifactReferenceDoc = collection( str('artifact_reference'), main_doc_session, Field('_id', str), Field( 'artifact_reference', dict(cls=S.Binary(), project_id=S.ObjectId(), app_config_id=S.ObjectId(), artifact_id=S.Anything(if_missing=None))), Field('references', [str], index=True), Index('artifact_reference.project_id'), # used in ReindexCommand ) ShortlinkDoc = collection( str('shortlink'), main_doc_session, Field('_id', S.ObjectId()), # index needed for from_artifact() and index_tasks.py:del_artifacts Field('ref_id', str, index=True), Field('project_id', S.ObjectId()), Field('app_config_id', S.ObjectId()), Field('link', str),
VIEWABLE_EXTENSIONS = [ '.php', '.py', '.js', '.java', '.html', '.htm', '.yaml', '.sh', '.rb', '.phtml', '.txt', '.bat', '.ps1', '.xhtml', '.css', '.cfm', '.jsp', '.jspx', '.pl', '.php4', '.php3', '.rhtml', '.svg', '.markdown', '.json', '.ini', '.tcl', '.vbs', '.xsl' ] # Basic commit information # One of these for each commit in the physical repo on disk. The _id is the # hexsha of the commit (for Git and Hg). CommitDoc = collection('repo_ci', main_doc_session, Field('_id', str), Field('tree_id', str), Field('committed', SUser), Field('authored', SUser), Field('message', str), Field('parent_ids', [str], index=True), Field('child_ids', [str], index=True), Field('repo_ids', [S.ObjectId()], index=True)) # Basic tree information (also see TreesDoc) TreeDoc = collection( 'repo_tree', main_doc_session, Field('_id', str), Field('tree_ids', [dict(name=str, id=str)]), Field('blob_ids', [dict(name=str, id=str)]), Field('other_ids', [dict(name=str, id=str, type=SObjType)])) # Information about the last commit to touch a tree/blob # LastCommitDoc.object_id = TreeDoc._id LastCommitDoc = collection( 'repo_last_commit', project_doc_session, Field('_id', str), Field('object_id', str, index=True), Field( 'commit_info',