class UsersEventsRoles(db.Model):
    __tablename__ = 'users_events_roles'
    __table_args__ = (
        db.UniqueConstraint(
            'user_id', 'event_id', 'role_id', name='uq_uer_user_event_role'
        ),
    )

    id = db.Column(db.Integer, primary_key=True)

    event_id = db.Column(
        db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'), nullable=False
    )

    user_id = db.Column(
        db.Integer, db.ForeignKey('users.id', ondelete='CASCADE'), nullable=False
    )
    user = db.relationship("User")

    role_id = db.Column(
        db.Integer, db.ForeignKey('roles.id', ondelete='CASCADE'), nullable=False
    )
    role = db.relationship("Role")

    def __repr__(self):
        return f'<UER {self.user!r}:{self.event_id!r}:{self.role!r}>'
Пример #2
0
class Faq(SoftDeletionModel):
    """Page model class"""
    __tablename__ = 'faq'
    id = db.Column(db.Integer, primary_key=True)
    question = db.Column(db.String, nullable=False)
    answer = db.Column(db.String, nullable=False)
    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='CASCADE'))
    faq_type_id = db.Column(db.Integer, db.ForeignKey('faq_types.id', ondelete='CASCADE'))

    def __init__(self, question=None, answer=None, event_id=None, faq_type_id=None, deleted_at=None):
        self.question = question
        self.answer = answer
        self.event_id = event_id
        self.faq_type_id = faq_type_id
        self.deleted_at = deleted_at

    def __repr__(self):
        return '<FAQ %r>' % self.question

    def __str__(self):
        return self.__repr__()

    @property
    def serialize(self):
        """Return object data in easily serializable format"""
        return {
            'id': self.id,
            'question': self.question,
            'answer': self.answer
        }
Пример #3
0
class BookedTicket(db.Model):
    __tablename__ = 'booked_ticket'
    __table_args__ = (db.UniqueConstraint('user_id',
                                          'ticket_id',
                                          name='user_ticket_uc'), )

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id',
                                                  ondelete='CASCADE'))
    user = db.relationship('User', backref='booked_tickets')
    ticket_id = db.Column(db.Integer,
                          db.ForeignKey('ticket.id', ondelete='CASCADE'))
    ticket = db.relationship('Ticket', backref='booked_tickets')
    quantity = db.Column(db.Integer)

    def __init__(self, user, ticket, quantity):
        self.user = user
        self.ticket = ticket
        self.quantity = quantity

    def __repr__(self):
        return '<BookedTicket %r by %r' % (
            self.ticket,
            self.user,
        )

    def __str__(self):
        return unicode(self).encode('utf-8')

    def __unicode__(self):
        return self.ticket
Пример #4
0
class Booth(db.Model, BaseModel):
    # table name
    __tablename__ = 'booths'
    # displayed fields
    visible = [
        'id', 'user_id', 'stage_id', 'points', 'summary', 'logo_url', 'name',
        'created_at', 'updated_at'
    ]

    # columns definitions
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(40),
                        db.ForeignKey('users.id'),
                        nullable=True)
    user = db.relationship('User')
    stage_id = db.Column(db.String(40), db.ForeignKey('stages.id'))
    stage = db.relationship('Stage')
    summary = db.Column(db.Text)
    points = db.Column(db.Integer)
    name = db.Column(db.String(255))
    logo_url = db.Column(db.String(255))
    created_at = db.Column(db.DateTime)
    updated_at = db.Column(db.DateTime)

    def __init__(self):
        self.created_at = datetime.datetime.now()
        self.updated_at = datetime.datetime.now()
        self.summary = ''
        self.points = 0
Пример #5
0
class Lesson(db.Model):
    """Lesson

    A lesson takes place every week. This is only a repetition pattern.
    Each week a new event (see `Event`) is created.
    """

    __tablename__ = 'lesson'
    id = db.Column(db.Integer, primary_key=True, unique=True, nullable=False)
    school_id = db.Column(db.Integer,
                          db.ForeignKey('school.id'),
                          nullable=False)

    tutor_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    available = db.Column(db.Boolean, nullable=False, default=True)
    # Time and repetition pattern (weekly)
    weekday = db.Column(db.Enum(Weekday),
                        nullable=False,
                        default=Weekday.monday)
    time_id = db.Column(db.Integer, db.ForeignKey('time.id'), nullable=False)

    tutor = db.relationship('User',
                            foreign_keys=[tutor_id],
                            back_populates='tutor_lessons')
    students = db.relationship('User',
                               secondary='user_lesson',
                               back_populates='student_lessons')
    time = db.relationship('Time', foreign_keys=[time_id])
    events = db.relationship('Event', back_populates='lesson')

    def __repr__(self):
        return f'<Lesson {self.tutor.name}@{self.weekday}>'
