Esempio n. 1
0
class Students(db.Model, ModelMixin):
    __tablename__ = 'students'

    name = db.Column(db.String(100), nullable=False)
    ist_id = db.Column(db.String(10), unique=True, nullable=False, index=True)
    photo = db.Column(db.Text())
    photo_type = db.Column(db.String(20))
    linkedin_url = deferred(db.Column(db.String(150)))
    uploaded_cv = deferred(db.Column(db.Boolean, default=False))

    level = relationship('Levels')
    level_id = db.Column(db.Integer, db.ForeignKey('levels.id'))

    daily_points = db.Column(db.Integer())
    total_points = db.Column(db.Integer())
    squad_points = db.Column(db.Integer())

    referral_code = db.Column(db.String(16),
                              unique=True,
                              nullable=False,
                              index=True)
    course = db.Column(db.String(10))
    entry_year = db.Column(db.String())

    user = relationship('Users', cascade="all,delete")
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))

    squad = relationship('Squads', back_populates="members", uselist=False)
    squad_id = db.Column(db.Integer,
                         db.ForeignKey('squads.id', ondelete='SET NULL'))

    tags = relationship("Tags",
                        secondary="students_tags",
                        secondaryjoin=sql.and_(StudentsTags.tag_id == Tags.id))

    companies = relationship(
        "Companies",
        secondary="student_companies",
        secondaryjoin=sql.and_(StudentCompanies.company_id == Companies.id))

    login_dates = relationship("StudentLogins")

    activities = relationship(
        "Activities",
        secondary="student_activities",
        secondaryjoin=sql.and_(StudentActivities.activity_id == Activities.id))

    def is_captain(self):
        if self.squad:
            return self.user.username == self.squad.captain_ist_id
        return False

    def __repr__(self):
        return 'Name: {}  |  IST Id: {}'.format(self.user.name,
                                                self.user.username)
