예제 #1
0
class Watcher(Base):
    __tablename__ = 'watcher'
    id = Column(Integer, primary_key=True)
    email = Column(String, nullable=False)
예제 #2
0
class BiometricMixin(object):
	# Biodata
	blood_group = Column(String(3))
	striking_features = Column(Text)
	height_m = Column(Float, nullable=True)
	weight_kg = Column(Float, nullable=True)
	eye_colour = Column(String(20))
	hair_colour = Column(String(20))
	complexion = Column(String(50))
	religion = Column(String(20))
	ethnicity = Column(String(40))
	
	# Biometrics
	fp_lthumb = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_left2 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_left3 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_left4 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_left5 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_rthumb = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_right2 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_right3 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_right4 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	fp_right5 = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	palm_left = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	palm_right = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	eye_left = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	eye_right = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
예제 #3
0
class ParentageMixin(object):
	# Mother
	m_prn = Column(String(6), index=True)
	m_firstname = Column(String(40), nullable=True)
	m_surname = Column(String(40), nullable=True)
	m_othernames = Column(String(100))
	m_nat_id_num = Column(String(15), index=True)
	m_education = Column(String(40))
	m_occupation = Column(String(40))
	m_income = Column(String(50))
	
	# Father
	f_prn = Column(String(6), index=True)
	f_firstname = Column(String(40), nullable=True)
	f_surname = Column(String(40), nullable=True)
	f_othernames = Column(String(100))
	f_nat_id_num = Column(String(15), index=True)
	f_education = Column(String(40))
	f_occupation = Column(String(40))
	f_income = Column(String(50))
예제 #4
0
class ActivityMixin(object):
	priority = Column(Integer)
	segment = Column(Integer)
	task_group = Column(Integer)
	
	action = Column(String(40))
	activity_description = Column(Text)
	goal = Column(Text)
	status = Column(String(40))
	actual_start = Column(Date, default=func.now())
	planned_start = Column(Date, default=func.now())
	start_notes = Column(String(100))
	
	planned_end = Column(Date, default=func.now())
	actual_end = Column(DateTime, nullable=True, default=func.now())
	end_notes = Column(String(100))
	
	deadline = Column(Date, default=func.now())
	# Admin Stuff
	not_started = Column(Boolean, default=True)
	delayed_start =  Column(Boolean, default=False)
	completed = Column(Boolean, default=False)
	delayed_end =  Column(Boolean, default=False)
	deviation_expected = Column(Boolean, default=False)
	
	contingency_plan = Column(Text)
	
	# Money
	budget = Column(Numeric(10,2), default=0.00)
	spend_td = Column(Numeric(10,2), default=0.00)
	balance_avail = Column(Numeric(10,2), default=0.00)
	over_budget = Column(Boolean, default=False)
	under_budget =Column(Boolean, default=False)
	
	CheckConstraint('actual_start >= actual_end')
	
	@renders('actual_start')
	def started(self):
		s = humanize.naturaltime(datetime.now() - self.actual_start)
		return Markup('<span class="no-wrap">Start: {}</span>'.format(s))
	
	@renders('delayed')
	def delayed(self):
		s = humanize.naturaltime(datetime.now() - self.planned_end)
		return Markup('<span class="no-wrap"> Delayed by: {}</span>'.format(s))
	
	@renders('duration')
	def lasted(self):
		dur = humanize.naturaltime(self.actual_end - self.actual_start)
		return Markup('<span class="no-wrap">Lasted: {}</span>'.format(dur))
		
	
	def __repr__(self):
		return str(self.action) + ' ' + str(self.actual_start)
예제 #5
0
class PersonDocMixin(object):
	# Birth Certificate
	bc_id = Column(String(20), index=True, unique=True, nullable=True)
	bc_number = Column(String(20), index=True)
	bc_serial = Column(String(20), index=True)
	bc_place = Column(String(20), index=True)
	bc_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# NationalID
	citizenship = Column(String(20), default='Kenyan')
	nat_id_num = Column(String(15), index=True, unique=True)
	nat_id_serial = Column(String(30), index=True)
	nat_id_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	
	# Passport
	pp_no = Column(String(20), index=True)
	pp_issue_date = Column(Date)
	pp_issue_place = Column(String(40))
	pp_scan = Column(ImageColumn(thumbnail_size=(30, 60, True), size=(300, 600, True)))
	pp_expiry_date = Column(Date)
