class User(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(200), nullable=False, unique=True) passphrase = db.Column(db.String(400), nullable=False) name = db.Column(db.String(200), nullable=False) role = db.Column(db.Enum(Role), nullable=False) country = db.Column(db.String(60), nullable=False) phone = db.Column(db.String(18), nullable=True) # ITU E.165 limits numbers to 15 digits proposals = db.relationship('Proposal', back_populates='proposer') scores = db.relationship('Score', back_populates='scorer') comments_for_proposer = db.relationship('CommentForProposer', back_populates='commenter') comments_for_committee = db.relationship('CommentForCommittee', back_populates='commenter') def __init__(self, email, passphrase, name, country, phone=None, role=Role.user): self.email = email self.passphrase = passphrase self.name = name self.role = role self.country = country self.phone = phone
class Proposal(db.Model): id = db.Column(db.Integer, primary_key=True) proposer_id = db.Column(db.Integer, db.ForeignKey('user.id')) proposer = db.relationship('User', back_populates='proposals') title = db.Column(db.String(150), nullable=False) session_type = db.Column(db.Enum(SessionType), nullable=False) text = db.Column(db.Text, nullable=False) notes = db.Column(db.Text, nullable=True) presenters = association_proxy('proposal_presenters', 'presenter') audience = db.Column(db.Enum(SessionAudience), nullable=False) category = db.Column(db.Enum(SessionCategory), nullable=False) scores = db.relationship('Score', back_populates='proposal') comments = db.relationship('Comment', back_populates='proposal') status = db.Column(db.Enum(ProposalState), nullable=False) # day, session, quickie_slot, track, room, slides_pdf, video_url are only non empty # when status is accepted. day = db.Column(db.Enum(ConferenceDay)) session = db.Column(db.Enum(SessionSlot)) quickie_slot = db.Column( db.Enum(QuickieSlot)) # Only not empty if session_type == quickie. track = db.Column(db.Enum(Track)) room = db.Column(db.Enum(Room)) # slides_pdf and video_url can only be completed after the conference. slides_pdf = db.Column(db.String(100)) video_url = db.Column(db.String(100)) def __init__(self, proposer, title, session_type, text, notes='', audience=SessionAudience.all, category=SessionCategory.not_sure, status=ProposalState.submitted, day=None, session=None, quickie_slot=None, track=None, room=None, slides_pdf=None, video_url=None): self.proposer = proposer self.title = title self.session_type = session_type self.text = text self.notes = notes self.audience = audience self.category = category self.status = status self.day = day self.session = session self.quickie_slot = quickie_slot self.track = track self.room = room self.slides_pdf = slides_pdf self.video_url = video_url
class Proposal(db.Model): id = db.Column(db.Integer, primary_key=True) proposer_id = db.Column(db.Integer, db.ForeignKey('user.id')) proposer = db.relationship('User', back_populates='proposals') title = db.Column(db.String(150), nullable=False) summary = db.Column(db.Text, nullable=False) session_type = db.Column(db.Enum(SessionType), nullable=False) audience = db.Column(db.Enum(SessionAudience), nullable=False) keywords = db.Column(db.String(100), nullable=True) no_video = db.Column(db.Boolean, nullable=False) notes = db.Column(db.Text, nullable=True) constraints = db.Column(db.Text, nullable=True) status = db.Column(db.Enum(ProposalState), nullable=False) # day, session, quickie_slot, track, room, slides_pdf, video_url are only non empty # when status is accepted. day = db.Column(db.Enum(ConferenceDay)) session = db.Column(db.Enum(SessionSlot)) quickie_slot = db.Column( db.Enum(QuickieSlot)) # Only not empty if session_type == quickie. room = db.Column(db.Enum(Room)) presenters = association_proxy('proposal_presenters', 'presenter') scores = db.relationship('Score', back_populates='proposal') comments_for_proposer = db.relationship('CommentForProposer', back_populates='proposal') comments_for_committee = db.relationship('CommentForCommittee', back_populates='proposal') def __init__(self, proposer, title, summary, session_type, audience=SessionAudience.all, keywords='', no_video=False, notes='', constraints='', status=ProposalState.submitted, day=None, session=None, quickie_slot=None, room=None): self.proposer = proposer self.title = title self.summary = summary self.session_type = session_type self.audience = audience self.keywords = keywords self.no_video = no_video self.notes = notes self.constraints = constraints self.status = status self.day = day self.session = session self.quickie_slot = quickie_slot self.room = room
class Score(db.Model): id = db.Column(db.Integer, primary_key=True) proposal_id = db.Column(db.Integer, db.ForeignKey('proposal.id')) scorer_id = db.Column(db.Integer, db.ForeignKey('user.id')) proposal = db.relationship('Proposal', back_populates='scores') scorer = db.relationship('User', back_populates='scores') score = db.Column(db.Integer) def __init__(self, proposal, scorer, score): self.proposal = proposal self.scorer = scorer self.score = score
class CommentForCommittee(db.Model): id = db.Column(db.Integer, primary_key=True) proposal_id = db.Column(db.Integer, db.ForeignKey('proposal.id')) commenter_id = db.Column(db.Integer, db.ForeignKey('user.id')) proposal = db.relationship('Proposal', back_populates='comments_for_committee') commenter = db.relationship('User', back_populates='comments_for_committee') comment = db.Column(db.Text) def __init__(self, proposal, commenter, comment): self.proposal = proposal self.commenter = commenter self.comment = comment
class ProposalPresenter(db.Model): proposal_id = db.Column(db.Integer, db.ForeignKey('proposal.id'), primary_key=True) presenter_id = db.Column(db.Integer, db.ForeignKey('presenter.id'), primary_key=True) proposal = db.relationship(Proposal, backref='proposal_presenters') presenter = db.relationship(Presenter, backref='presenter_proposals') is_lead = db.Column(db.Boolean, nullable=False) def __init__(self, proposal, presenter, is_lead): self.proposal = proposal self.presenter = presenter self.is_lead = is_lead
class User(db.Model): __tablename__ = 'users' user_id = db.Column(db.String(100), primary_key=True) user_pass = db.Column(db.String(512), nullable=False) user_info = db.relationship('UserInfo', uselist=False, backref=db.backref('user')) location = db.relationship('UserLocation', uselist=False) proposal = db.relationship('Proposal', uselist=False, backref=db.backref('proposed_by'), foreign_keys="Proposal.proposer") def __init__(self, userid, userpass): if userid is None or len(userid.strip()) == 0: raise AttributeError("Email cannot be empty") if userpass is None or len(userpass.strip()) < 8: raise AttributeError("Password should have at least 8 " "letters/numbers.") self.user_id = userid self.user_pass = userpass
class Proposal(db.Model): __tablename__ = "proposals" id = db.Column(db.Integer, primary_key=True) proposer = db.Column(db.String(100), db.ForeignKey('users.user_id')) title = db.Column(db.String(150), nullable=False) session_type = db.Column(db.String(20), nullable=False) text = db.Column(db.Text, nullable=False) presenters = db.relationship('ProposalPresenter', uselist=True) status = db.relationship('ProposalStatus', uselist=False) reviews = db.relationship('ProposalReview', uselist=True) comments = db.relationship('ProposalComment', uselist=True) categories = db.relationship('ProposalCategory', uselist=True) session_proposer = db.relationship('User', foreign_keys='Proposal.proposer') def __init__(self, proposer, title, session_type, text): self.proposer = proposer self.title = title if issubclass(type(session_type), ProposalType): self.session_type = session_type.proposalType() else: raise TypeError( "session_type should be of type accuconf.proposals.ProposalType" ) self.text = text
class User(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(200), nullable=False, unique=True) passphrase = db.Column(db.String(400), nullable=False) name = db.Column(db.String(200), nullable=False) role = db.Column(db.Enum(Role), nullable=False) street_address = db.Column(db.String(400), nullable=False) town_city = db.Column(db.String(30), nullable=False) state = db.Column(db.String(40), nullable=True) postal_code = db.Column(db.String(20), nullable=False) country = db.Column(db.String(60), nullable=False) phone = db.Column(db.String(18), nullable=True) # ITU E.165 limits numbers to 15 digits proposals = db.relationship('Proposal', back_populates='proposer') scores = db.relationship('Score', back_populates='scorer') comments = db.relationship('Comment', back_populates='commenter') def __init__(self, email, passphrase, name, street_address, town_city, postal_code, country, state=None, phone=None, role=Role.user): self.email = email self.passphrase = passphrase self.name = name self.role = role self.street_address = street_address self.town_city = town_city self.state = state self.postal_code = postal_code self.country = country self.phone = phone