Esempio n. 2
0
class SquadsRewards(db.Model, ModelMixin):
    __tablename__ = 'squads_rewards'
    
    reward_id = db.Column(db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    reward = relationship('Rewards')

    date = db.Column(db.String(30), unique=True)

    winner = relationship('Squads')
    winner_id = db.Column(db.Integer, db.ForeignKey('squads.id', ondelete='SET NULL'))

    def __repr__(self):
        return 'Name: {}'.format(self.name)
Esempio n. 3
0
class Bids(db.Model, ModelMixin):
    __tablename__ = 'bids'

    company_id = db.Column(db.Integer,
                           db.ForeignKey('companies.id'),
                           index=True)
    is_anonymous = db.Column(db.Boolean, default=False)

    value = db.Column(db.Float(), nullable=False)

    auction = db.relationship('Auctions', back_populates="bids", uselist=False)
    auction_id = db.Column(db.Integer, db.ForeignKey('auctions.id'))

    def __repr__(self):
        return 'Value: {}'.format(self.value)
Esempio n. 4
0
class SquadInvitations(db.Model, ModelMixin):
    __tablename__ = 'squad_invitations'

    __table_args__ = (db.UniqueConstraint('sender_id',
                                          'receiver_id',
                                          name='uix_squads'), )

    sender_id = db.Column(db.Integer,
                          db.ForeignKey('students.id', ondelete='CASCADE'),
                          index=True)
    sender = relationship('Students', foreign_keys=sender_id)

    receiver_id = db.Column(db.Integer,
                            db.ForeignKey('students.id', ondelete='CASCADE'),
                            index=True)
    receiver = relationship('Students', foreign_keys=receiver_id)
Esempio n. 5
0
class StudentLogins(db.Model, ModelMixin):
    __tablename__ = 'student_logins'

    student_id = db.Column(db.Integer,
                           db.ForeignKey('students.id', ondelete='CASCADE'),
                           index=True)
    date = db.Column(db.String(30))

    def __repr__(self):
        return 'Date: {}'.format(self.date)
Esempio n. 6
0
class ActivityCodes(db.Model, ModelMixin):
    __tablename__ = 'activity_codes'

    code = db.Column(db.String(16), unique=True, nullable=False, index=True)

    activity = relationship('Activities')
    activity_id = db.Column(db.Integer,
                            db.ForeignKey('activities.id', ondelete='CASCADE'))

    def __repr__(self):
        return 'Code: {}'.format(self.code)
Esempio n. 7
0
class Levels(db.Model, ModelMixin):
    __tablename__ = 'levels'
    
    value = db.Column(db.Integer(), unique=True, nullable=False)
    points = db.Column(db.Integer(), nullable=False)

    reward_id = db.Column(db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    reward = relationship('Rewards')
    
    def __repr__(self):
        return 'Level: {}'.format(self.value)
Esempio n. 8
0
class Activities(db.Model, ModelMixin):
    __tablename__ = 'activities'
    
    name = db.Column(db.String(100), unique=False, nullable=False)
    description = db.Column(db.String(300))

    location = db.Column(db.String(100), default="Instituto Superior Técnico")
    day = db.Column(db.String(20))
    time = db.Column(db.String(10))
    end_time = db.Column(db.String(10))

    registration_open = db.Column(db.Boolean, default=False)
    registration_link = db.Column(db.String(100))

    activity_type = relationship('ActivityTypes', back_populates="activities", uselist=False)
    activity_type_id = db.Column(db.Integer, db.ForeignKey('activity_types.id', ondelete='SET NULL'))

    event = relationship('Events', back_populates="activities", uselist=False)
    event_id = db.Column(db.Integer, db.ForeignKey('events.id'))

    chat_id = db.Column(db.String)
    chat_code = db.Column(db.String)
    chat_type = db.Column(db.Enum(ActivityChatEnum))

    zoom_link = db.Column(db.String)

    reward_id = db.Column(db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    reward = relationship('Rewards')

    moderator_id = db.Column(db.Integer, db.ForeignKey('speakers.id', ondelete='SET NULL'))
    moderator = relationship('Speakers')

    tags = relationship("Tags",
        secondary="activities_tags",
        secondaryjoin=sql.and_(ActivitiesTags.tag_id == Tags.id))

    points = db.Column(db.Integer())
    quest = db.Column(db.Boolean, default=False)
   
    def __repr__(self):
        return 'Type: {}  |  Name: {}'.format(self.activity_type.name, self.name)
Esempio n. 9
0
class Dishes(db.Model, ModelMixin):
    __tablename__ = 'dishes'

    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(300))
    type = db.Column(db.Enum(DishTypeEnum), nullable=False)

    meal_id = db.Column(db.Integer,
                        db.ForeignKey('meals.id', ondelete='CASCADE'),
                        index=True)

    def __repr__(self):
        return 'Dish: {}'.format(self.name)
Esempio n. 10
0
class SquadDailyPoints(db.Model, ModelMixin):
    __tablename__ = 'squad_daily_points'

    squad_id = db.Column(db.Integer,
                         db.ForeignKey('squads.id', ondelete='CASCADE'),
                         index=True)
    squad = relationship('Squads')

    date = db.Column(db.String(30))
    points = db.Column(db.Integer())

    def __repr__(self):
        return 'Date: {} Points: {}'.format(self.date, self.points)
Esempio n. 11
0
class Colaborators(db.Model, ModelMixin):
    __tablename__ = 'colaborators'

    name = db.Column(db.String(100), unique=True, nullable=False)
    ist_id = db.Column(db.String(10))
    email = db.Column(db.String(100))

    team = relationship('Teams', back_populates="members", uselist=False)
    team_id = db.Column(db.Integer, db.ForeignKey('teams.id'))

    linkedin_url = db.Column(db.String(150))

    def __repr__(self):
        return 'Name: {} | Team: {}'.format(self.name, self.team)
Esempio n. 12
0
class CompanyUsers(db.Model, ModelMixin):
    __tablename__ = 'company_users'

    company = db.relationship('Companies',
                              back_populates="users",
                              uselist=False)
    company_id = db.Column(db.Integer,
                           db.ForeignKey('companies.id', ondelete='CASCADE'))

    post = db.Column(db.String(50))

    food_manager = db.Column(db.Boolean, default=False)

    user = relationship('Users', cascade="all,delete")
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))

    evf_username = db.Column(db.String)
    evf_password = db.Column(db.String)

    def __repr__(self):
        return 'Name: {}  |  Company: {}'.format(self.user.name,
                                                 self.company.name)
Esempio n. 13
0
class Teams(db.Model, ModelMixin):
    __tablename__ = 'teams'

    name = db.Column(db.String(100), unique=True)
    description = db.Column(db.String(300))

    website_priority = db.Column(
        db.Integer(), default=0)  # for sorting the teams in the website

    members = relationship("Colaborators",
                           back_populates='team',
                           lazy='dynamic',
                           cascade="all,delete",
                           order_by="Colaborators.name")

    event = relationship('Events', back_populates="teams", uselist=False)
    event_id = db.Column(db.Integer, db.ForeignKey('events.id'))

    def __repr__(self):
        return 'Name: {}'.format(self.name)