Пример #6
0
class Microlocation(SoftDeletionModel):
    """Microlocation model class"""

    __tablename__ = 'microlocations'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    latitude = db.Column(db.Float)
    longitude = db.Column(db.Float)
    floor = db.Column(db.Integer)
    room = db.Column(db.String)
    session = db.relationship('Session', backref="microlocation")
    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='CASCADE'))
    video_stream_id = db.Column(
        db.Integer, db.ForeignKey('video_streams.id', ondelete='CASCADE'))

    @staticmethod
    def get_service_name():
        return 'microlocation'

    def __repr__(self):
        return '<Microlocation %r>' % self.name

    @property
    def safe_video_stream(self):
        """Conditionally return video stream after applying access control"""
        stream = self.video_stream
        if stream and stream.user_can_access:
            return stream
        return None
class UserFavouriteSession(db.Model, Timestamp):
    __tablename__ = 'user_favourite_sessions'
    __table_args__ = (db.UniqueConstraint('session_id',
                                          'user_id',
                                          name='uq_session_user'), )

    id = db.Column(db.Integer, primary_key=True)
    session_id = db.Column(db.Integer,
                           db.ForeignKey('sessions.id', ondelete='CASCADE'))
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))
    session = db.relationship('Session', backref='favourites')
    user = db.relationship('User', backref='favourite_sessions')

    @property
    def safe_user(self):
        from app.api.helpers.permission_manager import require_current_user
        from app.models.user import User

        if not self.user_id:
            return None
        can_access = require_current_user() and (
            current_user.is_staff or current_user.id == self.user_id)
        if not self.user.is_profile_public and not can_access:
            name = self.user.anonymous_name
            return User(
                id=self.user.id,
                email='*****@*****.**',
                public_name=name,
            )
        return self.user
Пример #8
0
class Invite(db.Model):
    """invite model class"""
    __tablename__ = 'invites'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))
    user = db.relationship("User", backref="invite")
    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='CASCADE'))
    session_id = db.Column(db.Integer,
                           db.ForeignKey('sessions.id', ondelete='CASCADE'))
    session = db.relationship("Session", backref="invite")
    hash = db.Column(db.String, nullable=False)

    def __init__(self, event_id=None, user_id=None, session_id=None):
        self.user_id = user_id
        self.event_id = event_id
        self.session_id = session_id

    def __repr__(self):
        return '<Invite %r>' % self.user_id

    def __str__(self):
        return self.__repr__()

    @property
    def serialize(self):
        """Return object data in easily serializable format"""

        return {
            'id': self.id,
            'user_id': self.user_id,
            'session_id': self.session_id
        }
Пример #9
0
class OrderDetails(db.Model, BaseModel):
	# table name
	__tablename__ = 'order_details'
	# displayed fields
	visible = ['id', 'ticket_id', 'order_id', 'count', 'price', 'created_at', 'updated_at']

	# columns definitions
	id = db.Column(db.Integer, primary_key=True)
	ticket_id = db.Column(
		db.String(40),
		db.ForeignKey('tickets.id'),
		nullable=False
	)
	ticket = db.relationship('Ticket')
	order_id = db.Column(
		db.String(180),
		db.ForeignKey('orders.id'),
		nullable=False
	)
	order = db.relationship('Order')
	count = db.Column(db.Integer)
	price = db.Column(db.Integer)
	created_at = db.Column(db.DateTime)
	updated_at = db.Column(db.DateTime)

	def __init__(self):
		self.created_at = datetime.datetime.now()
		self.updated_at = datetime.datetime.now()
