Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dinukadesilva committed Nov 2, 2019
1 parent 95020a1 commit 68300d5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 49 deletions.
7 changes: 2 additions & 5 deletions orm/entities/Area/Electorate/AdministrativeDistrict.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from app import db
from orm.entities.Area import Electorate
from orm.entities.Area.Electorate import Province
from orm.enums import ElectorateTypeEnum, AreaTypeEnum
from exception import NotFoundException
from sqlalchemy.orm import relationship, synonym
from orm.enums import AreaTypeEnum
from sqlalchemy.orm import synonym
from sqlalchemy.ext.associationproxy import association_proxy


Expand Down
6 changes: 1 addition & 5 deletions orm/entities/Area/Electorate/ElectoralDistrict.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from app import db
from orm.entities.Area import Electorate
from orm.entities.Area.Electorate import Country
from orm.enums import ElectorateTypeEnum, AreaTypeEnum
from exception import NotFoundException
from orm.enums import AreaTypeEnum
from sqlalchemy.orm import synonym
from sqlalchemy.ext.associationproxy import association_proxy


class ElectoralDistrictModel(Electorate.Model):
Expand Down
3 changes: 0 additions & 3 deletions orm/entities/Area/Electorate/PollingDistrict.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from app import db
from orm.entities.Area import Electorate
from orm.entities.Area.Electorate import PollingDivision
from orm.enums import AreaTypeEnum
from exception import NotFoundException
from sqlalchemy.orm import synonym
from sqlalchemy.ext.associationproxy import association_proxy

Expand Down
7 changes: 2 additions & 5 deletions orm/entities/Area/Electorate/PollingDivision.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from app import db
from orm.entities import Electorate
from orm.entities.Area.Electorate import ElectoralDistrict
from orm.enums import ElectorateTypeEnum, AreaTypeEnum
from exception import NotFoundException
from sqlalchemy.orm import relationship, synonym
from orm.enums import AreaTypeEnum
from sqlalchemy.orm import synonym
from sqlalchemy.ext.associationproxy import association_proxy


Expand Down
9 changes: 2 additions & 7 deletions orm/entities/Area/Electorate/Province.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
from app import db
from orm.entities import Electorate
from orm.entities.Area.Electorate import Country
from orm.enums import ElectorateTypeEnum, AreaTypeEnum
from exception import NotFoundException
from sqlalchemy.orm import relationship, synonym
from orm.enums import AreaTypeEnum
from sqlalchemy.orm import synonym


class ProvinceModel(Electorate.Model):
# parentElectorateId = db.Column(db.Integer, db.ForeignKey("electorateId"), nullable=True)

country = synonym("parentElectorate")

__mapper_args__ = {
Expand Down
42 changes: 21 additions & 21 deletions orm/entities/Election/election_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ def get_root_token(electionId):
AREA_CLAIM_PREFIX + DATA_EDITOR_ROLE: str([{
"areaId": electoral_district.areaId
} for electoral_district in electoral_districts]),
AREA_CLAIM_PREFIX + POLLING_DIVISION_REPORT_VIEWER_ROLE: str([{
"areaId": electoral_district.areaId
} for electoral_district in electoral_districts]),
AREA_CLAIM_PREFIX + POLLING_DIVISION_REPORT_VERIFIER_ROLE: str([{
"areaId": electoral_district.areaId
} for electoral_district in electoral_districts]),
AREA_CLAIM_PREFIX + ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE: str([{
"areaId": electoral_district.areaId
} for electoral_district in electoral_districts]),
AREA_CLAIM_PREFIX + ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: str([{
"areaId": electoral_district.areaId
} for electoral_district in electoral_districts]),
AREA_CLAIM_PREFIX + NATIONAL_REPORT_VIEWER_ROLE: str([{
"areaId": country.areaId
} for country in countries]),
AREA_CLAIM_PREFIX + NATIONAL_REPORT_VERIFIER_ROLE: str([{
"areaId": country.areaId
} for country in countries]),
AREA_CLAIM_PREFIX + EC_LEADERSHIP_ROLE: str([{
"areaId": country.areaId
} for country in countries])
# AREA_CLAIM_PREFIX + POLLING_DIVISION_REPORT_VIEWER_ROLE: str([{
# "areaId": electoral_district.areaId
# } for electoral_district in electoral_districts]),
# AREA_CLAIM_PREFIX + POLLING_DIVISION_REPORT_VERIFIER_ROLE: str([{
# "areaId": electoral_district.areaId
# } for electoral_district in electoral_districts]),
# AREA_CLAIM_PREFIX + ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE: str([{
# "areaId": electoral_district.areaId
# } for electoral_district in electoral_districts]),
# AREA_CLAIM_PREFIX + ELECTORAL_DISTRICT_REPORT_VERIFIER_ROLE: str([{
# "areaId": electoral_district.areaId
# } for electoral_district in electoral_districts]),
# AREA_CLAIM_PREFIX + NATIONAL_REPORT_VIEWER_ROLE: str([{
# "areaId": country.areaId
# } for country in countries]),
# AREA_CLAIM_PREFIX + NATIONAL_REPORT_VERIFIER_ROLE: str([{
# "areaId": country.areaId
# } for country in countries]),
# AREA_CLAIM_PREFIX + EC_LEADERSHIP_ROLE: str([{
# "areaId": country.areaId
# } for country in countries])
}

# Generate a token with claims for everything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

from app import db

from orm.entities import Candidate
from orm.entities.Election import ElectionCandidate, InvalidVoteCategory
from exception import NotFoundException
from orm.entities.Election import InvalidVoteCategory
from orm.entities.SubmissionVersion import TallySheetVersion


Expand Down

0 comments on commit 68300d5

Please sign in to comment.