Esempio n. 14
0
class ActivityTypes(db.Model, ModelMixin):
    __tablename__ = 'activity_types'

    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(300))
    price = db.Column(db.Float())

    show_in_home = db.Column(db.Boolean, default=True)
    show_in_schedule = db.Column(db.Boolean, default=True)
    show_in_app = db.Column(db.Boolean, default=True)

    event = relationship('Events',
                         back_populates="activity_types",
                         uselist=False)
    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='SET NULL'))

    activities = relationship("Activities",
                              back_populates='activity_type',
                              lazy='dynamic',
                              cascade="all,delete")

    def __repr__(self):
        return 'Name: {}  |  Price: {}'.format(self.name, self.price)
Esempio n. 15
0
class StudentActivities(db.Model, ModelMixin):
    __tablename__ = 'student_activities'

    student_id = db.Column(db.Integer, db.ForeignKey('students.id', ondelete='CASCADE'), index=True)
    activity_id = db.Column(db.Integer, db.ForeignKey('activities.id', ondelete='CASCADE'), index=True)
Esempio n. 16
0
class JeecpotRewards(db.Model, ModelMixin):
    __tablename__ = 'jeecpot_rewards'

    first_student_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    first_student_reward = relationship('Rewards',
                                        foreign_keys=first_student_reward_id)
    first_student_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    first_student_winner = relationship('Students',
                                        foreign_keys=first_student_winner_id)

    second_student_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    second_student_reward = relationship('Rewards',
                                         foreign_keys=second_student_reward_id)
    second_student_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    second_student_winner = relationship('Students',
                                         foreign_keys=second_student_winner_id)

    third_student_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    third_student_reward = relationship('Rewards',
                                        foreign_keys=third_student_reward_id)
    third_student_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    third_student_winner = relationship('Students',
                                        foreign_keys=third_student_winner_id)

    first_squad_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    first_squad_reward = relationship('Rewards',
                                      foreign_keys=first_squad_reward_id)
    first_squad_winner_id = db.Column(
        db.Integer, db.ForeignKey('squads.id', ondelete='SET NULL'))
    first_squad_winner = relationship('Squads',
                                      foreign_keys=first_squad_winner_id)

    second_squad_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    second_squad_reward = relationship('Rewards',
                                       foreign_keys=second_squad_reward_id)
    second_squad_winner_id = db.Column(
        db.Integer, db.ForeignKey('squads.id', ondelete='SET NULL'))
    second_squad_winner = relationship('Squads',
                                       foreign_keys=second_squad_winner_id)

    third_squad_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    third_squad_reward = relationship('Rewards',
                                      foreign_keys=third_squad_reward_id)
    third_squad_winner_id = db.Column(
        db.Integer, db.ForeignKey('squads.id', ondelete='SET NULL'))
    third_squad_winner = relationship('Squads',
                                      foreign_keys=third_squad_winner_id)

    king_job_fair_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    king_job_fair_reward = relationship('Rewards',
                                        foreign_keys=king_job_fair_reward_id)
    king_job_fair_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    king_job_fair_winner = relationship('Students',
                                        foreign_keys=king_job_fair_winner_id)

    king_knowledge_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    king_knowledge_reward = relationship('Rewards',
                                         foreign_keys=king_knowledge_reward_id)
    king_knowledge_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    king_knowledge_winner = relationship('Students',
                                         foreign_keys=king_knowledge_winner_id)

    king_hacking_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    king_hacking_reward = relationship('Rewards',
                                       foreign_keys=king_hacking_reward_id)
    king_hacking_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    king_hacking_winner = relationship('Students',
                                       foreign_keys=king_hacking_winner_id)

    king_networking_reward_id = db.Column(
        db.Integer, db.ForeignKey('rewards.id', ondelete='SET NULL'))
    king_networking_reward = relationship(
        'Rewards', foreign_keys=king_networking_reward_id)
    king_networking_winner_id = db.Column(
        db.Integer, db.ForeignKey('students.id', ondelete='SET NULL'))
    king_networking_winner = relationship(
        'Students', foreign_keys=king_networking_winner_id)

    def __repr__(self):
        return 'Name: {}'.format(self.name)
Esempio n. 17
0
class StudentCompanies(db.Model, ModelMixin):
    __tablename__ = 'student_companies'

    student_id = db.Column(db.Integer, db.ForeignKey('students.id', ondelete='CASCADE'), index=True)
    company_id = db.Column(db.Integer, db.ForeignKey('companies.id', ondelete='CASCADE'), index=True)