Пример #10
0
class EmailNotification(SoftDeletionModel):
    """email notifications model class"""
    __tablename__ = 'email_notifications'
    id = db.Column(db.Integer, primary_key=True)
    next_event = db.Column(db.Boolean, default=False)
    new_paper = db.Column(db.Boolean, default=False)
    session_accept_reject = db.Column(db.Boolean, default=False)
    session_schedule = db.Column(db.Boolean, default=False)
    after_ticket_purchase = db.Column(db.Boolean, default=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='CASCADE'))
    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
    event = db.relationship("Event")
    user = db.relationship("User", backref="email_notifications")

    def __init__(self,
                 next_event=False,
                 new_paper=False,
                 session_accept_reject=False,
                 session_schedule=False,
                 after_ticket_purchase=True,
                 user_id=None,
                 event_id=None,
                 deleted_at=None):
        self.next_event = next_event
        self.new_paper = new_paper
        self.session_accept_reject = session_accept_reject
        self.session_schedule = session_schedule
        self.user_id = user_id
        self.event_id = event_id
        self.after_ticket_purchase = after_ticket_purchase
        self.deleted_at = deleted_at

    def __str__(self):
        return 'User:'******' Event: ' + self.event_id
Пример #11
0
class Spot(db.Model, BaseModel):

	# table name
	__tablename__ = 'spots'
	# displayed fields
	visible = ['id', 'beacon_id', 'stage_id', 'coordinate_x', 'coordinate_y', 'created_at', 'updated_at']

	# columns definitions
	id = db.Column(db.Integer, primary_key=True)
	beacon_id = db.Column(
		db.String(40),
		db.ForeignKey('beacons.id'),
		nullable=True
	)
	beacon = db.relationship('Beacon')
	stage_id = db.Column(
		db.String(40),
		db.ForeignKey('stages.id'),
		nullable=True
	)
	stage = db.relationship('Stage')
	coordinate_x = db.Column(db.Integer)
	coordinate_y = db.Column(db.Integer)
	created_at = db.Column(db.DateTime)
	updated_at = db.Column(db.DateTime)

	def __init__(self):
		self.created_at = datetime.datetime.now()
		self.updated_at = datetime.datetime.now()
class RoleInvite(SoftDeletionModel):
    __tablename__ = 'role_invites'
    __table_args__ = (UniqueConstraint('email',
                                       'role_id',
                                       'event_id',
                                       name='email_role_event_uc'), )

    id = db.Column(db.Integer, primary_key=True)

    email = db.Column(db.String, nullable=False)
    role_name = db.Column(db.String, nullable=False)

    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='CASCADE'))
    event = db.relationship('Event', back_populates='role_invites')

    role_id = db.Column(db.Integer,
                        db.ForeignKey('roles.id', ondelete='CASCADE'))
    role = db.relationship("Role")

    hash = db.Column(db.String, default=generate_hash)
    created_at = db.Column(db.DateTime(timezone=True), default=func.now())
    status = db.Column(db.String, default="pending")

    def has_expired(self):
        # Check if invitation link has expired (it expires after 24 hours)
        return datetime.now(pytz.utc) > self.created_at + timedelta(hours=24)

    def __repr__(self):
        return '<RoleInvite %r:%r:%r>' % (
            self.email,
            self.event_id,
            self.role_id,
        )
Пример #13
0
class AccessToken(db.Model, BaseModel):
    # table name
    __tablename__ = 'access_tokens'

    # visible fields
    visible = [
        'id', 'user_id', 'access_token', 'refresh_token', 'client_id',
        'created_at', 'updated_at'
    ]

    # columns definitions
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(40),
                        db.ForeignKey('users.id'),
                        nullable=False)
    user = db.relationship('User')
    client_id = db.Column(db.String(40),
                          db.ForeignKey('clients.id'),
                          nullable=False)
    client = db.relationship('Client')
    access_token = db.Column(db.String)
    refresh_token = db.Column(db.String)
    created_at = db.Column(db.DateTime)
    updated_at = db.Column(db.DateTime)

    def __init__(self):
        self.created_at = datetime.datetime.now()
        self.updated_at = datetime.datetime.now()

    def init_token(self, access_token, refresh_token, user_id):
        self.access_token = access_token
        self.refresh_token = refresh_token
        self.user_id = user_id
        return self
Пример #14
0
class Notification(db.Model, BaseModel):

	__tablename__ = 'notifications'

	visible = ['id', 'message', 'sender_uid', 'receiver_uid', 'type', 'attachment', 'created_at', 'updated_at']

	id = db.Column(db.Integer, primary_key=True)
	message = db.Column(db.Text)
	attachment = db.Column(db.String)
	sender_uid = db.Column(
		db.Integer,
		db.ForeignKey('users.id'),
		nullable=False
	)
	sender = db.relationship("User", foreign_keys=[sender_uid])
	receiver_uid = db.Column(
		db.Integer,
		db.ForeignKey('users.id'),
		nullable=False
	)
	receiver = db.relationship('User', foreign_keys=[receiver_uid])
	type = db.Column(db.String)
	created_at = db.Column(db.DateTime)
	updated_at = db.Column(db.DateTime)

	def __init__(self):
		self.created_at = datetime.now() + timedelta(hours=7) 
		self.updated_at = datetime.now() + timedelta(hours=7) 