예제 #6
0
class ForumThread(Model):
    __tablename__ = 'ForumThread'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    type = Column(Enum('QUESTION', 'DISCUSSION'))
    typeConfirmed = Column(Boolean)
    typeConfirmedBy_id = Column(Integer, ForeignKey('User.id'))
    typeConfirmedDate = Column(DateTime)
    category_id = Column(Integer, ForeignKey('ForumCategory.id'))
    language = Column(String(length=2))
    transcription = Column(String(length=255))
    threadType = Column(
        Enum('FORUM', 'FIRST_AID', 'APP_QUESTION', 'APP_QUESTION_PARENT'))
    firstAidPostedBy_id = Column(Integer, ForeignKey('User.id'))
    firstPost_id = Column(Integer, ForeignKey('ForumPost.id'))
    lastPost_id = Column(Integer, ForeignKey('ForumPost.id'))
    createdBy_id = Column(Integer, ForeignKey('User.id'))
    creationDate = Column(DateTime)
    modificationDate = Column(DateTime)
    stickiness = Column(Integer)
    answered = Column(Boolean)
    closed = Column(Boolean)
    relatedThreads = Column(String(length=255))
    relatedThreadsLastUpdate = Column(DateTime)

    posts = relationship(
        'ForumPost', back_populates='thread', primaryjoin="and_(ForumThread.id==ForumPost.thread_id)")
    firstPost = relationship('ForumPost', foreign_keys=[firstPost_id])
    lastPost = relationship('ForumPost', foreign_keys=[lastPost_id])
    category = relationship('ForumCategory', foreign_keys=[
                            category_id], back_populates='threads')

    subscriptions = relationship(
        'ForumThreadUserSubscription', back_populates='thread')
class city(Base):
    """definition of city class"""
    __tablename__ = 'cities'
    id = Column(Integer, primary_key=True)
    name = Column(String(128), nullable=False)
    state_id = Column(Integer, ForeignKey('states.id'))
예제 #8
0
파일: database.py 프로젝트: yqyunjie/viper
from viper.common.out import print_warning, print_error, print_success
from viper.common.exceptions import Python2UnsupportedUnicode
from viper.common.objects import File
from viper.core.storage import get_sample_path, store_sample
from viper.core.project import __project__
from viper.core.config import __config__

log = logging.getLogger('viper')

cfg = __config__

Base = declarative_base()

association_table = Table(
    'association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag.id')),
    Column('note_id', Integer, ForeignKey('note.id')),
    Column('malware_id', Integer, ForeignKey('malware.id')),
    Column('analysis_id', Integer, ForeignKey('analysis.id')))


class Malware(Base):
    __tablename__ = 'malware'

    id = Column(Integer(), primary_key=True)
    name = Column(String(255), nullable=True)
    size = Column(Integer(), nullable=False)
    type = Column(Text(), nullable=True)
    mime = Column(String(255), nullable=True)
    md5 = Column(String(32), nullable=False, index=True)
    crc32 = Column(String(8), nullable=False)
예제 #9
0
파일: database.py 프로젝트: yqyunjie/viper
class Malware(Base):
    __tablename__ = 'malware'

    id = Column(Integer(), primary_key=True)
    name = Column(String(255), nullable=True)
    size = Column(Integer(), nullable=False)
    type = Column(Text(), nullable=True)
    mime = Column(String(255), nullable=True)
    md5 = Column(String(32), nullable=False, index=True)
    crc32 = Column(String(8), nullable=False)
    sha1 = Column(String(40), nullable=False)
    sha256 = Column(String(64), nullable=False, index=True)
    sha512 = Column(String(128), nullable=False)
    ssdeep = Column(String(255), nullable=True)
    created_at = Column(DateTime(timezone=False),
                        default=datetime.now(),
                        nullable=False)
    parent_id = Column(Integer(), ForeignKey('malware.id'))
    parent = relationship('Malware', lazy='subquery', remote_side=[id])
    tag = relationship('Tag',
                       secondary=association_table,
                       backref=backref('malware'))
    note = relationship('Note',
                        cascade='all, delete',
                        secondary=association_table,
                        backref=backref('malware'))
    analysis = relationship('Analysis',
                            cascade='all, delete',
                            secondary=association_table,
                            backref=backref('malware'))
    __table_args__ = (Index('hash_index',
                            'md5',
                            'crc32',
                            'sha1',
                            'sha256',
                            'sha512',
                            unique=True), )

    def to_dict(self):
        row_dict = {}
        for column in self.__table__.columns:
            value = getattr(self, column.name)
            row_dict[column.name] = value

        return row_dict

    def __repr__(self):
        return "<Malware ('{0}','{1}')>".format(self.id, self.md5)

    def __init__(self,
                 md5,
                 crc32,
                 sha1,
                 sha256,
                 sha512,
                 size,
                 type=None,
                 mime=None,
                 ssdeep=None,
                 name=None,
                 parent=None):
        self.md5 = md5
        self.sha1 = sha1
        self.crc32 = crc32
        self.sha256 = sha256
        self.sha512 = sha512
        self.size = size
        self.type = type
        self.mime = mime
        self.ssdeep = ssdeep
        self.name = name
        self.parent = parent
