Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_id = FieldProperty(S.ObjectId)
sfx_userid = FieldProperty(S.Deprecated)
username = FieldProperty(str)
email_addresses = FieldProperty([str])
password = FieldProperty(str)
last_password_updated = FieldProperty(datetime)
projects = FieldProperty(S.Deprecated)
# full mount point: prefs dict
tool_preferences = FieldProperty(S.Deprecated)
tool_data = FieldProperty({str: {str: None}}) # entry point: prefs dict
disabled = FieldProperty(bool, if_missing=False)
pending = FieldProperty(bool, if_missing=False)
# Don't use these directly, use get/set_pref() instead
preferences = FieldProperty(dict(
results_per_page=int,
email_address=str,
email_format=str,
disable_user_messages=bool,
mention_notifications=bool,
multifactor=bool,
))
# Additional top-level fields can/should be accessed with get/set_pref also
# Not sure why we didn't put them within the 'preferences' dictionary :(
display_name = FieldPropertyDisplayName(str)
# Personal data
sex = FieldProperty(
S.OneOf('Male', 'Female', 'Other', 'Unknown',
if_missing='Unknown'))
birthdate = FieldProperty(S.DateTime, if_missing=None)
category=S.ObjectId,
messages=[dict(
messagetype=str,
created=int,
modified=int)],
tickets=dict(
solved=int,
assigned=int,
revoked=int,
totsolvingtime=int),
commits=[dict(
lines=int,
number=int,
language=S.ObjectId)])])
lastmonth = FieldProperty(dict(
messages=[dict(
datetime=datetime,
created=bool,
categories=[S.ObjectId],
messagetype=str)],
assignedtickets=[dict(
datetime=datetime,
categories=[S.ObjectId])],
revokedtickets=[dict(
datetime=datetime,
categories=[S.ObjectId])],
solvedtickets=[dict(
datetime=datetime,
categories=[S.ObjectId],
solvingtime=int)],
commits=[dict(
session = main_orm_session
name = 'mailbox'
unique_indexes = [
('user_id', 'project_id', 'app_config_id',
'artifact_index_id', 'topic', 'is_flash'),
]
indexes = [
('project_id', 'artifact_index_id'),
('is_flash', 'user_id'),
('type', 'next_scheduled'), # for q_digest
('type', 'queue_empty'), # for q_direct
# for deliver()
('project_id', 'app_config_id', 'artifact_index_id', 'topic'),
]
_id = FieldProperty(S.ObjectId)
user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
project_id = ForeignIdProperty('Project', if_missing=lambda: c.project._id)
app_config_id = ForeignIdProperty(
'AppConfig', if_missing=lambda: c.app.config._id)
# Subscription filters
artifact_title = FieldProperty(str)
artifact_url = FieldProperty(str)
artifact_index_id = FieldProperty(str)
topic = FieldProperty(str)
# Subscription type
is_flash = FieldProperty(bool, if_missing=False)
type = FieldProperty(S.OneOf('direct', 'digest', 'summary', 'flash'))
frequency = FieldProperty(dict(
n=int, unit=S.OneOf('day', 'week', 'month')))
def cleanup_assocs(self):
old_len = len(self.assocs)
self.assocs = [a for a in self.assocs
if Association.deserialize(a['value']).getExpiresIn() != 0]
new_len = len(self.assocs)
return (old_len - new_len), new_len
class OpenIdNonce(MappedClass):
class __mongometa__:
name = 'oid_store_nonce'
session = main_orm_session
_id = FieldProperty(str) # Nonce value
timestamp = FieldProperty(datetime, if_missing=datetime.utcnow)
class OpenIdStore(object):
def _get_assocs(self, server_url):
assoc = OpenIdAssociation.query.get(_id=server_url)
if assoc is None:
assoc = OpenIdAssociation(_id=server_url)
return assoc
def storeAssociation(self, server_url, association):
assocs = self._get_assocs(server_url)
assocs.set_assoc(deepcopy(association))
def getAssociation(self, server_url, handle=None):
if feed_item:
feed_item.delete()
super(BlogPost, self).delete()
@classmethod
def attachment_class(cls):
return BlogAttachment
class BlogAttachment(M.BaseAttachment):
ArtifactType = BlogPost
thumbnail_size = (100, 100)
class __mongometa__:
polymorphic_identity = 'BlogAttachment'
attachment_type = FieldProperty(str, if_missing='BlogAttachment')
Mapper.compile_all()
skip_last_updated = getattr(_session, 'skip_last_updated', False)
if not skip_mod_date:
data['mod_date'] = datetime.utcnow()
else:
log.debug('Not updating mod_date')
if c.project and not skip_last_updated:
c.project.last_updated = datetime.utcnow()
type_s = 'Generic Artifact'
# Artifact base schema
_id = FieldProperty(S.ObjectId)
mod_date = FieldProperty(datetime, if_missing=datetime.utcnow)
app_config_id = ForeignIdProperty(
'AppConfig', if_missing=lambda: c.app.config._id)
plugin_verson = FieldProperty(S.Deprecated)
tool_version = FieldProperty(S.Deprecated)
acl = FieldProperty(ACL)
tags = FieldProperty(S.Deprecated)
labels = FieldProperty([str])
references = FieldProperty(S.Deprecated)
backreferences = FieldProperty(S.Deprecated)
app_config = RelationProperty('AppConfig')
# Not null if artifact originated from external import. The import ID is
# implementation specific, but should probably be an object indicating
# the source, original ID, and any other info needed to identify where
# the artifact came from. But if you only have one source, a str might do.
import_id = FieldProperty(None, if_missing=None)
deleted = FieldProperty(bool, if_missing=False)
def __json__(self, posts_limit=None, is_export=False):
"""Return a JSON-encodable :class:`dict` representation of this
def subcategories(self):
return self.query.find(dict(parent_id=self._id)).all()
class TroveCategory(MappedClass):
class __mongometa__:
session = main_orm_session
name='trove_category'
indexes = [ 'trove_cat_id', 'trove_parent_id' ]
_id=FieldProperty(S.ObjectId)
trove_cat_id = FieldProperty(int, if_missing=None)
trove_parent_id = FieldProperty(int, if_missing=None)
shortname = FieldProperty(str, if_missing='')
fullname = FieldProperty(str, if_missing='')
fullpath = FieldProperty(str, if_missing='')
parent_only = FieldProperty(bool, if_missing=False)
@property
def parent_category(self):
return self.query.get(trove_cat_id=self.trove_parent_id)
@property
def subcategories(self):
return self.query.find(dict(trove_parent_id=self.trove_cat_id)).sort('fullname').all()
@property
def children(self):
result = []
children = self.query.find(dict(trove_parent_id=self.trove_cat_id)).all()
for child in children:
result.append(child);
result.extend(child.children)
callback = FieldProperty(str)
validation_pin = FieldProperty(str)
consumer_token = RelationProperty('OAuthConsumerToken')
class OAuthAccessToken(OAuthToken):
class __mongometa__:
polymorphic_identity = 'access'
type = FieldProperty(str, if_missing='access')
consumer_token_id = ForeignIdProperty('OAuthConsumerToken')
request_token_id = ForeignIdProperty('OAuthToken')
user_id = AlluraUserProperty(if_missing=lambda: c.user._id)
is_bearer = FieldProperty(bool, if_missing=False)
user = RelationProperty('User')
consumer_token = RelationProperty(
'OAuthConsumerToken', via='consumer_token_id')
request_token = RelationProperty('OAuthToken', via='request_token_id')
@classmethod
def for_user(cls, user=None):
if user is None:
user = c.user
return cls.query.find(dict(user_id=user._id, type='access')).all()
def can_import_forum(self):
tokens = aslist(config.get('oauth.can_import_forum', ''), ',')
if self.api_key in tokens:
return True
from ming.orm import Mapper
from ming.orm import FieldProperty, ForeignIdProperty
from allura.lib.helpers import push_config
from allura.model import Artifact
log = logging.getLogger(__name__)
class PortalConfig(Artifact):
class __mongometa__:
name='portal_config'
type_s = 'Project Portal Configuration'
_id = FieldProperty(schema.ObjectId)
user_id = ForeignIdProperty('User')
layout_class = FieldProperty(str)
layout = FieldProperty([
{'name':str,
'content':[
{'mount_point':str,
'widget_name':str }
]
}])
@classmethod
def current(cls):
result = cls.query.get(user_id=c.user._id)
if result is None:
result = cls(user_id=c.user._id,
layout_class='onecol',
layout=[dict(name='content',
content=[dict(mount_point='home',
parent_id = FieldProperty(S.ObjectId, if_missing=None)
neighborhood_id = ForeignIdProperty(Neighborhood)
shortname = FieldProperty(str)
name=FieldProperty(str)
notifications_disabled = FieldProperty(bool)
suppress_emails = FieldProperty(bool)
show_download_button=FieldProperty(S.Deprecated)
short_description=FieldProperty(str, if_missing='')
summary=FieldProperty(str, if_missing='')
description=FieldProperty(str, if_missing='')
homepage_title=FieldProperty(str, if_missing='')
external_homepage=FieldProperty(str, if_missing='')
support_page=FieldProperty(str, if_missing='')
support_page_url=FieldProperty(str, if_missing='')
removal=FieldProperty(str, if_missing='')
moved_to_url=FieldProperty(str, if_missing='')
removal_changed_date = FieldProperty(datetime, if_missing=datetime.utcnow)
export_controlled=FieldProperty(bool, if_missing=False)
database=FieldProperty(S.Deprecated)
database_uri=FieldProperty(str)
is_root=FieldProperty(bool)
acl = FieldProperty(ACL(permissions=_perms_init))
neighborhood_invitations=FieldProperty([S.ObjectId])
neighborhood = RelationProperty(Neighborhood)
app_configs = RelationProperty('AppConfig')
category_id = FieldProperty(S.ObjectId, if_missing=None)
deleted = FieldProperty(bool, if_missing=False)
labels = FieldProperty([str])
last_updated = FieldProperty(datetime, if_missing=None)
tool_data = FieldProperty({str:{str:None}}) # entry point: prefs dict
ordinal = FieldProperty(int, if_missing=0)
database_configured = FieldProperty(bool, if_missing=True)