Пример #15
0
class Feedback(SoftDeletionModel):
    """Feedback model class"""

    __tablename__ = 'feedback'
    __table_args__ = (db.UniqueConstraint('session_id',
                                          'user_id',
                                          name='session_user_uc'), )

    id = db.Column(db.Integer, primary_key=True)
    rating = db.Column(db.Float, nullable=False)
    comment = db.Column(db.String, nullable=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))
    event_id = db.Column(db.Integer,
                         db.ForeignKey('events.id', ondelete='CASCADE'))
    session_id = db.Column(db.Integer,
                           db.ForeignKey('sessions.id', ondelete='CASCADE'))

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        # TODO(Areeb): Test rating rounding on __init__
        rating = float(kwargs.get('rating'))
        self.rating = round(rating * 2, 0) / 2  # Rounds to nearest 0.5

    def __repr__(self):
        return '<Feedback %r>' % self.rating
Пример #16
0
class UserTicket(db.Model, BaseModel):

	# table name
	__tablename__ = 'user_tickets'
	# displayed fields
	visible = ['id', 'user_id', 'ticket_id', 'ticket_code']

	# columns definitions
	id = db.Column(db.Integer, primary_key=True)
	user_id = db.Column(
		db.Integer,
		db.ForeignKey('users.id'),
		nullable=False
	)
	user = db.relationship('User')
	ticket_id = db.Column(
		db.Integer,
		db.ForeignKey('tickets.id'),
		nullable=False)
	ticket = db.relationship('Ticket')
	ticket_code = db.Column(db.String)
	created_at = db.Column(db.DateTime)
	updated_at = db.Column(db.DateTime)

	def __init__(self):
		self.created_at = datetime.datetime.now()
		self.updated_at = datetime.datetime.now()
		codes = [r.ticket_code for r in db.session.query(UserTicket.ticket_code).all()]
		code = secrets.token_hex(8)
		while (code in codes):
			code = secrets.token_hex(8)
		self.ticket_code = code
Пример #17
0
class Interest(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    dog_id = db.Column(db.Integer, db.ForeignKey(
        'dog.id', ondelete="CASCADE"), nullable=False, unique=True)
    breed_id = db.Column(db.Integer, db.ForeignKey('breed.id'), nullable=False)
    gender_interest = db.Column(db.Boolean, nullable=False)
Пример #18
0
class UserFavouriteEvent(SoftDeletionModel):
    __tablename__ = 'user_favourite_events'

    id = db.Column(db.Integer, primary_key=True)
    event_id = db.Column(db.Integer, db.ForeignKey('events.id', ondelete='CASCADE'))
    user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='CASCADE'))
    event = db.relationship("Event")
Пример #19
0
class PointTransactionLog(db.Model, BaseModel):
    # table name
    __tablename__ = 'point_transaction_log'
    # displayed fields
    visible = [
        'id', 'booth_id', 'user_id', 'amount', 'created_at', 'updated_at'
    ]

    # columns definitions
    id = db.Column(db.Integer, primary_key=True)
    booth_id = db.Column(db.String(40),
                         db.ForeignKey('booths.id'),
                         nullable=False)
    booth = db.relationship('Booth')
    user_id = db.Column(db.String(40),
                        db.ForeignKey('users.id'),
                        nullable=False)
    user = db.relationship('User')
    amount = db.Column(db.Integer)
    created_at = db.Column(db.DateTime)
    updated_at = db.Column(db.DateTime)

    def __init__(self):
        self.created_at = datetime.datetime.now()
        self.updated_at = datetime.datetime.now()