예제 #10
0
class Progress(Base):
    __tablename__ = "progress"

    id = Column(Text, primary_key=True, autoincrement=False)
    value = Column(Integer)
예제 #11
0
class Repository(Base):
    __tablename__ = "repository"

    id = Column(Integer, primary_key=True, autoincrement=False)
    organization_id = Column(Integer, ForeignKey('organization.id'))
    name = Column(Text)
    fork = Column(Text)
    push_date = Column(DateTime)
    created_date = Column(DateTime)
    language = Column(Text)
    license = Column(Text)
    forks_count = Column(Integer)
    stargazers_count = Column(Integer)
    network_count = Column(Integer)
    watchers_count = Column(Integer)
    source_government = Column(Boolean)
    source_civic = Column(Boolean)
    source_owner_id = Column(Integer)
    source_owner_login = Column(Text)
    source_repository_id = Column(Integer)
    source_repository_name = Column(Text)
    contributors = relationship("Person", secondary=person_repository_contributor, backref="contributor_repositories")
예제 #12
0
from sqlalchemy import Table, Column, Boolean, DateTime, Integer, Text, ForeignKey
from sqlalchemy.orm import relationship
from db import Base

person_organization_member = Table('person_organization_member_association', Base.metadata,
    Column('person_id', Integer, ForeignKey('person.id')),
    Column('organization_id', Integer, ForeignKey('organization.id')),
)

person_organization_contributor = Table('person_organization_contributor_association', Base.metadata,
    Column('person_id', Integer, ForeignKey('person.id')),
    Column('organization_id', Integer, ForeignKey('organization.id')),
)

person_repository_contributor = Table('person_repository_contributor_association', Base.metadata,
    Column('person_id', Integer, ForeignKey('person.id')),
    Column('repository_id', Integer, ForeignKey('repository.id')),
)


class Progress(Base):
    __tablename__ = "progress"

    id = Column(Text, primary_key=True, autoincrement=False)
    value = Column(Integer)


class Organization(Base):
    __tablename__ = "organization"

    id = Column(Integer, primary_key=True, autoincrement=False)
예제 #13
0
class NodeWatcher(Base):
    __tablename__ = 'node_watcher'
    id = Column(Integer, primary_key=True)
    node_id = Column(Integer)
    watcher_id = Column(Integer)
예제 #14
0
class Node(Base):
    __tablename__ = 'node'
    id = Column(Integer, primary_key=True)
    url = Column(String, nullable=False)
예제 #15
0
class ForumCategory(Model):
    __tablename__ = 'ForumCategory'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    language = Column(String(length=2))
    pos = Column(Integer)
    transcription_language = Column(String(length=2))
    transcription_transcription = Column(String(length=255))
    parentCategory_id = Column(Integer, ForeignKey('ForumCategory.id'))
    name = Column(String(length=255))
    nameForNavigation = Column(String(length=255))
    description = Column(Text)
    creationDate = Column(DateTime)
    modificationDate = Column(DateTime)
    deletionDate = Column(DateTime)
    deleted = Column(Boolean)

    createdBy_id = Column(Integer, ForeignKey('User.id'))
    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    deletedBy_id = Column(Integer, ForeignKey('User.id'))
    image_id = Column(Integer, ForeignKey('ForumCategoryImage.id'))

    createdBy = relationship('User', foreign_keys=[createdBy_id])
    modifiedBy = relationship('User', foreign_keys=[modifiedBy_id])
    deletedBy = relationship('User', foreign_keys=[deletedBy_id])
    transcription = relationship(
        'ForumCategoryTranscription', back_populates='forumCategory')

    image = relationship('ForumCategoryImage', foreign_keys=[image_id])

    posts = relationship('ForumPost', back_populates='category')
    threads = relationship('ForumThread', back_populates='category')
    children = relationship('ForumCategory', foreign_keys=[
        parentCategory_id], back_populates='parent')
    parent = relationship('ForumCategory', remote_side=[
        id], back_populates='children', uselist=False)

    subscriptions = relationship(
        'ForumCategoryUserSubscription', back_populates='category')

    progresses = relationship('ForumUserCategoryProgress',
                              primaryjoin="and_(ForumCategory.id==ForumUserCategoryProgress.category_id)")

    def __repr__(self):
        return "<ForumCategory(id='%s', name='%s', nameForNavigation='%s')>" % (self.id, self.name, self.nameForNavigation)
