Skip to content

Commit

Permalink
post election postal vote func
Browse files Browse the repository at this point in the history
  • Loading branch information
umayangag committed Apr 30, 2021
1 parent af3d498 commit c154774
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ def json(self):
def html(self, title="", total_registered_voters=None):
tallySheetVersion = self.tallySheetVersion

party_and_area_wise_valid_vote_count_result = self.get_party_and_area_wise_valid_vote_count_result()
area_wise_valid_vote_count_result = self.get_area_wise_valid_vote_count_result()
party_wise_valid_vote_count_result = self.get_party_wise_valid_vote_count_result()
# party_wise_valid_postal_vote_count_result = self.get_party_wise_valid_postal_vote_count_result()

party_and_area_wise_valid_postal_vote_count_result = self.get_party_and_area_wise_valid_postal_vote_count_result()
print("hello")
print(party_and_area_wise_valid_vote_count_result)
print(party_and_area_wise_valid_postal_vote_count_result)
stamp = tallySheetVersion.stamp
election = tallySheetVersion.tallySheet.election

Expand All @@ -91,16 +94,22 @@ def html(self, title="", total_registered_voters=None):
"No. of Bonus Seats", "Total seats"],
}

get_province_from_administrative_district_map = {}

# Append the grand totals
number_of_administrative_districts = len(area_wise_valid_vote_count_result)

for area_wise_valid_vote_count_result_item in area_wise_valid_vote_count_result.itertuples():
province_name = Area.get_associated_areas(tallySheetVersion.tallySheet.area,
AreaTypeEnum.Province)[0].areaName
if province_name not in content['provinces']:
content['provinces'][province_name] = []
content['provinces'][province_name].append(area_wise_valid_vote_count_result_item.areaName)
print(content['provinces'])
content['provinces'][province_name] = {}

administrative_district_name = area_wise_valid_vote_count_result_item.areaName
if administrative_district_name not in content['provinces'][province_name]:
get_province_from_administrative_district_map[administrative_district_name] = province_name
content['provinces'][province_name][administrative_district_name] = {}

for party_wise_valid_vote_count_result_item_index, party_wise_valid_vote_count_result_item in party_wise_valid_vote_count_result.iterrows():
data_row = []

Expand Down
12 changes: 12 additions & 0 deletions results-tabulation-api/ext/ExtendedTallySheet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,18 @@ def get_party_and_area_wise_valid_vote_count_result(self):
).reset_index()
return df

def get_party_and_area_wise_valid_postal_vote_count_result(self):
df = self.df.copy()

df = df.loc[df['templateRowType'] == "PARTY_WISE_POSTAL_VOTE"]
df = df.loc[df['voteType'] == Postal]

df = df.sort_values(
by=['electionPartyId', 'partyId', 'partyName', 'partyAbbreviation', 'partySymbol', 'areaId',
'areaName'], ascending=True
).reset_index()
return df

def get_area_wise_valid_vote_count_result(self):
df = self.df.copy()
df['numValue'] = df['numValue'].astype(float)
Expand Down

0 comments on commit c154774

Please sign in to comment.