|
@@ -67,12 +67,12 @@ class User(db.Model, UserMixin):
|
|
|
return argon2.check_password_hash(self.password, password)
|
|
|
|
|
|
|
|
|
- function_id = db.Column(
|
|
|
+ option_id = db.Column(
|
|
|
db.Integer,
|
|
|
- db.ForeignKey("function.id")
|
|
|
+ db.ForeignKey("option.id")
|
|
|
)
|
|
|
user = db.relationship(
|
|
|
- "Function",
|
|
|
+ "Option",
|
|
|
backref=db.backref("users", lazy="dynamic")
|
|
|
)
|
|
|
|
|
@@ -223,25 +223,25 @@ class Vote(db.Model):
|
|
|
)
|
|
|
|
|
|
|
|
|
-election_function = db.Table(
|
|
|
- 'election_function',
|
|
|
+multiple_choise_option = db.Table(
|
|
|
+ 'multiple_choise_option',
|
|
|
db.Column(
|
|
|
- 'election_id',
|
|
|
+ 'multiple_choise_id',
|
|
|
db.Integer,
|
|
|
- db.ForeignKey('election.id'),
|
|
|
+ db.ForeignKey('multiple_choise.id'),
|
|
|
primary_key=True
|
|
|
),
|
|
|
db.Column(
|
|
|
- 'function_id',
|
|
|
+ 'option_id',
|
|
|
db.Integer,
|
|
|
- db.ForeignKey('function.id'),
|
|
|
+ db.ForeignKey('option.id'),
|
|
|
primary_key=True
|
|
|
)
|
|
|
)
|
|
|
|
|
|
|
|
|
-class Election(db.Model):
|
|
|
- """Model for Election"""
|
|
|
+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)
|
|
@@ -249,17 +249,17 @@ class Election(db.Model):
|
|
|
description = db.Column(db.String)
|
|
|
|
|
|
|
|
|
-class Function(db.Model):
|
|
|
- """Model for Function"""
|
|
|
+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)
|
|
|
|
|
|
- elections = db.relationship(
|
|
|
- 'Election',
|
|
|
- secondary=election_function,
|
|
|
+ multiple_choises = db.relationship(
|
|
|
+ 'Multiple_choise',
|
|
|
+ secondary=multiple_choise_option,
|
|
|
lazy='subquery',
|
|
|
- backref=db.backref('functions', lazy=True)
|
|
|
+ backref=db.backref('options', lazy=True)
|
|
|
)
|
|
|
|
|
|
|
|
@@ -277,11 +277,11 @@ class Candidate(db.Model):
|
|
|
backref=db.backref("eligible", lazy="dynamic")
|
|
|
)
|
|
|
|
|
|
- function_id = db.Column(
|
|
|
+ option_id = db.Column(
|
|
|
db.Integer,
|
|
|
- db.ForeignKey("function.id")
|
|
|
+ db.ForeignKey("option.id")
|
|
|
)
|
|
|
user = db.relationship(
|
|
|
- "Function",
|
|
|
+ "Option",
|
|
|
backref=db.backref("candidates", lazy="dynamic")
|
|
|
)
|