예제 #16
0
class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    email = Column(String(255), nullable=False)
    password = Column(String(64))
    is_admin = Column(Boolean(), default=False, nullable=False)
    deleted = Column(Boolean(), default=False, nullable=False)
    created_at = Column(DateTime, default=datetime.datetime.utcnow)

    # ------------------------------------------------------------------------
    # FIND / CREATE
    # ------------------------------------------------------------------------

    @staticmethod
    def find_by_email(email):
        return db.query(User).filter_by(email=email, deleted=False).first()

    @staticmethod
    def create(**kwargs):
        """Create and return a user.
        Pass in password as 'passwd'
        Returns:
            User object on success.
            False if email is taken.
        """
        if User.find_by_email(kwargs['email']):
            return False

        u = User(**kwargs)
        db.add(u)
        db.commit()
        return u

    @staticmethod
    def login(email, password):
        """Tries to log in a user

        Args:
            email_or_username: obvi.
            password: plaintext plaintext password

        Returns:
            User object if login succeeded
            False if login failed
        """
        ret = False
        bcrypt = Bcrypt()
        user = User.find_by_email(email)
        if user and bcrypt.check_password_hash(user.password, password):
            ret = user
        return ret

    # ------------------------------------------------------------------------
    # PASSWORD
    # ------------------------------------------------------------------------

    @property
    def passwd(self):
        return self.password

    @passwd.setter
    def passwd(self, value=None):
        bcrypt = Bcrypt()
        password = bcrypt.generate_password_hash(value)
        self.password = password
예제 #17
0
class ForumPost(Model):
    __tablename__ = 'ForumPost'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    thread_id = Column(Integer, ForeignKey('ForumThread.id'))
    category_id = Column(Integer, ForeignKey('ForumCategory.id'))
    language = Column(String(length=2))
    author_id = Column(Integer, ForeignKey('User.id'))
    title = Column(String(length=255))
    content = Column(Text)
    contentAsHtml = Column(Text)
    tags = Column(Text)
    parentPost_id = Column(Integer, ForeignKey('ForumPost.id'))

    createdBy_id = Column(Integer, ForeignKey('User.id'))
    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    deletedBy_id = Column(Integer, ForeignKey('User.id'))

    creationDate = Column(DateTime)
    modificationDate = Column(DateTime)
    deletionDate = Column(DateTime)

    deleted = Column(Boolean)
    reportedAsSpam = Column(Boolean)
    reported = Column(Boolean)
    reportedBy_id = Column(Integer, ForeignKey('User.id'))
    reportedDate = Column(DateTime)
    reportedReason = Column(String(length=255))
    reportedComment = Column(Text)

    category = relationship('ForumCategory', back_populates='posts')
    author = relationship('User', foreign_keys=[author_id])
    createdBy = relationship('User', foreign_keys=[createdBy_id])
    modifiedBy = relationship('User', foreign_keys=[modifiedBy_id])
    deletedBy = relationship('User', foreign_keys=[deletedBy_id])
    reportedBy = relationship('User', foreign_keys=[reportedBy_id])
    ratings = relationship('ForumPostRating', back_populates='post')

    thread = relationship(
        'ForumThread', back_populates='posts', foreign_keys=[thread_id])
    parent = relationship('ForumPost', foreign_keys=[
                          parentPost_id], back_populates='children')
    children = relationship('ForumPost', remote_side=[
                            id], back_populates='parent')
