|
@@ -67,12 +67,12 @@ class User(db.Model, UserMixin):
|
|
|
return argon2.check_password_hash(self.password, password)
|
|
|
|
|
|
|
|
|
- option_id = db.Column(
|
|
|
+ question_id = db.Column(
|
|
|
db.Integer,
|
|
|
- db.ForeignKey("option.id")
|
|
|
+ db.ForeignKey("question.id")
|
|
|
)
|
|
|
user = db.relationship(
|
|
|
- "Option",
|
|
|
+ "Question",
|
|
|
backref=db.backref("users", lazy="dynamic")
|
|
|
)
|
|
|
|
|
@@ -163,9 +163,8 @@ class File(db.Model):
|
|
|
backref=db.backref('pages', lazy=True)
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-class Motion(db.Model):
|
|
|
- """Model for Motion"""
|
|
|
+class Ballot(db.Model):
|
|
|
+ """Model for Ballot"""
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
name = db.Column(db.String, nullable=False)
|
|
|
description = db.Column(db.String)
|
|
@@ -178,7 +177,7 @@ class Motion(db.Model):
|
|
|
)
|
|
|
user = db.relationship(
|
|
|
"User",
|
|
|
- backref=db.backref("motions", lazy="dynamic")
|
|
|
+ backref=db.backref("options", lazy="dynamic")
|
|
|
)
|
|
|
|
|
|
priority_id = db.Column(
|
|
@@ -187,7 +186,7 @@ class Motion(db.Model):
|
|
|
)
|
|
|
priority = db.relationship(
|
|
|
"Priority",
|
|
|
- backref=db.backref("motions", lazy="dynamic")
|
|
|
+ backref=db.backref("options", lazy="dynamic")
|
|
|
)
|
|
|
|
|
|
|
|
@@ -198,74 +197,25 @@ class Priority(db.Model):
|
|
|
description = db.Column(db.String, nullable=False)
|
|
|
|
|
|
|
|
|
-class Vote(db.Model):
|
|
|
- """Model for Vote"""
|
|
|
+class Question(db.Model):
|
|
|
+ """Model for Question"""
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
- value = db.Column(db.Boolean)
|
|
|
- datetime = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
-
|
|
|
- motion_id = db.Column(
|
|
|
- db.Integer,
|
|
|
- db.ForeignKey("motion.id")
|
|
|
- )
|
|
|
- motion = db.relationship(
|
|
|
- "Motion",
|
|
|
- backref=db.backref("votes", lazy="dynamic")
|
|
|
- )
|
|
|
+ name = db.Column(db.String, nullable=False)
|
|
|
+ description = db.Column(db.String)
|
|
|
|
|
|
- candidate_id = db.Column(
|
|
|
+ ballot_id = db.Column(
|
|
|
db.Integer,
|
|
|
- db.ForeignKey("candidate.id")
|
|
|
- )
|
|
|
- motion = db.relationship(
|
|
|
- "Candidate",
|
|
|
- backref=db.backref("votes", lazy="dynamic")
|
|
|
+ db.ForeignKey("user.id")
|
|
|
)
|
|
|
-
|
|
|
-
|
|
|
-multiple_choise_option = db.Table(
|
|
|
- 'multiple_choise_option',
|
|
|
- db.Column(
|
|
|
- 'multiple_choise_id',
|
|
|
- db.Integer,
|
|
|
- db.ForeignKey('multiple_choise.id'),
|
|
|
- primary_key=True
|
|
|
- ),
|
|
|
- db.Column(
|
|
|
- 'option_id',
|
|
|
- db.Integer,
|
|
|
- db.ForeignKey('option.id'),
|
|
|
- primary_key=True
|
|
|
+ ballot = db.relationship(
|
|
|
+ "Ballot",
|
|
|
+ backref=db.backref("questions", lazy="dynamic")
|
|
|
)
|
|
|
-)
|
|
|
-
|
|
|
-
|
|
|
-class Multiple_choise(db.Model):
|
|
|
- """Model for Multiple_choise"""
|
|
|
- id = db.Column(db.Integer, primary_key=True)
|
|
|
- start_at = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
- end_at = db.Column(db.DateTime, nullable=False)
|
|
|
- name = db.Column(db.String, nullable=False)
|
|
|
- description = db.Column(db.String)
|
|
|
|
|
|
|
|
|
class Option(db.Model):
|
|
|
"""Model for Option"""
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
- name = db.Column(db.String, nullable=False)
|
|
|
- description = db.Column(db.String)
|
|
|
-
|
|
|
- multiple_choises = db.relationship(
|
|
|
- 'Multiple_choise',
|
|
|
- secondary=multiple_choise_option,
|
|
|
- lazy='subquery',
|
|
|
- backref=db.backref('options', lazy=True)
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-class Candidate(db.Model):
|
|
|
- """Model for Candidate"""
|
|
|
- id = db.Column(db.Integer, primary_key=True)
|
|
|
motivation = db.Column(db.String)
|
|
|
|
|
|
user_id = db.Column(
|
|
@@ -277,11 +227,35 @@ class Candidate(db.Model):
|
|
|
backref=db.backref("eligible", lazy="dynamic")
|
|
|
)
|
|
|
|
|
|
+ question_id = db.Column(
|
|
|
+ db.Integer,
|
|
|
+ db.ForeignKey("question.id")
|
|
|
+ )
|
|
|
+ question = db.relationship(
|
|
|
+ "Question",
|
|
|
+ backref=db.backref("options", lazy="dynamic")
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+class Vote(db.Model):
|
|
|
+ """Model for Vote"""
|
|
|
+ id = db.Column(db.Integer, primary_key=True)
|
|
|
+ datetime = db.Column(db.DateTime, default=datetime.utcnow)
|
|
|
+
|
|
|
option_id = db.Column(
|
|
|
db.Integer,
|
|
|
db.ForeignKey("option.id")
|
|
|
)
|
|
|
+ option = db.relationship(
|
|
|
+ "Motion",
|
|
|
+ backref=db.backref("votes", lazy="dynamic")
|
|
|
+ )
|
|
|
+
|
|
|
+ user_id = db.Column(
|
|
|
+ db.Integer,
|
|
|
+ db.ForeignKey("user.id")
|
|
|
+ )
|
|
|
user = db.relationship(
|
|
|
- "Option",
|
|
|
- backref=db.backref("candidates", lazy="dynamic")
|
|
|
+ "User",
|
|
|
+ backref=db.backref("votes", lazy="dynamic")
|
|
|
)
|