-
Notifications
You must be signed in to change notification settings - Fork 0
/
page2.py
154 lines (122 loc) · 6.85 KB
/
page2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
'''
To pick a color: https://www.w3schools.com/colors/colors_picker.asp
Grid ressource: https://gridbyexample.com/examples/
'''
from xml.dom.xmlbuilder import Options
import streamlit as st
from src.utils import *
from PIL import Image
import numpy as np
import pandas as pd
import csv
import os.path
from elgiganten_view import *
from src.utils_page2 import *
#st.set_page_config(layout="wide",page_title="ScreenAid", page_icon="🔍")
#candidates = pd.read_csv('Data/applicants-from-page-1.csv',na_values=['a','b'])
def page2():
candidates = st.session_state.temp_df2
#define candidates
IDs = [candidate.replace(' ', '') for candidate in candidates['ID']]
candidates['IDs'] = [candidate.replace(' ', '') for candidate in candidates['ID']]
#initialise session state
rkey_list = [f'radio_{i}' for i in IDs]
tkey_list = [f'text_{i}' for i in IDs]
ckey_list = [f'compare_{i}' for i in range(0, len(candidates))] # with index instead of ID again!
#reload session states
for key in st.session_state:
st.session_state[key] = st.session_state[key]
for key in rkey_list + tkey_list + ckey_list:
if key not in st.session_state and 'radio_' in key:
st.session_state[key] = "Not selected"
elif key not in st.session_state and 'text_' in key:
st.session_state[key] = ""
elif key not in st.session_state and 'compare_' in key:
st.session_state[key] = False
else:
st.session_state[key] = st.session_state[key]
#Define comparison:
compare_candidates = [key for key, value in st.session_state.items() if 'compare_' in key and value == True]
# columns for progress bar and info icon
c1,c2 = st.columns([25,1])
# progress bar
with c1:
progress2_path = 'Data/progress/progress2.png'
progress2 = "<img src='data:image/png;base64,{}' class='img-fluid' style= 'height:100px; padding-bottom: 30px; padding-left: 240px;'>".format(
img_to_bytes(progress2_path)
)
st.markdown(progress2, unsafe_allow_html= True)
# help button
help_p2 = '''
STEP 2: COMPARE & SORT\n
Learn more about your applicants by reading their profiles. Each profile picture is the applicant’s skill plot overlaid on your thresholds from Step 1. Use the radio buttons to sort applicants into ‘yes’, ‘maybe’, and ‘no’ piles as you go. You can navigate the piles by clicking at the tabs at the top. You can also write notes to yourself about each applicant. Click the ‘+’ icon below an applicant to read their motivational letter.\n
To compare 2-3 applicants, check the ‘Compare’ box next to each of them and click the ‘+’ icon next to ‘Compare candidates’ at the top of the page. To the left, you can compare their skill plots (click on a name to toggle on and off). To the right, you can compare their information in a table.\n
When you press ‘Next’, all applicants in the ‘yes’ pile are chosen and will be revealed in the final step.
'''
with c2:
st.download_button(label='?',data='blabla',help=help_p2,disabled=True)
#Add comparison
with st.expander("𝘾𝙊𝙈𝙋𝘼𝙍𝙀 𝘾𝘼𝙉𝘿𝙄𝘿𝘼𝙏𝙀𝙎 𝙃𝙀𝙍𝙀"):
elgiganten_view(candidates, compare_candidates, ckey_list)
if len(compare_candidates) > 3:
st.warning('You can only compare 3 candidates at a time!')
if 'selected' not in st.session_state:
st.session_state.selected = f'All ({len(candidates)})'
#define menu place
menu = st.container()
menu_box = menu.empty()
#define columns
col1, col2, col3, col4 = st.columns(4)
#define candidates
st.session_state.yes_candidates = [str(item[0]).partition("_")[2] for item in st.session_state.items() if 'radio_' in item[0] and item[1]== 'Yes']
st.session_state.maybe_candidates = [str(item[0]).partition("_")[2] for item in st.session_state.items() if 'radio_' in item[0] and item[1]== 'Maybe']
st.session_state.no_candidates = [str(item[0]).partition("_")[2] for item in st.session_state.items() if 'radio_' in item[0] and item[1]== 'No']
#define indexes for candidates
st.session_state.yes_indexes = [int(IDs.index(i)) for i in st.session_state.yes_candidates if i in IDs]
st.session_state.maybe_indexes = [int(IDs.index(i)) for i in st.session_state.maybe_candidates if i in IDs]
st.session_state.no_indexes = [int(IDs.index(i)) for i in st.session_state.no_candidates if i in IDs]
#sort candidates
#candidates['index_column'] = 0
# for i in candidates['IDs'].index:
# if candidates['IDs'][i] in st.session_state.yes_candidates:
# candidates['index_column'][i] = 1
# elif candidates['IDs'][int(i)] in st.session_state.maybe_candidates:
# candidates['index_column'][i] = 2
# elif candidates['IDs'][int(i)] in st.session_state.no_candidates:
# candidates['index_column'][i] = 3
# candidates = candidates.sort_values('index_column')
#show pages
if st.session_state.selected.partition(" ")[0] == 'All':
#loop through candidates
for c in range(0, len(candidates)):
#show page
show_page2(ckey_list, rkey_list, tkey_list, index = c, df = candidates)
st.write('---')
if st.session_state.selected.partition(" ")[0] == 'Yes':
#loop through candidates
for c in st.session_state.yes_indexes:
#show page
show_page2(ckey_list, rkey_list, tkey_list, index = c, df = candidates)
st.write('---')
if st.session_state.selected.partition(" ")[0] == 'Maybe':
#loop through candidates
for c in st.session_state.maybe_indexes:
#show page
show_page2(ckey_list, rkey_list, tkey_list, index = c, df = candidates)
st.write('---')
if st.session_state.selected.partition(" ")[0] == 'No':
#loop through candidates
for c in st.session_state.no_indexes:
#show page
show_page2(ckey_list, rkey_list, tkey_list, index = c, df = candidates)
st.write('---')
#save number of candidates
st.session_state['no_yes_candidates'] = len(st.session_state.yes_candidates)
st.session_state['no_maybe_candidates'] = len(st.session_state.maybe_candidates)
st.session_state['no_no_candidates'] = len(st.session_state.no_candidates)
#define menu
options = [f'All ({len(candidates)})', f'Yes ({st.session_state.no_yes_candidates})', f'Maybe ({st.session_state.no_maybe_candidates})', f'No ({st.session_state.no_no_candidates})']
options_short = ['All', 'Yes', 'Maybe', 'No']
with menu_box.container():
streamlit_menu(options=options, icons=["circle", "check-circle", "question-circle", "x-circle"], key = 'selected', default_index=options_short.index(st.session_state.selected.partition(" ")[0]))
#page2()