class Twiiter_sentiment(Base):
    __tablename__ = 'twitter_sentiment_data'

    id = Column(UUID, default=lambda: str(uuid.uuid4()), primary_key=True)
    search_query = Column(String)
    twitter_id = Column(String)
    tweet_original = Column(String)
    tweet_translated = Column(String)
    lang = Column(String)
    created_at = Column(DateTime, nullable=False)
    geo = Column(String)
    reply_count = Column(Integer)
    retweet_count = Column(Integer)
    likes_count = Column(Integer)

    user_id = Column(String)
    user_name = Column(String)
    user_location = Column(String)
    user_description = Column(String)
    user_verified = Column(Boolean)
    user_followers_count = Column(Integer)
    user_friends_count = Column(Integer)

    polarity = Column(Float)
    subjectivity = Column(Float)

    def __init__(self, search_query,twitter_id, tweet_original, tweet_translated,
                 lang, created_at, geo, reply_count,retweet_count, likes_count,
                 user_id, user_name, user_location, user_description,user_verified,
                 user_followers_count, user_friends_count, polarity, subjectivity,
                 ):
        self.search_query = search_query
        self.twitter_id = twitter_id
        self.tweet_original = tweet_original
        self.tweet_translated = tweet_translated
        self.lang = lang
        self.created_at = created_at
        self.geo = geo
        self.reply_count = reply_count
        self.retweet_count = retweet_count
        self.likes_count = likes_count

        self.user_id = user_id
        self.user_name = user_name
        self.user_location = user_location
        self.user_description = user_description
        self.user_verified = user_verified
        self.user_followers_count = user_followers_count
        self.user_friends_count = user_friends_count

        self.polarity = polarity
        self.subjectivity = subjectivity
예제 #19
0
class UserEvent(Model):
    __tablename__ = 'UserEvent'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    user_id = Column(Integer, ForeignKey('User.id'))
    event = Column(Enum('NEWSLETTER_REGISTRATION', 'DAILY_LOGIN', 'CREATE_POST', 'CREATE_APP_TALK', 'CREATE_COMMENT', 'RECEIVE_LIKE',
                        'RECEIVE_BEST_ANSWER', 'CUSTOM_MODERATOR', 'LEVEL_UP', 'LEVEL_DOWN', 'LEVEL_UP_MODERATOR', 'LEVEL_DOWN_MODERATOR'))
    forumPost_id = Column(Integer)  # TODO: relation
    articleComment_id = Column(Integer, ForeignKey('ArticleComment.id'))
    description = Column(String(length=255))
    awardedBy_id = Column(Integer, ForeignKey('User.id'))
    creationDate = Column(DateTime)
    revocation_id = Column(Integer)
    revokedEvent_id = Column(Integer)
    revokedBy_id = Column(Integer, ForeignKey('User.id'))

    comment = relationship(
        'ArticleComment',  back_populates='likes')

    user = relationship('User', foreign_keys=[user_id])
    awardedBy = relationship('User', foreign_keys=[awardedBy_id])
예제 #20
0
class UserFile(Model):
    __tablename__ = 'UserFile'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    url = Column(String(length=255))
    folder_path = Column(String(length=255))
    fileName = Column(String(length=255))
    mimeType = Column(String(length=255))
    altText = Column(String(length=255))
    uploadSource = Column(
        Enum('FINDER', 'ARTICLE_UPLOAD_DIALOG', 'FORUM_UPLOAD_DIALOG'))
    createdBy_id = Column(Integer, ForeignKey('User.id'))
    creationDate = Column(DateTime)
    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    modificationDate = Column(DateTime)
    deleted = Column(BIT)
    deletedBy_id = Column(Integer, ForeignKey('User.id'))
    deletionDate = Column(DateTime)
    copyright = Column(String(length=255))
    tags = Column(String(length=255))
    ignoreInMigration = Column(BIT)

    user = relationship('User', back_populates='files',
                        foreign_keys=[createdBy_id])

    def __repr__(self):
        return "<ApitUserFile(id='%s', url='%s', mimeType='%s')>" % (self.id, self.url, self.mimeType)
예제 #21
0
class Sequence(Task, CodeMixin):
    """Stores data about Sequences.

    Sequences are a way of grouping the Shots according to their temporal
    position to each other.

    **Initialization**

    .. warning::

       .. deprecated:: 0.2.0

       Sequences do not have a lead anymore. Use the :class:`.Task.responsible`
       attribute of the super (:class:`.Task`).
    """
    __auto_name__ = False
    __tablename__ = "Sequences"
    __mapper_args__ = {"polymorphic_identity": "Sequence"}
    sequence_id = Column("id",
                         Integer,
                         ForeignKey("Tasks.id"),
                         primary_key=True)

    shots = relationship("Shot",
                         secondary='Shot_Sequences',
                         back_populates="sequences",
                         doc="""The :class:`.Shot` s assigned to this Sequence.

        It is a list of :class:`.Shot` instances.
        """)

    def __init__(self, **kwargs):
        super(Sequence, self).__init__(**kwargs)

        # call the mixin __init__ methods
        ReferenceMixin.__init__(self, **kwargs)
        CodeMixin.__init__(self, **kwargs)
        self.shots = []

    @validates("shots")
    def _validate_shots(self, key, shot):
        """validates the given shot value
        """
        from stalker.models.shot import Shot

        if not isinstance(shot, Shot):
            raise TypeError(
                '%s.shots should be all stalker.models.shot.Shot instances, '
                'not %s' % (self.__class__.__name__, shot.__class__.__name__))
        return shot

    def __eq__(self, other):
        """the equality operator
        """
        return isinstance(other, Sequence) and \
            super(Sequence, self).__eq__(other)

    def __hash__(self):
        """the overridden __hash__ method
        """
        return super(Sequence, self).__hash__()
예제 #22
0
class Article(Model):
    __tablename__ = 'Article'
    id = Column(Integer, primary_key=True)
    DTYPE = Column(String(length=31))
    version = Column(Integer)
    format = Column(Enum('NEWS', 'BEST_PRODUCTS', 'HOW_TO', 'OPINION', 'INTERVIEW', 'POLL',
                         'LIVE_STREAM', 'DEALS', 'HANDS_ON', 'FULL_REVIEW', 'LONG_TERM_REVIEW', 'COMPARISON'))
    language = Column(String(length=2))
    uri_language = Column(String(length=2))
    uri_uri = Column(String(length=255))
    title = Column(String(length=255))
    advertorial = Column(BIT)
    metaDescription = Column(Text)
    metaKeywords = Column(Text)
    metaNewsKeywords = Column(Text)
    categoryIds = Column(Text)
    relatedManufacturerIds = Column(Text)
    mainDevice_id = Column(Integer)
    relatedDeviceIds = Column(Text)
    relatedAppIds = Column(Text)
    relatedAndroidVersions = Column(Text)
    relatedSystemUIs = Column(Text)
    relatedOSs = Column(Text)
    relatedOperatorBrands = Column(Text)
    otherTags = Column(Text)
    otherTagIds = Column(Text)
    relatedForumThreadIds = Column(String(length=255))
    relatedArticleIds = Column(String(length=255))
    referencedGalleryIds = Column(Text)
    commentsAllowed = Column(Boolean)
    author_id = Column(Integer, ForeignKey('User.id'))
    published = Column(Boolean)
    publishingDate = Column(DateTime)
    republishingDate = Column(DateTime)
    storyLabel = Column(String(length=255))
    sourceName = Column(String(length=255))
    sourceURL = Column(String(length=255))
    source2Name = Column(String(length=255))
    source2URL = Column(String(length=255))
    source3Name = Column(String(length=255))
    source3URL = Column(String(length=255))
    translationSource_id = Column(Integer, ForeignKey('Article.id'))

    heroImage_id = Column(Integer, ForeignKey(
        'UserFile.id'))  # foregin keys here/
    heroImageAuto = Column(Boolean)
    previewImage_id = Column(Integer, ForeignKey('UserFile.id'))
    previewImageLegacy_id = Column(Integer, ForeignKey('UserFile.id'))
    pros = Column(Text)
    cons = Column(Text)

    createdBy_id = Column(Integer, ForeignKey('User.id'))
    creationDate = Column(DateTime)

    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    modificationDate = Column(DateTime)

    deleted = Column(Boolean)
    deletionDate = Column(DateTime)
    deletionReason = Column(String(length=255))

    author = relationship('User', foreign_keys=[author_id])
    createdBy = relationship('User', foreign_keys=[createdBy_id])
    modifiedBy = relationship('User', foreign_keys=[modifiedBy_id])

    heroImage = relationship('UserFile', foreign_keys=[heroImage_id])
    previewImage = relationship('UserFile', foreign_keys=[previewImage_id])
    previewImageLegacy = relationship(
        'UserFile', foreign_keys=[previewImageLegacy_id])

    sections = relationship('ArticleSection', back_populates='article')
    comments = relationship('ArticleComment', back_populates='article')
    translationSource = relationship('Article', uselist=False, remote_side=[id], back_populates='translations')
    translations = relationship('Article', foreign_keys=[translationSource_id], back_populates='translationSource')

    def __repr__(self):
        return "<ApitArticle(id='%s', title='%s', publishingDate='%s')>" % (self.id, self.title, self.publishingDate)
예제 #23
0
class PlaceMixin(object):
	place_name = Column(String(40))
	lat = Column(Float)
	lng = Column(Float)
	alt = Column(Float)
	map = Column(Text, default='')
	info = Column(Text, default='')
	pin = Column(Boolean)  # Do we put a pin
	pin_color = Column(String(20))
	pin_icon = Column(String(50))
	centered = Column(Boolean)
	nearest_feature = Column(String(100))
예제 #24
0
class User(Model):
    __tablename__ = 'User'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    status = Column(Enum('NO_USER', 'REGISTERING',
                         'REGISTERING_ACTIVE', 'OK', 'DEACTIVATED'))

    emailAddress = Column(String(length=255))
    passwordSHA = Column(String(length=255))
    passwordGenerated = Column(String(length=255))
    accountActivationCode = Column(String(length=255))
    accountActivationLink = Column(String(length=255))
    emailAddressNew = Column(String(length=255))
    emailValidationCode = Column(String(length=255))
    emailValidationLink = Column(String(length=255))
    fbUserId = Column(BigInteger)
    googleUserId = Column(String(length=255))
    publicName = Column(String(length=255))
    username = Column(String(length=255))
    communityName = Column(String(length=255))
    birthdayDate = Column(Integer)
    birthdayMonth = Column(Integer)
    birthdayYear = Column(Integer)
    birthdayMailSentYear = Column(Integer)

    city = Column(String(length=255))
    country_id = Column(String(length=2))
    locale = Column(String(length=255))

    roleAssignmentsJson = Column(Text)
    staffPageDescriptionJson = Column(Text)
    deactivationDate = Column(DateTime)
    lastLoginDate = Column(DateTime)

    nextPitTransferAgreed = Column(BIT)
    nextPitTransferAgrementDate = Column(DateTime)
    nextPitTransferDisagrementDate = Column(DateTime)
    creationDate = Column(DateTime)

    level = Column(Integer)
    pointsInLevel = Column(Integer)
    pointsTotalRecalculated = Column(Integer)

    partner_id = Column(String(length=255))

    userImage_id = Column(Integer)  # FOREIGNKEY HERE

    image = relationship('UserImage', back_populates='user', uselist=False,
                         primaryjoin="and_(User.id==UserImage.user_id, UserImage.deleted==0)")
    files = relationship('UserFile', back_populates='user',
                         foreign_keys='UserFile.createdBy_id')

    def __repr__(self):
        return "<ApitUser(id='%s', emailAddress='%s', publicName='%s')>" % (self.id, self.emailAddress, self.publicName)
예제 #25
0
class PersonMixin(object):
	# prn_id = Column(Integer, index=True)
	# prn = Column(String(6), unique=True, index=True)
	id = Column(Integer, autoincrement=True, primary_key=True)
	firstname = Column(String(40), nullable=False, index=True)
	surname = Column(String(40), nullable=False, index=True)
	othernames = Column(String(40), nullable=True, index=True)
	dob = Column(Date, default=func.now())
	
	marital_status = Column(String(10))
	photo = Column(ImageColumn(thumbnail_size=(30, 30, True), size=(300, 300, True)))
	
	
	# Next of Kin
	kin1_name = Column(String(40))
	kin1_phone = Column(String(50))
	kin1_email = Column(String(125))
	kin1_addr = Column(Text)
	
	kin2_name = Column(String(40))
	kin2_phone = Column(String(50))
	kin2_email = Column(String(125))
	kin2_addr = Column(Text)
	
	# @declared_attr
	# def age_today(self):
	# 	today = date.today()
	# 	born = self.dob
	# 	return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
	
	age_today = Column(Integer)
	
	@hybrid_property
	def _age_today(self):
		"""Property calculated from (current time - :attr:`User.date_of_birth` - leap days)"""
		if self.dob:
			today = (datetime.utcnow() + timedelta(hours=self.timezone)).date()
			birthday = self.dob
			if isinstance(birthday, datetime):
				birthday = birthday.date()
			age = today - (birthday or (today - timedelta(1)))
			self._age_today =  (age.days - calendar.leapdays(birthday.year, today.year)) / 365
			return self._age_today
		return -1
	
	@declared_attr
	def age(self):
		if isinstance(self.dob, datetime):
			doby = self.dob.date()
		else:
			doby = mindate
		dur = humanize.naturaltime(datetime.now().date() - doby)
		return Markup('<span class="no-wrap">{}</span>'.format(dur))
	
	
	# @declared_attr
	@hybrid_property
	def dob_month_year(self):
		if isinstance(self.dob, datetime):
			doby = self.dob.date()
		else:
			doby = mindate
		return datetime(doby.year, doby.month, 1)

	def month_year(self):
		date = self.dob or mindate
		return datetime(date.year, date.month, 1) or mindate
	
	def year(self):
		date = self.dob or mindate
		return datetime(date.year, 1, 1)
	
	def ViewName(self):
		return self.__class__.__name__ +'View.show'
	
	
	def __repr__(self):
		return self.firstname + ' ' + self.surname
예제 #26
0
class ArticleComment(Model):
    __tablename__ = 'ArticleComment'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    article_id = Column(Integer, ForeignKey('Article.id'))
    # TODO: fix the parent relation ship
    parentComment_id = Column(Integer, ForeignKey('ArticleComment.id'))
    nestedLevel = Column(Integer)
    language = Column(String(length=2))
    comment = Column(Text)
    createdBy_id = Column(Integer, ForeignKey('User.id'))
    creationDate = Column(DateTime)
    creatorIp = Column(String(length=255))
    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    modificationDate = Column(DateTime)
    deleted = Column(Boolean)
    deletedBy_id = Column(Integer, ForeignKey('User.id'))
    deletionDate = Column(DateTime)

    createdBy = relationship('User', foreign_keys=[createdBy_id])
    modifiedBy = relationship('User', foreign_keys=[modifiedBy_id])
    deletedBy = relationship('User', foreign_keys=[deletedBy_id])
    article = relationship('Article', foreign_keys=[article_id])

    parent = relationship('ArticleComment', remote_side=[id])
    likes = relationship(
        'UserEvent', primaryjoin="and_(ArticleComment.id==UserEvent.articleComment_id, UserEvent.event == 'RECEIVE_LIKE')")

    def __repr__(self):
        return "<ApitArticleComment(article_id='%s', creationDate='%s', parentComment_id='%s')>\n" % (self.article_id, self.creationDate, self.parentComment_id)
예제 #27
0
	def prn_id(cls):
		return Column(Integer, ForeignKey('humans.prn_id'), nullable=True, index=True)
예제 #28
0
class Device(Model):
    __tablename__ = 'Device'
    id = Column(Integer, primary_key=True)
    version = Column(Integer)
    manufacturer_id = Column(String(length=255))
    deviceType = Column(Enum('PHONE', 'PHABLET', 'TABLET', 'TV', 'CAMERA', 'GAME_CONSOLE', 'WATCH', 'SMART_HOME',
                             'FITNESS_TRACKER', 'WEARABLE', 'SPEAKER', 'HEADPHONE', 'E_READER', 'NOTEBOOK', 'VR_HEADSET', 'OTHER'))
    releaseDate = Column(DateTime)
    bestseller = Column(Boolean)
    thirdPartyPixel = Column(Text)
    name = Column(String(length=255))
    modelId = Column(String(length=255))
    alsoKnownAs = Column(String(length=255))
    creationDate = Column(DateTime)
    createdBy_id = Column(Integer, ForeignKey('User.id'))
    modifiedBy_id = Column(Integer, ForeignKey('User.id'))
    modificationDate = Column(DateTime)
    deleted = Column(Boolean)
    deletedBy_id = Column(Integer, ForeignKey('User.id'))
    deletionDate = Column(DateTime)
    metaKeywords = Column(String(length=255))
    metaDescription = Column(String(length=255))

    createdBy = relationship('User', foreign_keys=[createdBy_id])
    modifiedBy = relationship('User', foreign_keys=[modifiedBy_id])
    deletedBy = relationship('User', foreign_keys=[deletedBy_id])
    images = relationship('DeviceImage', back_populates='device')

    def __repr__(self):
        return "<ApitDevice(id='%s', name='%s', releaseDate='%s')>" % (self.id, self.name, self.releaseDate)
예제 #29
0
class ContactMixin(object):
	mobile = Column(String(30), index=True)
	other_mobile = Column(String(30))
	fixed_line = Column(String(30))
	other_fixed_line = Column(String(20))
	email = Column(String(60))
	other_email = Column(String(60))
	address_line_1 = Column(String(200))
	address_line_2 = Column(String(200))
	zipcode = Column(String(30))
	town = Column(String(40))
	country = Column(String(50), default='Ghana')
	facebook = Column(String(40))
	twitter = Column(String(40))
	instagram = Column(String(40))
	whatsapp = Column(Boolean)
	other_whatsapp = Column(Boolean)
	fax = Column(String(30))
	gcode = Column(String(40))
	okhi = Column(String(40))
class Users(Base):

    __tablename__ = "users"
    id =Column(Integer, primary_key=True)
    name = Column(String)
    college = Column(String)