Skip to content

Commit

Permalink
Revert "Add iconset rules for rtw and score percentage"
Browse files Browse the repository at this point in the history
This reverts commit 300a8e0.
  • Loading branch information
shiyingwucl committed Jan 16, 2025
1 parent 300a8e0 commit a202463
Showing 1 changed file with 6 additions and 46 deletions.
52 changes: 6 additions & 46 deletions shortlister/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from openpyxl.utils import get_column_letter
from openpyxl.styles import PatternFill, Font, Alignment
from openpyxl.worksheet.table import Table,TableStyleInfo
from openpyxl.formatting.rule import Rule,IconSetRule
from openpyxl.formatting.rule import Rule
from openpyxl.styles.differential import DifferentialStyle
import pymupdf
import re
Expand Down Expand Up @@ -297,7 +297,7 @@ def extract_info_from_text(lines: List[str]):
# creating tabular data
def get_headings(criteria:List[Criterion]):
"""Get headings for table"""
header = ["No.", "NAME", "Σ","%","RtW"]
header = ["No.", "NAME", "Σ", "RtW"]
criteria_headings = [criterion.name for criterion in criteria]
return header,criteria_headings

Expand All @@ -306,17 +306,12 @@ def get_applicant_information(applicants:List[Applicant],criteria:List[Criterion
rows = []
scores =[]
i = 0
denominator = RANK_AND_SCORE["Excellent"]*len(criteria)

for applicant in applicants:
i = i + 1
amount_scored = total_score(applicant.scores)
percentage_scored = round(amount_scored/denominator,2)*100
row = [
i,
applicant.name,
amount_scored,
percentage_scored,
total_score(applicant.scores),
"Y" if applicant.right_to_work else "N",
]
score = []
Expand All @@ -342,8 +337,6 @@ def applicant_table(
header = header + criteria_headings
else:
header = header + ["SCORES"]

RANK_AND_SCORE["Excellent"]*len(criteria_headings)

# creates rows of applicant data

Expand Down Expand Up @@ -427,7 +420,7 @@ def export_excel(filename, applicants: List[Applicant], criteria: List[Criterion
)

# rotate score headings
for col in range(6, ws.max_column+1):
for col in range(5, ws.max_column+1):
heading_score_cell = ws[get_column_letter(col)+"1"]
heading_score_cell.alignment = Alignment(horizontal="center",textRotation=90)

Expand All @@ -450,39 +443,8 @@ def export_excel(filename, applicants: List[Applicant], criteria: List[Criterion
showColumnStripes=False,)
ws.add_table(table)

# Icon rules

# right to work column
rtw_to_num = {
"N": 0,
"?": 2,
"Y": 1
}

for row in ws.iter_rows(min_row=2, max_row=ws.max_row, min_col=5, max_col=5):
for cell in row:
if cell.value in rtw_to_num:
# map string to value
cell.value = rtw_to_num[cell.value]

rtw_icon_rule = IconSetRule(
type="num",
icon_style="3Symbols",
showValue=False,
percent=True,
values=[0, 2, 1]
)

# total score column
total_score_icon_rule = IconSetRule(
type="num",
icon_style="3Arrows",
showValue=True,
percent=True,
values=[0,50,75]
)
# add colour for cells depending on the score: U(red),M(yellow),S,E(green)

# conditional formatting
for score in RANK_COLOUR_EXCEL:
ws.conditional_formatting.add(
range_string=table_range,
Expand All @@ -494,9 +456,7 @@ def export_excel(filename, applicants: List[Applicant], criteria: List[Criterion
formula=[f'EXACT("{score}",A1)']
)
)
ws.conditional_formatting.add(f"D2:D{ws.max_row}", total_score_icon_rule)
ws.conditional_formatting.add(f"E2:E{ws.max_row}", rtw_icon_rule)


wb.save(filename)

def abbreviate(list_of_strings: List[str]) -> list[str]:
Expand Down

0 comments on commit a202463

Please sign in to comment.