class Page(Base): __tablename__ = 'page' name = C(String(255), primary_key=True) lang = C(String(16), primary_key=True) title = C(String(255)) text = C(Text) permissions = C(JSON)
class VotingPhaseType(Base): __tablename__ = 'voting_phase_types' id = integer_pk() name = C(Text, server_default='', comment='readable name') abbreviation = C(Text, server_default='', comment='abbreviated name') secret_voting_possible = C(Boolean, nullable=False) voting_type = C(Enum(VotingType), nullable=False) # online, urn, assembly, board
class VotingModule(Base): __tablename__ = "voting_module" id = integer_pk() name = C(String(16), unique=True, nullable=False) description = C(Text) base_url = C(URLType, nullable=False) module_type = C(String(16), nullable=False) __mapper_args__ = {"polymorphic_on": module_type}
class User(Base): __tablename__ = 'users' id = Column(Integer, Sequence('id_seq', optional=True), primary_key=True) name = Column(String(64), unique=True, nullable=False) email = Column( EmailType, unique=True, comment='optional, for notifications, otherwise use user/mails/') auth_type = Column( String(8), nullable=False, server_default='system', comment='deleted,system,token,virtual,oauth(has UserProfile)') joined = Column(DateTime, nullable=False, server_default=func.now()) active = Column(Boolean, nullable=False, server_default='true') last_active = Column( DateTime, nullable=False, server_default=func.now(), comment='last relevant activity (to be considered active member §2.2)') can_login_until = C( DateTime, comment= 'optional expiration datetime after which login is no longer possible') # actions: submit/support proposition, voting, or explicit, deactivate after 2 periods profile = relationship("UserProfile", uselist=False, back_populates="user") groups = association_proxy('member_groups', 'group') # <-GroupMember-> Group # from user/membership/ all_nested_groups departments = association_proxy( 'member_departments', 'department') # <-DepartmentMember-> Department areas = association_proxy('member_areas', 'area') # <-AreaMember-> SubjectArea supports = association_proxy('member_propositions', 'proposition') # <-Supporter-> Proposition arguments = relationship("Argument", back_populates="author") secret_voters = association_proxy('member_secretvoters', 'secretvoter') # <-SecretVoter-> Ballot urns = association_proxy('member_urns', 'urn') # <-UrnSupporter-> Urn postal_votes = association_proxy('member_postal', 'voting') # <-PostalVote-> VotingPhase @property def managed_departments(self): return [md.department for md in self.member_departments if md.is_admin]
class Policy(Base): # Regelwerk __tablename__ = 'policies' id = Column(Integer, Sequence('id_seq', optional=True), primary_key=True) name = Column(String(64), unique=True, nullable=False) description = Column(Text, server_default='') proposition_types = relationship("PropositionType", back_populates="policy") majority = C(Enum(Majority)) proposition_expiration = C( Integer, comment='days to reach the qualification (supporter) quorum') qualification_minimum = C(Integer, comment='minimum for qualification quorum') qualification_quorum = C( Numeric(3, 2), comment= 'fraction of area members that must support a proposition for reaching the qualified state' ) range_max = C( Integer, comment= 'maximum score used when the number of options is at least `range_small_options`' ) range_small_max = C( Integer, comment= 'maximum score used when the number of options is less than `range_small_options`' ) range_small_options = C( Integer, comment= 'largest number of options for which `range_small_max` is used as maximum score' ) secret_minimum = C(Integer, comment='minimum for secret voting quorum') secret_quorum = C(Numeric(3, 2), comment='quorum to force a secret voting') submitter_minimum = C( Integer, comment='minimum number of submitters for a proposition') voting_duration = C(Integer, comment='voting duration in days; ends at target date') voting_system = C(Enum(VotingSystem)) """
class UserLoginToken(Base): __tablename__ = 'user_login_token' token = C(String(36), primary_key=True) user_id = C(Integer, ForeignKey('users.id')) user = relationship("User", backref=backref("login_token", uselist=False)) valid_until = Column(DateTime)