From 5fc2b4685d355623bcfedfee6bce102453fa515b Mon Sep 17 00:00:00 2001 From: Umayanga Prabhash Gunawardhana Date: Thu, 31 Oct 2019 14:52:27 +0530 Subject: [PATCH 1/3] add preferences schema --- .../TallySheetVersion_PRE_34_CO_Api.py | 115 +++++++++++++++ migrations/versions/f3d6ad1fdd31_.py | 40 ++++++ orm/entities/Election/ElectionCandidate.py | 1 + orm/entities/Election/election_helper.py | 6 + .../TallySheetVersion_PRE_34_CO.py | 136 ++++++++++++++++++ .../TallySheetVersionRow_PRE_34_preference.py | 53 +++++++ schemas/__init__.py | 39 ++++- 7 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py create mode 100644 migrations/versions/f3d6ad1fdd31_.py create mode 100644 orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py create mode 100644 orm/entities/TallySheetVersionRow/TallySheetVersionRow_PRE_34_preference.py diff --git a/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py new file mode 100644 index 00000000..d0f2b464 --- /dev/null +++ b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py @@ -0,0 +1,115 @@ +from app import db +from auth import authorize +from auth.AuthConstants import POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE, \ + ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE +from orm.entities import Submission, SubmissionVersion, Area, Election +from orm.entities.Election import ElectionCandidate +from orm.entities.Submission import TallySheet +from orm.entities.SubmissionVersion import TallySheetVersion +from orm.entities.TallySheetVersionRow import TallySheetVersionRow_PRE_41, TallySheetVersionRow_RejectedVoteCount +from orm.enums import AreaTypeEnum, TallySheetCodeEnum +from schemas import TallySheetVersion_PRE_34_CO_Schema, TallySheetVersionSchema +from sqlalchemy import func, and_ + + +@authorize( + required_roles=[ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE, POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE]) +def get_by_id(tallySheetId, tallySheetVersionId): + result = TallySheetVersion.get_by_id( + tallySheetId=tallySheetId, + tallySheetVersionId=tallySheetVersionId + ) + + return TallySheetVersion_PRE_34_CO_Schema().dump(result).data + + +@authorize( + required_roles=[ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE, POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE]) +def create(tallySheetId): + tallySheet, tallySheetVersion = TallySheet.create_latest_version( + tallySheetId=tallySheetId, + tallySheetCode=TallySheetCodeEnum.PRE_34_CO + ) + + countingCentres = tallySheetVersion.submission.area.get_associated_areas( + areaType=AreaTypeEnum.CountingCentre, electionId=tallySheetVersion.submission.electionId + ) + + query = db.session.query( + Area.Model.areaId, + ElectionCandidate.Model.candidateId, + func.sum(TallySheetVersionRow_PRE_41.Model.count).label("count"), + ).join( + Election.Model, + Election.Model.electionId == Area.Model.electionId + ).join( + ElectionCandidate.Model, + ElectionCandidate.Model.electionId == Election.Model.parentElectionId + ).join( + Submission.Model, + Submission.Model.areaId == Area.Model.areaId + ).join( + TallySheet.Model, + and_( + TallySheet.Model.tallySheetId == Submission.Model.submissionId, + TallySheet.Model.tallySheetCode == TallySheetCodeEnum.PRE_41 + ) + ).join( + TallySheetVersionRow_PRE_41.Model, + and_( + TallySheetVersionRow_PRE_41.Model.tallySheetVersionId == Submission.Model.lockedVersionId, + TallySheetVersionRow_PRE_41.Model.candidateId == ElectionCandidate.Model.candidateId + ), + isouter=True + ).filter( + Area.Model.areaId.in_([area.areaId for area in countingCentres]) + ).group_by( + Area.Model.areaId, + ElectionCandidate.Model.candidateId + ).order_by( + Area.Model.areaId, + ElectionCandidate.Model.candidateId + ).all() + + is_complete = True # TODO:Change other reports to validate like this + for row in query: + if row.candidateId is not None and row.areaId is not None and row.count is not None: + tallySheetVersion.add_row( + candidateId=row.candidateId, + countingCentreId=row.areaId, + count=row.count + ) + else: + is_complete = False + + if is_complete: + tallySheetVersion.set_complete() + + rejected_vote_count_query = db.session.query( + Submission.Model.areaId, + func.sum(TallySheetVersionRow_RejectedVoteCount.Model.rejectedVoteCount).label("rejectedVoteCount"), + ).join( + TallySheet.Model, + TallySheet.Model.tallySheetId == Submission.Model.submissionId + ).join( + TallySheetVersionRow_RejectedVoteCount.Model, + TallySheetVersionRow_RejectedVoteCount.Model.tallySheetVersionId == Submission.Model.lockedVersionId + ).filter( + Submission.Model.areaId.in_([area.areaId for area in countingCentres]), + TallySheet.Model.tallySheetCode == TallySheetCodeEnum.PRE_41 + ).group_by( + Submission.Model.areaId + ).order_by( + Submission.Model.areaId + ).all() + + for row in rejected_vote_count_query: + tallySheetVersion.add_invalid_vote_count( + electionId=tallySheetVersion.submission.electionId, + areaId=row.areaId, + rejectedVoteCount=row.rejectedVoteCount + ) + + db.session.commit() + + return TallySheetVersionSchema().dump(tallySheetVersion).data diff --git a/migrations/versions/f3d6ad1fdd31_.py b/migrations/versions/f3d6ad1fdd31_.py new file mode 100644 index 00000000..e18bf686 --- /dev/null +++ b/migrations/versions/f3d6ad1fdd31_.py @@ -0,0 +1,40 @@ +"""empty message + +Revision ID: f3d6ad1fdd31 +Revises: 46e1b58e2e67 +Create Date: 2019-10-31 14:26:47.708066 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f3d6ad1fdd31' +down_revision = '46e1b58e2e67' +branch_labels = None +depends_on = None + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.create_table('tallySheetVersionRow_PRE_34_Preference', + sa.Column('tallySheetVersionRowId', sa.Integer(), nullable=False), + sa.Column('tallySheetVersionId', sa.Integer(), nullable=False), + sa.Column('electionId', sa.Integer(), nullable=False), + sa.Column('candidateId', sa.Integer(), nullable=True), + sa.Column('preferenceNumber', sa.Integer(), nullable=False), + sa.Column('preferenceCount', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['candidateId'], ['candidate.candidateId'], ), + sa.ForeignKeyConstraint(['electionId'], ['election.electionId'], ), + sa.ForeignKeyConstraint(['tallySheetVersionId'], ['tallySheetVersion.tallySheetVersionId'], ), + sa.PrimaryKeyConstraint('tallySheetVersionRowId'), + sa.UniqueConstraint('tallySheetVersionId', 'preferenceNumber', 'candidateId', name='TallySheetVersionRow_RejectedVoteCount_Model') + ) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_table('tallySheetVersionRow_PRE_34_Preference') + ### end Alembic commands ### diff --git a/orm/entities/Election/ElectionCandidate.py b/orm/entities/Election/ElectionCandidate.py index 78009207..bcc4b8b3 100644 --- a/orm/entities/Election/ElectionCandidate.py +++ b/orm/entities/Election/ElectionCandidate.py @@ -9,6 +9,7 @@ class ElectionCandidateModel(db.Model): electionId = db.Column(db.Integer, db.ForeignKey("election.electionId"), nullable=False) partyId = db.Column(db.Integer, db.ForeignKey(Party.Model.__table__.c.partyId), nullable=False) candidateId = db.Column(db.Integer, db.ForeignKey(Candidate.Model.__table__.c.candidateId), nullable=False) + qualifiedForPreferences = db.Column(db.Boolean, default=False, nullable=False) election = relationship("ElectionModel", foreign_keys=[electionId]) party = relationship(Party.Model, foreign_keys=[partyId]) diff --git a/orm/entities/Election/election_helper.py b/orm/entities/Election/election_helper.py index dc8c5079..30c27227 100644 --- a/orm/entities/Election/election_helper.py +++ b/orm/entities/Election/election_helper.py @@ -191,6 +191,9 @@ def get_object(election, row, row_key, data_key=None): TallySheet.create( tallySheetCode=TallySheetCodeEnum.CE_201, electionId=election.electionId, areaId=obj.areaId ) + TallySheet.create( + tallySheetCode=TallySheetCodeEnum.PRE_34_CO, electionId=election.electionId, areaId=obj.areaId + ) elif election.voteType is VoteTypeEnum.Postal: obj = CountingCentre.create( cell, electionId=election.electionId, @@ -202,6 +205,9 @@ def get_object(election, row, row_key, data_key=None): TallySheet.create( tallySheetCode=TallySheetCodeEnum.CE_201_PV, electionId=election.electionId, areaId=obj.areaId ) + TallySheet.create( + tallySheetCode=TallySheetCodeEnum.PRE_34_CO, electionId=election.electionId, areaId=obj.areaId + ) elif data_store_key == "Polling Station": obj = PollingStation.create( diff --git a/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py b/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py new file mode 100644 index 00000000..4dddc04a --- /dev/null +++ b/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py @@ -0,0 +1,136 @@ +from flask import render_template +from sqlalchemy.ext.hybrid import hybrid_property +from sqlalchemy import func, and_, or_ +from app import db +from orm.entities import Area, Candidate, Party, Election +from orm.entities.Election import ElectionCandidate +from orm.entities.SubmissionVersion import TallySheetVersion +from util import to_comma_seperated_num, sqlalchemy_num_or_zero +from orm.enums import TallySheetCodeEnum, AreaTypeEnum, VoteTypeEnum + + +class TallySheetVersion_PRE_34_CO_Model(TallySheetVersion.Model): + + def __init__(self, tallySheetId): + super(TallySheetVersion_PRE_34_CO_Model, self).__init__( + tallySheetId=tallySheetId + ) + + __mapper_args__ = { + 'polymorphic_identity': TallySheetCodeEnum.PRE_34_CO + } + + def add_row(self, preferenceNumber, preferenceCount, candidateId, electionId): + from orm.entities.TallySheetVersionRow import TallySheetVersionRow_PRE_34_preference + + TallySheetVersionRow_PRE_34_preference.create( + tallySheetVersionId=self.tallySheetVersionId, + electionId=electionId, + preferenceNumber=preferenceNumber, + preferenceCount=preferenceCount, + candidateId=candidateId + ) + + def html(self): + stamp = self.stamp + + content = { + "election": { + "electionName": self.submission.election.get_official_name() + }, + "stamp": { + "createdAt": stamp.createdAt, + "createdBy": stamp.createdBy, + "barcodeString": stamp.barcodeString + }, + "electoralDistrict": self.submission.area.areaName, + "pollingDivisions": [], + "data": [], + "validVoteCounts": [], + "rejectedVoteCounts": [], + "totalVoteCounts": [] + } + + non_postal_candidate_and_area_wise_valid_vote_count_result = self.non_postal_candidate_and_area_wise_valid_vote_count_query().all() + postal_candidate_and_area_wise_valid_vote_count_result = self.postal_candidate_and_area_wise_valid_vote_count_query().all() + candidate_wise_vote_count_result = self.candidate_wise_vote_count().all() + non_postal_area_wise_vote_count_result = self.non_postal_area_wise_vote_count_query().all() + postal_area_wise_vote_count_result = self.postal_area_wise_vote_count_query().all() + vote_count_result = self.vote_count_query().one_or_none() + + polling_division_count = len(non_postal_area_wise_vote_count_result) + postal_polling_division_count = len(postal_area_wise_vote_count_result) + number_of_candidates = len(candidate_wise_vote_count_result) + + for polling_division_index in range(polling_division_count): + non_postal_area_wise_vote_count_result_item = non_postal_area_wise_vote_count_result[ + polling_division_index] + content["pollingDivisions"].append(non_postal_area_wise_vote_count_result_item.areaName) + content["rejectedVoteCounts"].append( + to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.rejectedVoteCount) + ) + content["validVoteCounts"].append( + to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.validVoteCount) + ) + content["totalVoteCounts"].append( + to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.totalVoteCount) + ) + + for postal_polling_division_index in range(postal_polling_division_count): + postal_area_wise_vote_count_result_item = postal_area_wise_vote_count_result[ + postal_polling_division_index] + content["rejectedVoteCounts"].append( + to_comma_seperated_num(postal_area_wise_vote_count_result_item.rejectedVoteCount) + ) + content["validVoteCounts"].append( + to_comma_seperated_num(postal_area_wise_vote_count_result_item.validVoteCount) + ) + content["totalVoteCounts"].append( + to_comma_seperated_num(postal_area_wise_vote_count_result_item.totalVoteCount) + ) + + content["rejectedVoteCounts"].append(to_comma_seperated_num(vote_count_result.rejectedVoteCount)) + content["validVoteCounts"].append(to_comma_seperated_num(vote_count_result.validVoteCount)) + content["totalVoteCounts"].append(to_comma_seperated_num(vote_count_result.totalVoteCount)) + + for candidate_wise_vote_count_result_item_index in range(number_of_candidates): + data_row = [] + + data_row_number = candidate_wise_vote_count_result_item_index + 1 + data_row.append(data_row_number) + + candidate_wise_vote_count_result_item = candidate_wise_vote_count_result[ + candidate_wise_vote_count_result_item_index + ] + data_row.append(candidate_wise_vote_count_result_item.candidateName) + + for polling_division_index in range(polling_division_count): + non_postal_area_wise_valid_vote_count_result_item_index = ( + candidate_wise_vote_count_result_item_index * + polling_division_count) + polling_division_index + non_postal_candidate_and_area_wise_valid_vote_count_result_item = \ + non_postal_candidate_and_area_wise_valid_vote_count_result[ + non_postal_area_wise_valid_vote_count_result_item_index + ] + data_row.append(to_comma_seperated_num( + non_postal_candidate_and_area_wise_valid_vote_count_result_item.validVoteCount)) + + postal_candidate_and_area_wise_valid_vote_count_result_item = \ + postal_candidate_and_area_wise_valid_vote_count_result[ + candidate_wise_vote_count_result_item_index + ] + data_row.append( + to_comma_seperated_num(postal_candidate_and_area_wise_valid_vote_count_result_item.validVoteCount)) + data_row.append(to_comma_seperated_num(candidate_wise_vote_count_result_item.validVoteCount)) + + content["data"].append(data_row) + + html = render_template( + 'PRE-34-CO.html', + content=content + ) + + return html + + +Model = TallySheetVersion_PRE_34_CO_Model diff --git a/orm/entities/TallySheetVersionRow/TallySheetVersionRow_PRE_34_preference.py b/orm/entities/TallySheetVersionRow/TallySheetVersionRow_PRE_34_preference.py new file mode 100644 index 00000000..1d6a0872 --- /dev/null +++ b/orm/entities/TallySheetVersionRow/TallySheetVersionRow_PRE_34_preference.py @@ -0,0 +1,53 @@ +from sqlalchemy.ext.associationproxy import association_proxy +from sqlalchemy.orm import relationship + +from app import db +from orm.entities import Area, Election, Candidate +from orm.entities.SubmissionVersion import TallySheetVersion + + +class TallySheetVersionRow_PRE_34_preference_Model(db.Model): + __tablename__ = 'tallySheetVersionRow_PRE_34_Preference' + tallySheetVersionRowId = db.Column(db.Integer, primary_key=True, autoincrement=True) + tallySheetVersionId = db.Column(db.Integer, db.ForeignKey(TallySheetVersion.Model.__table__.c.tallySheetVersionId), + nullable=False) + electionId = db.Column(db.Integer, db.ForeignKey(Election.Model.__table__.c.electionId), nullable=False) + candidateId = db.Column(db.Integer, db.ForeignKey(Candidate.Model.__table__.c.candidateId), nullable=True) + preferenceNumber = db.Column(db.Integer, nullable=False) + preferenceCount = db.Column(db.Integer, nullable=False) + + candidate = relationship(Candidate.Model, foreign_keys=[candidateId]) + election = relationship(Election.Model, foreign_keys=[electionId]) + + areaName = association_proxy("area", "areaName") + + __table_args__ = ( + db.UniqueConstraint('tallySheetVersionId', 'preferenceNumber', 'candidateId', + name='TallySheetVersionRow_RejectedVoteCount_Model'), + ) + + def __init__(self, electionId, tallySheetVersionId, preferenceNumber, preferenceCount, candidateId): + super(TallySheetVersionRow_PRE_34_preference_Model, self).__init__( + electionId=electionId, + tallySheetVersionId=tallySheetVersionId, + preferenceNumber=preferenceNumber, + preferenceCount=preferenceCount, + candidateId=candidateId + ) + db.session.add(self) + db.session.flush() + + +Model = TallySheetVersionRow_PRE_34_preference_Model + + +def create(electionId, tallySheetVersionId, preferenceNumber, preferenceCount, candidateId): + result = Model( + electionId=electionId, + tallySheetVersionId=tallySheetVersionId, + preferenceNumber=preferenceNumber, + preferenceCount=preferenceCount, + candidateId=candidateId + ) + + return result diff --git a/schemas/__init__.py b/schemas/__init__.py index f0e3f64f..2e31fc66 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -9,11 +9,11 @@ from orm.entities.SubmissionVersion import TallySheetVersion from orm.entities.Submission import TallySheet from orm.entities.SubmissionVersion.TallySheetVersion import TallySheetVersionCE201, TallySheetVersionPRE41, \ - TallySheetVersionPRE21, TallySheetVersion_PRE_30_PD, TallySheetVersion_PRE_30_ED, \ + TallySheetVersionPRE21, TallySheetVersion_PRE_30_PD, TallySheetVersion_PRE_30_ED, TallySheetVersion_PRE_34_CO, \ TallySheetVersion_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS, TallySheetVersion_PRE_ALL_ISLAND_RESULT, \ TallySheetVersion_CE_201_PV from orm.entities.TallySheetVersionRow import TallySheetVersionRow_CE_201_PV, TallySheetVersionRow_CE_201, \ - TallySheetVersionRow_PRE_41, \ + TallySheetVersionRow_PRE_41, TallySheetVersionRow_PRE_34_preference, \ TallySheetVersionRow_PRE_21, TallySheetVersionRow_PRE_ALL_ISLAND_RESULT, TallySheetVersionRow_PRE_30_ED, \ TallySheetVersionRow_PRE_30_PD, TallySheetVersionRow_CE_201_PV_CC, TallySheetVersionRow_RejectedVoteCount, \ TallySheetVersionRow_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS @@ -47,7 +47,8 @@ class Meta: fields = ( "candidateId", "candidateName", - "candidateProfileImageFile" + "candidateProfileImageFile", + "qualifiedForPreferences" ) model = Party.Model @@ -195,6 +196,20 @@ class Meta: # to use for deserialization sqla_session = db.session +class TallySheetVersionRow_PRE_34_CO_Schema(ma.ModelSchema): + class Meta: + fields = ( + "electionId", + "tallySheetVersionId", + "preferenceNumber", + "preferenceCount", + "candidateId" + ) + + model = TallySheetVersionRow_PRE_34_preference.Model + # optionally attach a Session + # to use for deserialization + sqla_session = db.session class TallySheetVersionRow_PRE_30_PD_Schema(ma.ModelSchema): class Meta: @@ -562,6 +577,24 @@ class Meta: content = ma.Nested(TallySheetVersionRow_PRE_30_ED_Schema, many=True) areas = ma.Nested(AreaSchema, many=True) +class TallySheetVersion_PRE_34_CO_Schema(ma.ModelSchema): + class Meta: + fields = ( + "tallySheetId", + "tallySheetVersionId", + "createdBy", + "createdAt", + "htmlUrl", + "content" + ) + + model = TallySheetVersion_PRE_34_CO.Model + # optionally attach a Session + # to use for deserialization + sqla_session = db.session + + # submission = ma.Nested(SubmissionSchema) + content = ma.Nested(TallySheetVersionRow_PRE_34_CO_Schema, many=True) class TallySheetVersion_PRE_30_PD_Schema(ma.ModelSchema): class Meta: From b441ec78c1f6d7b5ac8833c6f6f7205d596a384f Mon Sep 17 00:00:00 2001 From: Umayanga Prabhash Gunawardhana Date: Thu, 31 Oct 2019 15:39:36 +0530 Subject: [PATCH 2/3] migrate PRE 34 CO --- .../TallySheetVersion_PRE_34_CO_Api.py | 113 +++++------------- migrations/versions/1c10a1181f81_.py | 28 +++++ schemas/__init__.py | 6 +- 3 files changed, 58 insertions(+), 89 deletions(-) create mode 100644 migrations/versions/1c10a1181f81_.py diff --git a/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py index d0f2b464..6374ed1c 100644 --- a/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py +++ b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py @@ -1,20 +1,20 @@ from app import db -from auth import authorize -from auth.AuthConstants import POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE, \ - ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE -from orm.entities import Submission, SubmissionVersion, Area, Election -from orm.entities.Election import ElectionCandidate +from auth import authorize, EC_LEADERSHIP_ROLE +from auth.AuthConstants import DATA_EDITOR_ROLE +from exception import NotFoundException from orm.entities.Submission import TallySheet from orm.entities.SubmissionVersion import TallySheetVersion -from orm.entities.TallySheetVersionRow import TallySheetVersionRow_PRE_41, TallySheetVersionRow_RejectedVoteCount -from orm.enums import AreaTypeEnum, TallySheetCodeEnum +from orm.enums import TallySheetCodeEnum from schemas import TallySheetVersion_PRE_34_CO_Schema, TallySheetVersionSchema -from sqlalchemy import func, and_ +from util import RequestBody -@authorize( - required_roles=[ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE, POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE]) +@authorize(required_roles=[DATA_EDITOR_ROLE, EC_LEADERSHIP_ROLE]) def get_by_id(tallySheetId, tallySheetVersionId): + tallySheet = TallySheet.get_by_id(tallySheetId=tallySheetId) + if tallySheet is None: + raise NotFoundException("Tally sheet not found. (tallySheetId=%d)" % tallySheetId) + result = TallySheetVersion.get_by_id( tallySheetId=tallySheetId, tallySheetVersionId=tallySheetVersionId @@ -23,91 +23,32 @@ def get_by_id(tallySheetId, tallySheetVersionId): return TallySheetVersion_PRE_34_CO_Schema().dump(result).data -@authorize( - required_roles=[ELECTORAL_DISTRICT_REPORT_VIEWER_ROLE, POLLING_DIVISION_REPORT_VIEWER_ROLE, EC_LEADERSHIP_ROLE]) -def create(tallySheetId): +@authorize(required_roles=[DATA_EDITOR_ROLE]) +def create(tallySheetId, body): + request_body = RequestBody(body) tallySheet, tallySheetVersion = TallySheet.create_latest_version( tallySheetId=tallySheetId, tallySheetCode=TallySheetCodeEnum.PRE_34_CO ) - - countingCentres = tallySheetVersion.submission.area.get_associated_areas( - areaType=AreaTypeEnum.CountingCentre, electionId=tallySheetVersion.submission.electionId - ) - - query = db.session.query( - Area.Model.areaId, - ElectionCandidate.Model.candidateId, - func.sum(TallySheetVersionRow_PRE_41.Model.count).label("count"), - ).join( - Election.Model, - Election.Model.electionId == Area.Model.electionId - ).join( - ElectionCandidate.Model, - ElectionCandidate.Model.electionId == Election.Model.parentElectionId - ).join( - Submission.Model, - Submission.Model.areaId == Area.Model.areaId - ).join( - TallySheet.Model, - and_( - TallySheet.Model.tallySheetId == Submission.Model.submissionId, - TallySheet.Model.tallySheetCode == TallySheetCodeEnum.PRE_41 - ) - ).join( - TallySheetVersionRow_PRE_41.Model, - and_( - TallySheetVersionRow_PRE_41.Model.tallySheetVersionId == Submission.Model.lockedVersionId, - TallySheetVersionRow_PRE_41.Model.candidateId == ElectionCandidate.Model.candidateId - ), - isouter=True - ).filter( - Area.Model.areaId.in_([area.areaId for area in countingCentres]) - ).group_by( - Area.Model.areaId, - ElectionCandidate.Model.candidateId - ).order_by( - Area.Model.areaId, - ElectionCandidate.Model.candidateId - ).all() - - is_complete = True # TODO:Change other reports to validate like this - for row in query: - if row.candidateId is not None and row.areaId is not None and row.count is not None: + tallySheetVersion.set_complete() # TODO: valid before setting complete. Refer to PRE_34_CO + tally_sheet_content = request_body.get("content") + if tally_sheet_content is not None: + for row in tally_sheet_content: + party_count_body = RequestBody(row) tallySheetVersion.add_row( - candidateId=row.candidateId, - countingCentreId=row.areaId, - count=row.count + electionId=party_count_body.get("electionId"), + candidateId=party_count_body.get("candidateId"), + preferenceCount=party_count_body.get("preferenceCount"), + preferencNumber=party_count_body.get("preferenceNumber"), ) - else: - is_complete = False - - if is_complete: - tallySheetVersion.set_complete() - - rejected_vote_count_query = db.session.query( - Submission.Model.areaId, - func.sum(TallySheetVersionRow_RejectedVoteCount.Model.rejectedVoteCount).label("rejectedVoteCount"), - ).join( - TallySheet.Model, - TallySheet.Model.tallySheetId == Submission.Model.submissionId - ).join( - TallySheetVersionRow_RejectedVoteCount.Model, - TallySheetVersionRow_RejectedVoteCount.Model.tallySheetVersionId == Submission.Model.lockedVersionId - ).filter( - Submission.Model.areaId.in_([area.areaId for area in countingCentres]), - TallySheet.Model.tallySheetCode == TallySheetCodeEnum.PRE_41 - ).group_by( - Submission.Model.areaId - ).order_by( - Submission.Model.areaId - ).all() - for row in rejected_vote_count_query: + tally_sheet_summary_body = request_body.get("summary") + if tally_sheet_summary_body is not None: tallySheetVersion.add_invalid_vote_count( electionId=tallySheetVersion.submission.electionId, - areaId=row.areaId, - rejectedVoteCount=row.rejectedVoteCount + candidateId=tallySheetVersion.submission.candidateId, + preferenceCount=tallySheetVersion.submission.preferenceCount, + preferencNumber=tallySheetVersion.submission.preferenceNumber, ) db.session.commit() diff --git a/migrations/versions/1c10a1181f81_.py b/migrations/versions/1c10a1181f81_.py new file mode 100644 index 00000000..494855d5 --- /dev/null +++ b/migrations/versions/1c10a1181f81_.py @@ -0,0 +1,28 @@ +"""empty message + +Revision ID: 1c10a1181f81 +Revises: f3d6ad1fdd31 +Create Date: 2019-10-31 15:19:30.297761 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1c10a1181f81' +down_revision = 'f3d6ad1fdd31' +branch_labels = None +depends_on = None + + +def upgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.add_column('election_candidate', sa.Column('qualifiedForPreferences', sa.Boolean(), nullable=False)) + ### end Alembic commands ### + + +def downgrade(): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column('election_candidate', 'qualifiedForPreferences') + ### end Alembic commands ### diff --git a/schemas/__init__.py b/schemas/__init__.py index 2e31fc66..9ee8ddb6 100644 --- a/schemas/__init__.py +++ b/schemas/__init__.py @@ -2,8 +2,8 @@ from app import db, ma from orm.entities import StationaryItem, Ballot, Invoice, BallotBox, \ - Election, Proof, Submission, Electorate, SubmissionVersion, Area, Party, BallotBook -from orm.entities.Election import InvalidVoteCategory + Election, Proof, Submission, Electorate, SubmissionVersion, Area, Party, BallotBook, Candidate +from orm.entities.Election import InvalidVoteCategory, ElectionCandidate from orm.entities.IO import File from orm.entities.Invoice import InvoiceStationaryItem from orm.entities.SubmissionVersion import TallySheetVersion @@ -51,7 +51,7 @@ class Meta: "qualifiedForPreferences" ) - model = Party.Model + model = ElectionCandidate.Model # optionally attach a Session # to use for deserialization sqla_session = db.session From d063ede8259759c5a3f12c1bce6fdfc50d911c2b Mon Sep 17 00:00:00 2001 From: Umayanga Prabhash Gunawardhana Date: Thu, 31 Oct 2019 21:17:46 +0530 Subject: [PATCH 3/3] PRE-34_CO view and edit done --- .../TallySheetVersion_PRE_34_CO_Api.py | 13 +- .../Submission/TallySheet/__init__.py | 3 +- .../TallySheetVersion_PRE_34_CO.py | 147 +- swagger.yml | 1698 +++++++++-------- templates/PRE-34-CO.html | 8 +- util/__init__.py | 9 +- 6 files changed, 993 insertions(+), 885 deletions(-) diff --git a/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py index 6374ed1c..f66d391b 100644 --- a/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py +++ b/api/TallySheetVersionApi/TallySheetVersion_PRE_34_CO_Api.py @@ -36,21 +36,12 @@ def create(tallySheetId, body): for row in tally_sheet_content: party_count_body = RequestBody(row) tallySheetVersion.add_row( - electionId=party_count_body.get("electionId"), + electionId=tallySheetVersion.submission.electionId, candidateId=party_count_body.get("candidateId"), preferenceCount=party_count_body.get("preferenceCount"), - preferencNumber=party_count_body.get("preferenceNumber"), + preferenceNumber=party_count_body.get("preferenceNumber"), ) - tally_sheet_summary_body = request_body.get("summary") - if tally_sheet_summary_body is not None: - tallySheetVersion.add_invalid_vote_count( - electionId=tallySheetVersion.submission.electionId, - candidateId=tallySheetVersion.submission.candidateId, - preferenceCount=tallySheetVersion.submission.preferenceCount, - preferencNumber=tallySheetVersion.submission.preferenceNumber, - ) - db.session.commit() return TallySheetVersionSchema().dump(tallySheetVersion).data diff --git a/orm/entities/Submission/TallySheet/__init__.py b/orm/entities/Submission/TallySheet/__init__.py index 667f15e6..251347f9 100644 --- a/orm/entities/Submission/TallySheet/__init__.py +++ b/orm/entities/Submission/TallySheet/__init__.py @@ -162,7 +162,8 @@ def create_empty_version(tallySheetId, tallySheetCode=None): def create_version(tallySheetId, tallySheetCode=None): tallySheet = get_by_id(tallySheetId=tallySheetId, tallySheetCode=tallySheetCode) if tallySheet is None: - raise NotFoundException("Tally sheet not found. (tallySheetId=%d)" % tallySheetId) + raise NotFoundException( + "Tally sheet not found. (tallySheetId=%d, tallySheetCode=%s)" % (tallySheetId, tallySheetCode.name)) tallySheetVersion = tallySheet.create_version() diff --git a/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py b/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py index 4dddc04a..15b89e46 100644 --- a/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py +++ b/orm/entities/SubmissionVersion/TallySheetVersion/TallySheetVersion_PRE_34_CO.py @@ -5,6 +5,7 @@ from orm.entities import Area, Candidate, Party, Election from orm.entities.Election import ElectionCandidate from orm.entities.SubmissionVersion import TallySheetVersion +from orm.entities.TallySheetVersionRow import TallySheetVersionRow_PRE_34_preference from util import to_comma_seperated_num, sqlalchemy_num_or_zero from orm.enums import TallySheetCodeEnum, AreaTypeEnum, VoteTypeEnum @@ -31,9 +32,45 @@ def add_row(self, preferenceNumber, preferenceCount, candidateId, electionId): candidateId=candidateId ) + @hybrid_property + def content(self): + + return db.session.query( + ElectionCandidate.Model.candidateId, + Candidate.Model.candidateName, + Party.Model.partySymbol, + TallySheetVersionRow_PRE_34_preference.Model.preferenceNumber, + TallySheetVersionRow_PRE_34_preference.Model.preferenceCount, + TallySheetVersionRow_PRE_34_preference.Model.tallySheetVersionId, + TallySheetVersionRow_PRE_34_preference.Model.electionId + ).join( + TallySheetVersionRow_PRE_34_preference.Model, + and_( + TallySheetVersionRow_PRE_34_preference.Model.candidateId == ElectionCandidate.Model.candidateId, + TallySheetVersionRow_PRE_34_preference.Model.tallySheetVersionId == self.tallySheetVersionId, + ), + isouter=True + ).join( + Candidate.Model, + Candidate.Model.candidateId == ElectionCandidate.Model.candidateId, + isouter=True + ).join( + Party.Model, + Party.Model.partyId == ElectionCandidate.Model.partyId, + isouter=True + ).filter( + ElectionCandidate.Model.electionId.in_(self.submission.election.mappedElectionIds), + ElectionCandidate.Model.qualifiedForPreferences == True + ).all() + def html(self): stamp = self.stamp + polling_divisions = Area.get_associated_areas(self.submission.area, AreaTypeEnum.PollingDivision) + polling_division_name = "" + if len(polling_divisions) > 0: + polling_division_name = polling_divisions[0].areaName + content = { "election": { "electionName": self.submission.election.get_official_name() @@ -43,87 +80,39 @@ def html(self): "createdBy": stamp.createdBy, "barcodeString": stamp.barcodeString }, - "electoralDistrict": self.submission.area.areaName, - "pollingDivisions": [], - "data": [], - "validVoteCounts": [], - "rejectedVoteCounts": [], - "totalVoteCounts": [] + "title": "PRESIDENTIAL ELECTION ACT NO. 15 OF 1981", + "electoralDistrict": Area.get_associated_areas( + self.submission.area, AreaTypeEnum.ElectoralDistrict)[0].areaName, + "pollingDivision": polling_division_name, + "countingCentre": self.submission.area.areaName, + "pollingDistrictNos": ", ".join([ + pollingDistrict.areaName for pollingDistrict in + Area.get_associated_areas(self.submission.area, AreaTypeEnum.PollingDistrict) + ]), + "data": [ + ], } - non_postal_candidate_and_area_wise_valid_vote_count_result = self.non_postal_candidate_and_area_wise_valid_vote_count_query().all() - postal_candidate_and_area_wise_valid_vote_count_result = self.postal_candidate_and_area_wise_valid_vote_count_query().all() - candidate_wise_vote_count_result = self.candidate_wise_vote_count().all() - non_postal_area_wise_vote_count_result = self.non_postal_area_wise_vote_count_query().all() - postal_area_wise_vote_count_result = self.postal_area_wise_vote_count_query().all() - vote_count_result = self.vote_count_query().one_or_none() - - polling_division_count = len(non_postal_area_wise_vote_count_result) - postal_polling_division_count = len(postal_area_wise_vote_count_result) - number_of_candidates = len(candidate_wise_vote_count_result) - - for polling_division_index in range(polling_division_count): - non_postal_area_wise_vote_count_result_item = non_postal_area_wise_vote_count_result[ - polling_division_index] - content["pollingDivisions"].append(non_postal_area_wise_vote_count_result_item.areaName) - content["rejectedVoteCounts"].append( - to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.rejectedVoteCount) - ) - content["validVoteCounts"].append( - to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.validVoteCount) - ) - content["totalVoteCounts"].append( - to_comma_seperated_num(non_postal_area_wise_vote_count_result_item.totalVoteCount) - ) - - for postal_polling_division_index in range(postal_polling_division_count): - postal_area_wise_vote_count_result_item = postal_area_wise_vote_count_result[ - postal_polling_division_index] - content["rejectedVoteCounts"].append( - to_comma_seperated_num(postal_area_wise_vote_count_result_item.rejectedVoteCount) - ) - content["validVoteCounts"].append( - to_comma_seperated_num(postal_area_wise_vote_count_result_item.validVoteCount) - ) - content["totalVoteCounts"].append( - to_comma_seperated_num(postal_area_wise_vote_count_result_item.totalVoteCount) - ) - - content["rejectedVoteCounts"].append(to_comma_seperated_num(vote_count_result.rejectedVoteCount)) - content["validVoteCounts"].append(to_comma_seperated_num(vote_count_result.validVoteCount)) - content["totalVoteCounts"].append(to_comma_seperated_num(vote_count_result.totalVoteCount)) - - for candidate_wise_vote_count_result_item_index in range(number_of_candidates): - data_row = [] - - data_row_number = candidate_wise_vote_count_result_item_index + 1 - data_row.append(data_row_number) - - candidate_wise_vote_count_result_item = candidate_wise_vote_count_result[ - candidate_wise_vote_count_result_item_index - ] - data_row.append(candidate_wise_vote_count_result_item.candidateName) - - for polling_division_index in range(polling_division_count): - non_postal_area_wise_valid_vote_count_result_item_index = ( - candidate_wise_vote_count_result_item_index * - polling_division_count) + polling_division_index - non_postal_candidate_and_area_wise_valid_vote_count_result_item = \ - non_postal_candidate_and_area_wise_valid_vote_count_result[ - non_postal_area_wise_valid_vote_count_result_item_index - ] - data_row.append(to_comma_seperated_num( - non_postal_candidate_and_area_wise_valid_vote_count_result_item.validVoteCount)) - - postal_candidate_and_area_wise_valid_vote_count_result_item = \ - postal_candidate_and_area_wise_valid_vote_count_result[ - candidate_wise_vote_count_result_item_index - ] - data_row.append( - to_comma_seperated_num(postal_candidate_and_area_wise_valid_vote_count_result_item.validVoteCount)) - data_row.append(to_comma_seperated_num(candidate_wise_vote_count_result_item.validVoteCount)) - - content["data"].append(data_row) + # for row_index in range(len(tallySheetContent)): + # row = tallySheetContent[row_index] + # if row.count is not None: + # content["data"].append([ + # row_index + 1, + # row.candidateName, + # row.partySymbol, + # row.preferenceNumber, + # to_comma_seperated_num(row.count), + # "" + # ]) + # else: + # content["data"].append([ + # row_index + 1, + # row.candidateName, + # row.partySymbol, + # "", + # "", + # "" + # ]) html = render_template( 'PRE-34-CO.html', diff --git a/swagger.yml b/swagger.yml index 9470ae4b..f690a9ea 100644 --- a/swagger.yml +++ b/swagger.yml @@ -14,33 +14,33 @@ info: url: 'http://www.apache.org/licenses/LICENSE-2.0.html' tags: - - name: Tally Sheet - description: Access to tally sheets - - name: Invoice - description: Access to invoices - - name: Stationary - description: Access to stationaries - - name: Invoice Stationary - description: Access to stationaries - - name: System Testing - description: Endpoints required for testing purpose only. These are to be removed. +- name: Tally Sheet + description: Access to tally sheets +- name: Invoice + description: Access to invoices +- name: Stationary + description: Access to stationaries +- name: Invoice Stationary + description: Access to stationaries +- name: System Testing + description: Endpoints required for testing purpose only. These are to be removed. paths: /system-testing/election/{electionId}/root-token: get: tags: - - System Testing + - System Testing summary: Get all. operationId: api.ElectionApi.getRootToken parameters: - - name: electionId - in: path - description: Election ID - required: true - schema: - type: integer - format: int64 + - name: electionId + in: path + description: Election ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -77,16 +77,16 @@ paths: /election/{electionId}: get: tags: - - Election + - Election summary: Get By Id operationId: api.ElectionApi.get_by_id parameters: - - name: electionId - in: path - required: true - schema: - type: integer - format: int64 + - name: electionId + in: path + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -95,8 +95,8 @@ paths: schema: type: object required: - - electionId - - electionName + - electionId + - electionName properties: electionId: type: integer @@ -169,16 +169,16 @@ paths: /election/{electionId}/area: get: tags: - - Election + - Election summary: Get by ID operationId: api.ElectionApi.get_all_areas parameters: - - name: electionId - required: true - in: path - schema: - type: integer - format: int64 + - name: electionId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -214,24 +214,24 @@ paths: /election: get: tags: - - Election + - Election summary: Get all. operationId: api.ElectionApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 responses: '200': description: Successful operation. @@ -242,8 +242,8 @@ paths: items: type: object required: - - electionId - - electionName + - electionId + - electionName properties: electionId: type: integer @@ -315,7 +315,7 @@ paths: post: tags: - - Election + - Election summary: Create election operationId: api.ElectionApi.create requestBody: @@ -344,11 +344,11 @@ paths: type: string format: binary required: - - electionName - - pollingStationsDataset - - invalidVoteCategoriesDataset - - partyCandidatesDataset - - postalCountingCentresDataset + - electionName + - pollingStationsDataset + - invalidVoteCategoriesDataset + - partyCandidatesDataset + - postalCountingCentresDataset responses: '200': description: Successful operation. @@ -359,8 +359,8 @@ paths: items: type: object required: - - electionId - - electionName + - electionId + - electionName properties: electionId: type: integer @@ -433,43 +433,43 @@ paths: /ballot: get: tags: - - Stationary + - Stationary summary: Get all. operationId: api.BallotApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 - - name: ballotId - required: false - in: query - schema: - type: string - - name: ballotType - required: false - in: query - schema: - type: string - enum: - - Ordinary - - Tendered + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 + - name: ballotId + required: false + in: query + schema: + type: string + - name: ballotType + required: false + in: query + schema: + type: string + enum: + - Ordinary + - Tendered responses: '200': description: Successful operation. @@ -480,9 +480,9 @@ paths: items: type: object required: - - ballotId - - stationaryItemId - - electionId + - ballotId + - stationaryItemId + - electionId properties: ballotId: type: string @@ -495,8 +495,8 @@ paths: ballotType: type: string enum: - - Ordinary - - Tendered + - Ordinary + - Tendered '400': description: Bad request. content: @@ -524,7 +524,7 @@ paths: post: tags: - - Stationary + - Stationary summary: Create. operationId: api.BallotApi.create responses: @@ -535,9 +535,9 @@ paths: schema: type: object required: - - ballotId - - stationaryItemId - - electionId + - ballotId + - stationaryItemId + - electionId properties: ballotId: type: string @@ -550,8 +550,8 @@ paths: ballotType: type: string enum: - - Ordinary - - Tendered + - Ordinary + - Tendered '400': description: Bad request. content: @@ -582,8 +582,8 @@ paths: schema: type: object required: - - ballotId - - electionId + - ballotId + - electionId properties: ballotId: type: string @@ -593,38 +593,38 @@ paths: ballotType: type: string enum: - - Ordinary - - Tendered + - Ordinary + - Tendered description: Ballot Object. required: True /ballot-book: get: tags: - - Stationary + - Stationary summary: Get all. operationId: api.BallotBookApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -635,10 +635,10 @@ paths: items: type: object required: - - stationaryItemId - - fromBallotId - - toBallotId - - electionId + - stationaryItemId + - fromBallotId + - toBallotId + - electionId properties: fromBallotId: type: string @@ -677,7 +677,7 @@ paths: post: tags: - - Stationary + - Stationary summary: Create. operationId: api.BallotBookApi.create responses: @@ -688,10 +688,10 @@ paths: schema: type: object required: - - stationaryItemId - - fromBallotId - - toBallotId - - electionId + - stationaryItemId + - fromBallotId + - toBallotId + - electionId properties: fromBallotId: type: string @@ -733,9 +733,9 @@ paths: schema: type: object required: - - fromBallotId - - toBallotId - - electionId + - fromBallotId + - toBallotId + - electionId properties: fromBallotId: type: string @@ -750,35 +750,35 @@ paths: /ballot-box: get: tags: - - Stationary + - Stationary summary: Get all. operationId: api.BallotBoxApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 - - name: ballotBoxId - required: false - in: query - schema: - type: string + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 + - name: ballotBoxId + required: false + in: query + schema: + type: string responses: '200': description: Successful operation. @@ -789,9 +789,9 @@ paths: items: type: object required: - - ballotBoxId - - stationaryItemId - - electionId + - ballotBoxId + - stationaryItemId + - electionId properties: ballotBoxId: type: string @@ -828,7 +828,7 @@ paths: post: tags: - - Stationary + - Stationary summary: Create. operationId: api.BallotBoxApi.create responses: @@ -839,9 +839,9 @@ paths: schema: type: object required: - - ballotBoxId - - stationaryItemId - - electionId + - ballotBoxId + - stationaryItemId + - electionId properties: ballotBoxId: type: string @@ -881,8 +881,8 @@ paths: schema: type: object required: - - ballotBoxId - - electionId + - ballotBoxId + - electionId properties: ballotBoxId: type: string @@ -895,54 +895,54 @@ paths: /invoice: get: tags: - - Invoice + - Invoice summary: Get all. operationId: api.InvoiceApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 - - name: issuingOfficeId - required: false - in: query - schema: - type: integer - format: int64 - - name: receivingOfficeId - required: false - in: query - schema: - type: integer - format: int64 - - name: issuedBy - required: false - in: query - schema: - type: integer - format: int64 - - name: issuedTo - required: false - in: query - schema: - type: integer - format: int64 + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 + - name: issuingOfficeId + required: false + in: query + schema: + type: integer + format: int64 + - name: receivingOfficeId + required: false + in: query + schema: + type: integer + format: int64 + - name: issuedBy + required: false + in: query + schema: + type: integer + format: int64 + - name: issuedTo + required: false + in: query + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -953,14 +953,14 @@ paths: items: type: object required: - - invoiceId - - electionId - - issuingOfficeId - - receivingOfficeId - - issuedBy - - issuedTo - - issuedAt - - confirmed + - invoiceId + - electionId + - issuingOfficeId + - receivingOfficeId + - issuedBy + - issuedTo + - issuedAt + - confirmed properties: invoiceId: type: integer @@ -1012,7 +1012,7 @@ paths: post: tags: - - Invoice + - Invoice summary: Create. operationId: api.InvoiceApi.create responses: @@ -1023,14 +1023,14 @@ paths: schema: type: object required: - - invoiceId - - electionId - - issuingOfficeId - - receivingOfficeId - - issuedBy - - issuedTo - - issuedAt - - confirmed + - invoiceId + - electionId + - issuingOfficeId + - receivingOfficeId + - issuedBy + - issuedTo + - issuedAt + - confirmed properties: invoiceId: type: integer @@ -1085,10 +1085,10 @@ paths: schema: type: object required: - - electionId - - issuingOfficeId - - receivingOfficeId - - issuedTo + - electionId + - issuingOfficeId + - receivingOfficeId + - issuedTo properties: electionId: type: integer @@ -1108,16 +1108,16 @@ paths: /invoice/{invoiceId}: get: tags: - - Invoice + - Invoice summary: Create. operationId: api.InvoiceApi.get_by_id parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1126,14 +1126,14 @@ paths: schema: type: object required: - - invoiceId - - electionId - - issuingOfficeId - - receivingOfficeId - - issuedBy - - issuedTo - - issuedAt - - confirmed + - invoiceId + - electionId + - issuingOfficeId + - receivingOfficeId + - issuedBy + - issuedTo + - issuedAt + - confirmed properties: invoiceId: type: integer @@ -1185,16 +1185,16 @@ paths: delete: tags: - - Invoice + - Invoice summary: Create. operationId: api.InvoiceApi.delete parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1230,16 +1230,16 @@ paths: /invoice/{invoiceId}/confirm: put: tags: - - Invoice + - Invoice summary: Create. operationId: api.InvoiceApi.confirm parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1248,14 +1248,14 @@ paths: schema: type: object required: - - invoiceId - - electionId - - issuingOfficeId - - receivingOfficeId - - issuedBy - - issuedTo - - issuedAt - - confirmed + - invoiceId + - electionId + - issuingOfficeId + - receivingOfficeId + - issuedBy + - issuedTo + - issuedAt + - confirmed properties: invoiceId: type: integer @@ -1308,60 +1308,60 @@ paths: /invoice/stationary-item: get: tags: - - Invoice Stationary + - Invoice Stationary summary: Get all. operationId: api.InvoiceStationaryItemApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: invoiceId - required: false - in: query - schema: - type: integer - format: int64 - - name: stationaryItemId - required: false - in: query - schema: - type: integer - format: int64 - - name: received - required: false - in: query - schema: - type: integer - format: int64 - - name: receivedBy - required: false - in: query - schema: - type: integer - format: int64 - - name: receivedFrom - required: false - in: query - schema: - type: integer - format: int64 - - name: receivedOffice - required: false - in: query - schema: - type: integer - format: int64 + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: invoiceId + required: false + in: query + schema: + type: integer + format: int64 + - name: stationaryItemId + required: false + in: query + schema: + type: integer + format: int64 + - name: received + required: false + in: query + schema: + type: integer + format: int64 + - name: receivedBy + required: false + in: query + schema: + type: integer + format: int64 + - name: receivedFrom + required: false + in: query + schema: + type: integer + format: int64 + - name: receivedOffice + required: false + in: query + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1372,13 +1372,13 @@ paths: items: type: object required: - - invoiceId - - stationaryItemId - - received - - receivedBy - - receivedFrom - - receivedOfficeId - - receivedAt + - invoiceId + - stationaryItemId + - received + - receivedBy + - receivedFrom + - receivedOfficeId + - receivedAt properties: invoiceId: type: integer @@ -1433,16 +1433,16 @@ paths: /invoice/{invoiceId}/stationary-item: post: tags: - - Invoice Stationary + - Invoice Stationary summary: Create. operationId: api.InvoiceStationaryItemApi.create parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1451,9 +1451,9 @@ paths: schema: type: object required: - - invoiceId - - stationaryItemId - - received + - invoiceId + - stationaryItemId + - received properties: invoiceId: type: integer @@ -1510,7 +1510,7 @@ paths: schema: type: object required: - - stationaryItemId + - stationaryItemId properties: stationaryItemId: type: integer @@ -1521,22 +1521,22 @@ paths: /invoice/{invoiceId}/stationary-item/{stationaryItemId}: get: tags: - - Invoice Stationary + - Invoice Stationary summary: Get all. operationId: api.InvoiceStationaryItemApi.get_by_id parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 - - name: stationaryItemId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 + - name: stationaryItemId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1545,13 +1545,13 @@ paths: schema: type: object required: - - invoiceId - - stationaryItemId - - received - - receivedBy - - receivedFrom - - receivedOfficeId - - receivedAt + - invoiceId + - stationaryItemId + - received + - receivedBy + - receivedFrom + - receivedOfficeId + - receivedAt properties: invoiceId: type: integer @@ -1605,22 +1605,22 @@ paths: delete: tags: - - Invoice Stationary + - Invoice Stationary summary: Get all. operationId: api.InvoiceStationaryItemApi.delete parameters: - - name: invoiceId - required: true - in: path - schema: - type: integer - format: int64 - - name: stationaryItemId - required: true - in: path - schema: - type: integer - format: int64 + - name: invoiceId + required: true + in: path + schema: + type: integer + format: int64 + - name: stationaryItemId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1656,7 +1656,7 @@ paths: /invoice/stationary-item/receive: put: tags: - - Invoice Stationary + - Invoice Stationary summary: Create. operationId: api.InvoiceStationaryItemApi.receive responses: @@ -1742,7 +1742,7 @@ paths: /proof/upload: put: tags: - - Proof + - Proof summary: Upload a proof. operationId: api.ProofApi.upload_file responses: @@ -1794,16 +1794,16 @@ paths: /proof/{proofId}/finish: put: tags: - - Proof + - Proof summary: Create. operationId: api.ProofApi.finish parameters: - - name: proofId - required: true - in: path - schema: - type: integer - format: int64 + - name: proofId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1839,16 +1839,16 @@ paths: /proof/{proofId}: get: tags: - - Proof + - Proof summary: Create. operationId: api.ProofApi.get_by_id parameters: - - name: proofId - required: true - in: path - schema: - type: integer - format: int64 + - name: proofId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -1884,16 +1884,16 @@ paths: /file/{fileId}: get: tags: - - Files + - Files summary: Get by ID operationId: api.FileApi.get_by_id parameters: - - name: fileId - required: true - in: path - schema: - type: integer - format: int64 + - name: fileId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -1925,16 +1925,16 @@ paths: /file/{fileId}/inline: get: tags: - - Files + - Files summary: Get by ID operationId: api.FileApi.get_inline_file parameters: - - name: fileId - required: true - in: path - schema: - type: integer - format: int64 + - name: fileId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -1970,16 +1970,16 @@ paths: /file/{fileId}/download: get: tags: - - Files + - Files summary: Get by ID operationId: api.FileApi.get_download_file parameters: - - name: fileId - required: true - in: path - schema: - type: integer - format: int64 + - name: fileId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -2015,53 +2015,53 @@ paths: /area: get: tags: - - Area + - Area summary: Get by ID operationId: api.AreaApi.get_all parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 - - name: associatedAreaId - required: false - in: query - schema: - type: integer - format: int64 - - name: areaType - required: false - in: query - schema: - type: string - enum: - - ElectionCommission - - DistrictCentre - - CountingCentre - - PostalVoteCountingCentre - - PollingStation - - Country - - Province - - AdministrativeDistrict - - ElectoralDistrict - - PollingDivision - - PollingDistrict + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 + - name: associatedAreaId + required: false + in: query + schema: + type: integer + format: int64 + - name: areaType + required: false + in: query + schema: + type: string + enum: + - ElectionCommission + - DistrictCentre + - CountingCentre + - PostalVoteCountingCentre + - PollingStation + - Country + - Province + - AdministrativeDistrict + - ElectoralDistrict + - PollingDivision + - PollingDistrict responses: '200': description: OK @@ -2097,56 +2097,57 @@ paths: /tally-sheet: get: tags: - - Tally Sheet + - Tally Sheet summary: Get all the tally sheets. operationId: api.TallySheetApi.getAll parameters: - - name: limit - in: query - description: Limit of the result array. - required: false - schema: - type: integer - default: 20 - - name: offset - in: query - description: Offset of the result array. - required: false - schema: - type: integer - default: 0 - - name: electionId - required: false - in: query - schema: - type: integer - format: int64 - - name: areaId - required: false - in: query - schema: - type: integer - format: int64 - - name: createdBy - required: false - in: query - schema: - type: integer - format: int64 - - name: tallySheetCode - required: false - in: query - schema: - type: string - enum: - - CE-201 - - CE-201-PV - - PRE-41 - - PRE-21 - - PRE-30-PD - - PRE-30-ED - - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS - - PRE-ALL-ISLAND-RESULTS + - name: limit + in: query + description: Limit of the result array. + required: false + schema: + type: integer + default: 20 + - name: offset + in: query + description: Offset of the result array. + required: false + schema: + type: integer + default: 0 + - name: electionId + required: false + in: query + schema: + type: integer + format: int64 + - name: areaId + required: false + in: query + schema: + type: integer + format: int64 + - name: createdBy + required: false + in: query + schema: + type: integer + format: int64 + - name: tallySheetCode + required: false + in: query + schema: + type: string + enum: + - CE-201 + - CE-201-PV + - PRE-41 + - PRE-21 + - PRE-30-PD + - PRE-30-ED + - PRE-34-CO + - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS + - PRE-ALL-ISLAND-RESULTS responses: '200': description: Successful operation. @@ -2157,9 +2158,9 @@ paths: items: type: object required: - - electionId - - officeId - - tallySheetCode + - electionId + - officeId + - tallySheetCode properties: id: type: integer @@ -2187,14 +2188,14 @@ paths: tallySheetCode: type: string enum: - - CE-201 - - CE-201-PV - - PRE-41 - - PRE-21 - - PRE-30-PD - - PRE-30-ED - - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS - - PRE-ALL-ISLAND-RESULTS + - CE-201 + - CE-201-PV + - PRE-41 + - PRE-21 + - PRE-30-PD + - PRE-30-ED + - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS + - PRE-ALL-ISLAND-RESULTS '400': description: Bad request. content: @@ -2223,16 +2224,16 @@ paths: /tally-sheet/{tallySheetId}: get: tags: - - Tally Sheet + - Tally Sheet summary: Get tally sheet by ID operationId: api.TallySheetApi.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: string + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: string responses: '200': description: Successful operation. @@ -2241,9 +2242,9 @@ paths: schema: type: object required: - - electionId - - officeId - - tallySheetCode + - electionId + - officeId + - tallySheetCode properties: id: type: integer @@ -2271,14 +2272,14 @@ paths: tallySheetCode: type: string enum: - - CE-201 - - CE-201-PV - - PRE-41 - - PRE-21 - - PRE-30-PD - - PRE-30-ED - - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS - - PRE-ALL-ISLAND-RESULTS + - CE-201 + - CE-201-PV + - PRE-41 + - PRE-21 + - PRE-30-PD + - PRE-30-ED + - PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS + - PRE-ALL-ISLAND-RESULTS '400': description: Bad request. content: @@ -2307,17 +2308,17 @@ paths: /tally-sheet/PRE-41/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersionPRE41Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2326,8 +2327,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -2376,8 +2377,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -2401,24 +2402,24 @@ paths: /tally-sheet/PRE-41/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersionPRE41Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2427,8 +2428,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -2475,17 +2476,17 @@ paths: /tally-sheet/PRE-21/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersionPRE21Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2494,7 +2495,7 @@ paths: schema: type: object required: - - content + - content properties: content: type: array @@ -2539,7 +2540,7 @@ paths: schema: type: object required: - - content + - content properties: content: type: array @@ -2557,24 +2558,24 @@ paths: /tally-sheet/PRE-21/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersionPRE21Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2610,17 +2611,17 @@ paths: /tally-sheet/CE-201/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersionCE201Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2629,7 +2630,7 @@ paths: schema: type: object required: - - content + - content properties: content: type: array @@ -2701,7 +2702,7 @@ paths: schema: type: object required: - - content + - content properties: content: type: array @@ -2748,24 +2749,24 @@ paths: /tally-sheet/CE-201/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersionCE201Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2774,7 +2775,7 @@ paths: schema: type: object required: - - content + - content properties: content: type: array @@ -2844,17 +2845,17 @@ paths: /tally-sheet/CE-201-PV/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersion_CE_201_PV_Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2863,8 +2864,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -2924,8 +2925,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -2958,24 +2959,24 @@ paths: /tally-sheet/CE-201-PV/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersion_CE_201_PV_Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -2984,8 +2985,8 @@ paths: schema: type: object required: - - content - - summary + - content + - summary properties: content: type: array @@ -3043,17 +3044,17 @@ paths: /tally-sheet/PRE-30-PD/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_30_PD_Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3088,24 +3089,24 @@ paths: /tally-sheet/PRE-30-PD/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_30_PD_Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3141,17 +3142,17 @@ paths: /tally-sheet/PRE-30-ED/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_30_ED_Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3186,24 +3187,143 @@ paths: /tally-sheet/PRE-30-ED/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_30_ED_Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + type: object + '400': + description: Bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '401': + description: Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '404': + description: Resource was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '500': + description: Unexpected error. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + + /tally-sheet/PRE-34-CO/{tallySheetId}/version: + post: + tags: + - Tally Sheet Version + summary: Create tally sheet version + operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_34_CO_Api.create + parameters: + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + requestBody: + content: + application/json: + schema: + type: object + required: + - content + properties: + content: + type: array + items: + type: object + properties: + candidateId: + type: integer + format: int64 + preferenceCount: + type: integer + preferencNumber: + type: integer + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + type: object + '400': + description: Bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '401': + description: Unauthorized. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '404': + description: Resource was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + '500': + description: Unexpected error. + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + + /tally-sheet/PRE-34-CO/{tallySheetId}/version/{tallySheetVersionId}: + get: + tags: + - Tally Sheet Version + summary: Get tally sheet version by ID + operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_34_CO_Api.get_by_id + parameters: + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3239,17 +3359,17 @@ paths: /tally-sheet/PRE-ALL-ISLAND-RESULTS/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_ALL_ISLAND_RESULT_Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3284,24 +3404,24 @@ paths: /tally-sheet/PRE-ALL-ISLAND-RESULTS/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_ALL_ISLAND_RESULT_Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3337,17 +3457,17 @@ paths: /tally-sheet/PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS/{tallySheetId}/version: post: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Create tally sheet version operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS_Api.create parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3382,24 +3502,24 @@ paths: /tally-sheet/PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS/{tallySheetId}/version/{tallySheetVersionId}: get: tags: - - Tally Sheet Version + - Tally Sheet Version summary: Get tally sheet version by ID operationId: api.TallySheetVersionApi.TallySheetVersion_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS_Api.get_by_id parameters: - - name: tallySheetId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 - - name: tallySheetVersionId - in: path - description: Tally sheet ID - required: true - schema: - type: integer - format: int64 + - name: tallySheetId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 + - name: tallySheetVersionId + in: path + description: Tally sheet ID + required: true + schema: + type: integer + format: int64 responses: '200': description: Successful operation. @@ -3435,22 +3555,22 @@ paths: /tally-sheet/{tallySheetId}/version/{tallySheetVersionId}/html: get: tags: - - Tally Sheet Version Export + - Tally Sheet Version Export summary: Get by ID operationId: api.TallySheetVersionApi.html parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 - - name: tallySheetVersionId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 + - name: tallySheetVersionId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -3486,16 +3606,16 @@ paths: /tally-sheet/{tallySheetId}/empty/html: get: tags: - - Tally Sheet Version Export + - Tally Sheet Version Export summary: Get by ID operationId: api.TallySheetVersionApi.create_empty_and_get_html parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -3531,16 +3651,16 @@ paths: /tally-sheet/{tallySheetId}/lock: put: tags: - - Tally Sheet + - Tally Sheet summary: Get by ID operationId: api.TallySheetApi.lock parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -3578,7 +3698,7 @@ paths: schema: type: object required: - - lockedVersionId + - lockedVersionId properties: lockedVersionId: type: integer @@ -3587,16 +3707,16 @@ paths: /tally-sheet/{tallySheetId}/unlock: put: tags: - - Tally Sheet + - Tally Sheet summary: Get by ID operationId: api.TallySheetApi.unlock parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -3632,16 +3752,16 @@ paths: /tally-sheet/{tallySheetId}/submit: put: tags: - - Tally Sheet + - Tally Sheet summary: Get by ID operationId: api.TallySheetApi.submit parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK @@ -3679,7 +3799,7 @@ paths: schema: type: object required: - - submittedVersionId + - submittedVersionId properties: submittedVersionId: type: integer @@ -3688,16 +3808,16 @@ paths: /tally-sheet/{tallySheetId}/request-edit: put: tags: - - Tally Sheet + - Tally Sheet summary: Get by ID operationId: api.TallySheetApi.request_edit parameters: - - name: tallySheetId - required: true - in: path - schema: - type: integer - format: int64 + - name: tallySheetId + required: true + in: path + schema: + type: integer + format: int64 responses: '200': description: OK diff --git a/templates/PRE-34-CO.html b/templates/PRE-34-CO.html index ff5c08d2..188a24cc 100644 --- a/templates/PRE-34-CO.html +++ b/templates/PRE-34-CO.html @@ -97,13 +97,13 @@ TOTAL IN WORDS The Total No. of Preferences in favour of Candidate No. 1
- (Name:- xx)
- is xx + (Name:- ............................................)
+ is ............................................ The Total No. of Preferences in favour of Candidate No. 2
- (Name:- xx)
- is xx + (Name:- ............................................)
+ is ............................................ diff --git a/util/__init__.py b/util/__init__.py index 1b104b1f..9aa48040 100644 --- a/util/__init__.py +++ b/util/__init__.py @@ -61,6 +61,8 @@ def get_tally_sheet_code(tally_sheet_code_str): return TallySheetCodeEnum.PRE_30_PD_PV elif tally_sheet_code_str == "PRE-30-ED": return TallySheetCodeEnum.PRE_30_ED + elif tally_sheet_code_str == "PRE-34-CO": + return TallySheetCodeEnum.PRE_34_CO elif tally_sheet_code_str == "PRE-ALL-ISLAND-RESULTS": return TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS elif tally_sheet_code_str == "PRE-ALL-ISLAND-RESULTS-BY-ELECTORAL-DISTRICTS": @@ -82,6 +84,8 @@ def get_tally_sheet_code_string(tally_sheet_code): return "PRE-30-PD-PV" elif tally_sheet_code is TallySheetCodeEnum.PRE_30_ED: return "PRE-30-ED" + elif tally_sheet_code is TallySheetCodeEnum.PRE_34_CO: + return "PRE-34-CO" elif tally_sheet_code is TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS: return "PRE-ALL-ISLAND-RESULTS" elif tally_sheet_code is TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS: @@ -90,7 +94,8 @@ def get_tally_sheet_code_string(tally_sheet_code): def get_tally_sheet_version_class(tally_sheet_version_code): from orm.entities.SubmissionVersion.TallySheetVersion import TallySheetVersionPRE41, TallySheetVersion_CE_201_PV, \ - TallySheetVersionCE201, TallySheetVersionPRE21, TallySheetVersion_PRE_30_PD, TallySheetVersion_PRE_30_ED, \ + TallySheetVersionCE201, TallySheetVersionPRE21, TallySheetVersion_PRE_30_PD, TallySheetVersion_PRE_34_CO \ + , TallySheetVersion_PRE_30_ED, \ TallySheetVersion_PRE_ALL_ISLAND_RESULT, TallySheetVersion_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS if tally_sheet_version_code is TallySheetCodeEnum.CE_201: @@ -107,6 +112,8 @@ def get_tally_sheet_version_class(tally_sheet_version_code): return TallySheetVersion_PRE_30_PD elif tally_sheet_version_code is TallySheetCodeEnum.PRE_30_ED: return TallySheetVersion_PRE_30_ED + elif tally_sheet_version_code is TallySheetCodeEnum.PRE_34_CO: + return TallySheetVersion_PRE_34_CO elif tally_sheet_version_code is TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS: return TallySheetVersion_PRE_ALL_ISLAND_RESULT elif tally_sheet_version_code is TallySheetCodeEnum.PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS: