示例#1
0
文件: models.py 项目: ubacm/swe0-old
class Resume(db.Model):
    __tablename__ = 'resumes_resume'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, foreign_key(db, User))
    filename = db.Column(db.String(50), nullable=False)

    user = db.relationship(User, backref=db.backref('resume', uselist=False))

    @classmethod
    def generate_filename(cls):
        def generate():
            return uuid.uuid4().hex + '.pdf'

        filename = generate()
        while db.session.query(
                cls.query.filter_by(filename=filename).exists()).scalar():
            # Regenerate in the unlikely event of a duplicate.
            filename = generate()
        return filename

    @property
    def file_path(self):
        return os.path.join(app.config['UPLOAD_FOLDER'], 'resumes',
                            self.filename)

    @property
    def url_path(self):
        return url_for('resumes.view', filename=self.filename)
示例#2
0
class Transaction(db.Model):
    __tablename__ = 'rewards_transaction'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), nullable=False)
    timestamp = db.Column(db.DateTime(timezone=True), server_default=func.now())
    amount = db.Column(db.Integer, nullable=False)
    comment = db.Column(db.String(500), nullable=False)
示例#3
0
class Vote(db.Model):
    __tablename__ = 'voting_vote'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, foreign_key(db, User))
    category_id = db.Column(db.Integer, foreign_key(db, Category))
    entry_id = db.Column(db.Integer, foreign_key(db, Entry))

    user = db.relationship(User, backref='votes')
    category = db.relationship(Category, backref='votes')
    entry = db.relationship(Entry, backref='votes')
示例#4
0
class User(UserMixin, db.Model):
    __tablename__ = 'auth_user'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), nullable=False, unique=True)
    name = db.Column(db.String(100),
                     nullable=False)  # Note: Slack's limit is 80 chars.
    is_admin = db.Column(db.Boolean, nullable=False, server_default='0')

    def __repr__(self):
        return '<User {}: {}>'.format(self.id, self.email)
示例#5
0
文件: models.py 项目: ubacm/swe0-old
class Event(db.Model):
    __tablename__ = 'events_event'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(500), nullable=False)
    location = db.Column(db.String(50), nullable=False)
    start_time = db.Column(db.DateTime(timezone=True))
    end_time = db.Column(db.DateTime(timezone=True))
    check_in_enabled = db.Column(db.Boolean, server_default='0')
    check_in_code = db.Column(db.String(10), server_default='', nullable=False)
    check_in_rewards = db.Column(db.Integer, server_default='1')
示例#6
0
class Entry(db.Model):
    __tablename__ = 'voting_entry'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(500), nullable=False)
    categories = db.relationship(Category,
                                 secondary=categorization,
                                 lazy='subquery',
                                 backref=db.backref('entries', lazy=True))
    _team_emails = db.Column('team_emails', db.String(200), nullable=False)

    @property
    def team_emails(self):
        return self._team_emails.split(', ')

    @team_emails.setter
    def team_emails(self, emails):
        if isinstance(emails, str):
            emails = (email.strip() for email in emails.split(','))
        self._team_emails = ', '.join(sorted(filter(None, emails)))
示例#7
0
class Category(db.Model):
    __tablename__ = 'voting_category'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(500), nullable=False)
    event_id = db.Column(db.Integer, foreign_key(db, Event))
    is_accepting_entries = db.Column(db.Boolean, server_default='0')
    is_accepting_votes = db.Column(db.Boolean, server_default='0')

    event = db.relationship(Event,
                            backref=db.backref('voting_categories',
                                               uselist=False))
示例#8
0
from swe0 import db
from swe0.auth.models import User
from swe0.ext.events.models import Event
from swe0.utils import foreign_key

categorization = db.Table(
    'voting_categorization',
    db.Column('category_id',
              db.Integer,
              db.ForeignKey('voting_category.id'),
              primary_key=True),
    db.Column('entry_id',
              db.Integer,
              db.ForeignKey('voting_entry.id'),
              primary_key=True),
)


class Category(db.Model):
    __tablename__ = 'voting_category'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(500), nullable=False)
    event_id = db.Column(db.Integer, foreign_key(db, Event))
    is_accepting_entries = db.Column(db.Boolean, server_default='0')
    is_accepting_votes = db.Column(db.Boolean, server_default='0')

    event = db.relationship(Event,
                            backref=db.backref('voting_categories',
                                               uselist=False))
示例#9
0
文件: models.py 项目: ubacm/swe0-old
class CheckIn(db.Model):
    __tablename__ = 'events_check_in'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), nullable=False)
    timestamp = db.Column(db.DateTime(timezone=True))