Пример #20
0
class Need(db.Model):
    __tablename__ = 'needs'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    description = db.Column(db.String)
    estimated_tokens = db.Column(db.Integer)
    status = db.Column(db.String)
    speaker_conclusion = db.Column(db.String)
    team_conclusion = db.Column(db.String)
    used_tokens = db.Column(db.Integer)
    # creation_date = db.Column(db.DateTime)
    # validation_date = db.Column(db.DateTime)
    # close_date = db.Column(db.DateTime)

    id_assigned_team = db.Column(db.Integer, db.ForeignKey(Team.id, name="fk_assigned_team_id"))
    team = db.relationship('Team', lazy='joined')

    id_assigned_speaker = db.Column(db.Integer, db.ForeignKey(Speaker.id, name="fk_assigned_speaker_id"))
    speaker = db.relationship('Speaker', lazy='joined')

    def __repr__(self):
        return "<Need (id='{}, title='{}', description='{}', estimated_tokens='{}', status='{}, " \
               "speaker_conclusion='{}', team_conclusion='{}', close_date='{}', id_team='{}', id_speaker='{}')>".format(
                self.id, self.title, self.description, self.estimated_tokens, self.status, self.speaker_conclusion,
                self.team_conclusion, self.used_tokens, self.id_assigned_team, self.id_assigned_speaker)
Пример #21
0
class Schedule(db.Model, BaseModel):
	# table name
	__tablename__ = 'schedules'
	# displayed fields
	visible = ['id', 'event_id', 'stage_id', 'time_start', 'time_end', 'created_at', 'updated_at']

	# columns definitions
	id = db.Column(db.Integer, primary_key=True)
	event_id = db.Column(
		db.String(40),
		db.ForeignKey('events.id'),
		nullable=False
	)
	event = db.relationship('Event')

	stage_id = db.Column(
		db.String(40),
		db.ForeignKey('stages.id'),
		nullable=False
	)
	stage = db.relationship('Stage')
	time_start = db.Column(db.DateTime)
	time_end = db.Column(db.DateTime)
	created_at = db.Column(db.DateTime)
	updated_at = db.Column(db.DateTime)

	def __init__(self):
		self.created_at = datetime.datetime.now()
		self.updated_at = datetime.datetime.now()
Пример #22
0
class Permission(db.Model):
    """Role-Service Permissions"""

    __tablename__ = 'permissions'
    __table_args__ = (db.UniqueConstraint('role_id',
                                          'service_id',
                                          name='role_service_uc'), )

    id = db.Column(db.Integer, primary_key=True)

    role_id = db.Column(db.Integer,
                        db.ForeignKey('roles.id', ondelete='CASCADE'))
    role = db.relationship('Role')

    service_id = db.Column(db.Integer,
                           db.ForeignKey('services.id', ondelete='CASCADE'))
    service = db.relationship('Service')

    can_create = db.Column(db.Boolean, nullable=False, default=True)
    can_read = db.Column(db.Boolean, nullable=False, default=True)
    can_update = db.Column(db.Boolean, nullable=False, default=True)
    can_delete = db.Column(db.Boolean, nullable=False, default=True)

    def __repr__(self):
        return f'<Perm {self.role!r} for {self.service!r}>'
Пример #23
0
class TicketTransferLog(db.Model, BaseModel):

    # table name
    __tablename__ = 'ticket_transfer_logs'
    # displayed fields
    visible = [
        'user_ticket_id', 'sender_user_id', 'receiver_user_id', 'sender',
        'receiver', 'created_at', 'updated_at'
    ]

    # columns definitions
    id = db.Column(db.Integer, primary_key=True)
    user_ticket_id = db.Column(db.Integer)
    sender_user_id = db.Column(db.Integer,
                               db.ForeignKey('users.id'),
                               nullable=False)
    receiver_user_id = db.Column(db.Integer,
                                 db.ForeignKey('users.id'),
                                 nullable=False)
    sender = db.relationship("User", foreign_keys=[sender_user_id])
    receiver = db.relationship("User", foreign_keys=[receiver_user_id])
    created_at = db.Column(db.DateTime)
    updated_at = db.Column(db.DateTime)

    def __init__(self):
        self.created_at = datetime.datetime.now()
        self.updated_at = datetime.datetime.now()
Пример #24
0
class TaskResult(BaseMixin, db.Model):
    done = db.Column(db.Boolean, default=False)
    task_id = db.Column(db.Integer, db.ForeignKey('tasks.id'))
    student_id = db.Column(db.Integer, db.ForeignKey('students.id'))

    def __repr__(self):
        return "<TaskResult({id}|{done}|{task_id}<->{student_id})>".format(
            **self.__dict__)

    @classmethod
    def get_student_labs(cls, group_id, discipline):
        student_taskresults = {}

        results = TaskResult.query \
            .join(Task).join(Lab).join(Student) \
            .filter(Student.group_id == group_id, Lab.discipline_id == discipline.id)\
            .with_entities(Student.id, Task.id, TaskResult.done)

        for (student_id, task_id, done) in results:
            if student_id not in student_taskresults:
                student_taskresults[student_id] = {}
            if task_id not in student_taskresults[student_id]:
                student_taskresults[student_id][task_id] = done

        tasks = Task.query.filter(
            Task.lab_id.in_(discipline.labs.with_entities(Lab.id)))

        return student_taskresults, discipline.labs, tasks
