Example #1
0
class ElectionCandidatePollingStationVote(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    election_candidate_id = db.Column(db.Integer,
                                      db.ForeignKey('election_candidate.id'))
    polling_station_id = db.Column(db.Integer,
                                   db.ForeignKey('polling_station.id'))
    votes = db.Column(db.Integer)

    polling_station = db.relationship('PollingStation',
                                      backref=db.backref(
                                          "ecpollingstationvotes",
                                          cascade="all,delete-orphan"),
                                      lazy='joined')
    election_candidate = db.relationship('ElectionCandidate',
                                         backref=db.backref(
                                             "ecpollingstationvotes",
                                             cascade="all,delete-orphan",
                                             lazy='joined'))

    def __repr__(self):
        pass

    def __json__(self):
        return [self.polling_station_id, self.electioncandidate, self.votes]
Example #2
0
class PollingStationRegister(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_id = db.Column(db.Integer, db.ForeignKey('election.id'))
    polling_station_id = db.Column(db.Integer,
                                   db.ForeignKey('polling_station.id'))
    number_of_registered_voters = db.Column(db.Integer)

    polling_station = db.relationship('PollingStation',
                                      backref=db.backref("elections_register"))
    election = db.relationship('Election',
                               backref=db.backref('polling_stations_register',
                                                  lazy='joined'))
Example #3
0
class ConstituencyRegister(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_id = db.Column(db.Integer, db.ForeignKey('election.id'))
    constituency_id = db.Column(db.Integer, db.ForeignKey('constituency.id'))
    number_of_registered_voters = db.Column(db.Integer)

    constituency = db.relationship('Constituency',
                                   backref=db.backref('election_registers',
                                                      lazy='joined'))
    election = db.relationship('Election',
                               backref=db.backref('constituencies_register',
                                                  lazy='joined'))
Example #4
0
class Constituency(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40))
    region_id = db.Column(db.Integer, db.ForeignKey('region.id'))

    #simple one to many relationship1
    polling_stations = db.relationship('PollingStation',
                                       backref='constituency',
                                       lazy='dynamic')

    #many to many relationship type1
    elections = db.relationship('ElectionConstituency', backref='constituency')

    def __repr__(self):
        return "<Constituence > %r" % self.name
Example #5
0
class Region(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    constituencies = db.relationship('Constituency',
                                     backref='region',
                                     lazy='dynamic')
    code = db.Column(db.String(4))

    def __repr__(self):
        return "<Region> %r  %r" % (self.name, self.code)
Example #6
0
class ElectionType(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(db.String(20), unique=True)
    elections = db.relationship('Election',
                                backref=db.backref('electiontype',
                                                   lazy="joined"),
                                lazy='dynamic')

    def __repr__(self):
        return " <ElectionType> %r" % self.type
Example #7
0
class Iteration(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(12))

    elections = db.relationship('Election',
                                backref="iteration",
                                lazy='dynamic')

    def __repr__(self):
        return "<Iteration %r>" % self.description
Example #8
0
class PollingStation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40))
    constituency_id = db.Column(db.Integer, db.ForeignKey('constituency.id'))

    elections = db.relationship('ElectionPollingStation',
                                backref='pollinstation')

    def __repr__(self):
        return "<Constituency > %r" % self.name
Example #9
0
class Candidate(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(70))
    last_name = db.Column(db.String(140))
    avartar = db.Column(db.String(140))

    #elections a candidate has participated in
    elections = db.relationship('ElectionCandidate', backref='candidate')

    def __repr__(self):
        return "<Candidate>  %r %r" % (self.first_name, self.last_name)
Example #10
0
class Incident(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(240))
    election_polling_station_id = db.Column(
        db.Integer, db.ForeignKey('election_polling_station.id'))
    election_constituency_id = db.Column(
        db.Integer, db.ForeignKey('election_constituency.id'))
    status_type_id = db.Column(db.Integer, db.ForeignKey('incident_status.id'))

    election_polling_station = db.relationship('ElectionPollingStation',
                                               backref=db.backref(
                                                   'incidents', lazy="joined"))

    election_constituency = db.relationship('ElectionConstituency',
                                            backref=db.backref('incidents', ))

    status = db.relationship('IncidentStatus', backref="incidents")

    def __repr__(self):
        return "<Incident>  %r constituency: %r status: %r, " % (
            self.description, self.election_constituency, self.status)
Example #11
0
class Party(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(45))
    avartar = db.Column(db.String(70))
    code = db.Column(db.String(10))

    #election candidates
    election_candidates = db.relationship("ElectionCandidate",
                                          backref="party",
                                          lazy="dynamic")

    def __repr__(self):
        return "<Party>  %r (%r)" % (self.name, self.code)
Example #12
0
class ElectionCandidateConstituencyVote(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_candidate_id = db.Column(db.Integer,
                                      db.ForeignKey('election_candidate.id'))
    constituency_id = db.Column(db.Integer, db.ForeignKey('constituency.id'))
    votes = db.Column(db.Integer)

    constituency = db.relationship('Constituency',
                                   backref=db.backref(
                                       "ecconstituencyvotes",
                                       cascade="all,delete-orphan"))

    election_candidate = db.relationship('ElectionCandidate',
                                         backref=db.backref(
                                             "ecconstituencyvotes",
                                             cascade="all,delete-orphan"))

    def __repr__(self):
        return "Election: %r ,Candidate %r , Constituency %r votes %r" % (
            self.election_candidate.election,
            self.election_candidate.candidate, self.constituency, self.votes)

    def __json__(self):
        return [self.constituency, self.electioncandidate, self.votes]
Example #13
0
class ElectionCandidate(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_id = db.Column(db.Integer, db.ForeignKey('election.id'))
    candidate_id = db.Column(db.Integer, db.ForeignKey('candidate.id'))
    party_id = db.Column(db.Integer, db.ForeignKey('party.id'))

    #what the f**k is this? = elections and candidates for a particular election
    election = db.relationship('Election', backref="electioncandidates")

    def __repr__(self):
        return "<Election  %r party: %r Election: %r>" % (
            self.candidate, self.party, self.election)

    def __json__(self):

        return [self.candidate, self.election, self.party]
Example #14
0
class ElectionConstituency(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_id = db.Column(db.Integer, db.ForeignKey('election.id'))
    constituency_id = db.Column(db.Integer, db.ForeignKey('constituency.id'))
    number_of_registered_voters = db.Column(db.Integer)

    #many to many type1
    election = db.relationship('Election',
                               backref="constituency_electionconstituencies")

    def __repr__(self):
        return "<Election  %r : %r Constituency:  Total Registered Voters %r>" % (
            self.election, self.constituency, self.number_of_registered_voters)

    def __json__(self):

        return [self.candidate, self.election, self.party]
Example #15
0
class ElectionPollingStation(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    election_id = db.Column(db.Integer, db.ForeignKey('election.id'))
    polling_station_id = db.Column(db.Integer,
                                   db.ForeignKey('polling_station.id'))
    number_of_registered_voters = db.Column(db.Integer)

    #what the f**k is this? = elections and candidates for a particular election
    election = db.relationship(
        'Election', backref="pollingstation_electionpollingstations")

    def __repr__(self):
        return "<ElectionPollingStation> Election:%r : %r Polling Station:  Total Registered Voters: %r>" % (
            self.election, self.polling_station, self.total_registered_voters)

    def __json__(self):

        return [
            self.election, self.pooling_station,
            self.number_of_registered_voters
        ]
Example #16
0
class Role(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    rolename = db.Column(db.String(64))

    users = db.relationship('User', backref="role")