Пример #25
0
class Dog(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), nullable=False)
    details = db.Column(db.String(300), nullable=True)
    owner_id = db.Column(db.Integer,
                         db.ForeignKey('owner.id', ondelete="CASCADE"))
    breed_id = db.Column(db.Integer, db.ForeignKey('breed.id'))
    gender = db.Column(db.Boolean, nullable=False)

    breed = db.relationship("Breed", backref="dog", cascade="all, delete")
    photos = db.relationship("Photo",
                             backref="dog",
                             cascade="all, delete",
                             passive_deletes=True)
    interest = db.relationship("Interest",
                               backref="dog",
                               cascade="all, delete")

    conversations = db.relationship('Conversation',
                                    secondary=dog_conversation,
                                    back_populates='dogs',
                                    cascade="all, delete")

    messages = db.relationship('Message',
                               back_populates='dogs',
                               cascade="all, delete",
                               passive_deletes=True)

    def __repr__(self):
        return f"<Dog {self.name} />"
Пример #26
0
class NewsComment(db.Model):
    __tablename__ = 'gk-news-comments'

    id = db.Column(
        'comment_id',
        db.Integer,
        primary_key=True,
        key='id'
    )
    news_id = db.Column(
        db.Integer,
        db.ForeignKey('gk-news.id'),
        nullable=False
    )
    author_id = db.Column(
        'user_id',
        db.Integer,
        db.ForeignKey('gk-users.id'),
        key='author_id',
        nullable=False
    )
    created_on_date = db.Column(
        'date',
        db.Date,
        key='created_on_date',
        default=datetime.datetime.now().date()
    )
    comment = db.Column(
        db.String(1000),
        nullable=False
    )
    icon = db.Column(
        db.Integer,
        default=0
    )
Пример #27
0
class RecipeXTag(BaseModel):
    __tablename__ = 'recipe_x_tag'

    recipe_id = db.Column(db.Integer,
                          db.ForeignKey('recipes.id'),
                          nullable=False)
    tag_id = db.Column(db.Integer, db.ForeignKey('tags.id'), nullable=False)
Пример #28
0
class AccessCode(SoftDeletionModel):
    __tablename__ = "access_codes"

    id: int = db.Column(db.Integer, primary_key=True)
    code: str = db.Column(db.String)
    access_url: str = db.Column(db.String)
    is_active: bool = db.Column(db.Boolean)
    tickets_number: int = db.Column(
        db.Integer)  # For event level access this holds the max. uses
    min_quantity: int = db.Column(db.Integer)
    max_quantity: int = db.Column(
        db.Integer
    )  # For event level access this holds the months for which it is valid
    valid_from: datetime = db.Column(db.DateTime(timezone=True), nullable=True)
    valid_till: datetime = db.Column(db.DateTime(timezone=True), nullable=True)
    ticket_id: int = db.Column(db.Integer,
                               db.ForeignKey('tickets.id', ondelete='CASCADE'))
    event_id: int = db.Column(db.Integer,
                              db.ForeignKey('events.id', ondelete='CASCADE'))
    created_at: datetime = db.Column(db.DateTime(timezone=True),
                                     default=func.now())
    marketer_id: int = db.Column(db.Integer,
                                 db.ForeignKey('users.id', ondelete='CASCADE'))

    marketer = db.relationship('User', backref='access_codes_')
    ticket = db.relationship('Ticket',
                             backref='access_code',
                             foreign_keys=[ticket_id])
    event = db.relationship('Event',
                            backref='access_codes',
                            foreign_keys=[event_id])

    @staticmethod
    def get_service_name():
        return 'access_code'
Пример #29
0
class SelectedRecipe(BaseModel):
    __tablename__ = 'selected_recipes'

    id = db.Column(db.Integer(), primary_key=True)
    recipe_id = db.Column(db.Integer,
                          db.ForeignKey('recipes.id'),
                          nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('tags.id'), nullable=False)
Пример #30
0
class ReportEvent(db.Model):
    """TODO add
    """
    __tablename__ = 'report_event'
    id = db.Column(db.Integer, primary_key=True, unique=True, nullable=False)

    report_id = db.Column(db.Integer, db.ForeignKey('report.id'))
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'))