-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
67 lines (53 loc) · 2.63 KB
/
streamlit_app.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
import streamlit as st
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
def init_firestore():
# Inicializar la aplicación de Firebase
cred = credentials.Certificate(st.secrets["lasalleDB"].to_dict())
if not firebase_admin._apps:
firebase_admin.initialize_app(cred)
return firestore.client()
db = init_firestore()
# Função para traduzir
def translate(language, en_text, fr_text):
if language == 'English':
return en_text
else:
return fr_text
# Título da Aplicação
st.title('Scheduler For September 3 to 6')
# Seleção de Idioma
language = st.selectbox('Choose your language / Choisissez votre langue', ['English', 'Français'])
times = ['08:00-09:00', '09:00-10:00', '10:00-11:00', '11:00-12:00', '12:00-13:00', '13:00-14:00', '14:00-15:00', '15:00-16:00', '16:00-17:00']
# Disponibilidade
st.subheader(translate(language, "Select your Availability", "Sélectionnez votre Disponibilité"))
st.write('Please select all available days and times / Veuillez sélectionner tous les jours et heures disponibles')
# st.dataframe(data=db)
with st.form("Schedule", clear_on_submit=True):
# Nome do Usuário
name = st.text_input(translate(language, "Your Name", "Votre Nom"))
# Número do Estudante
studentNumber = st.text_input(translate(language, "Your Student Number", "Votre No étudiant"))
tuesday = st.multiselect(translate(language, 'Tuesday', 'Mardi'), times)
wednesday = st.multiselect(translate(language, 'Wednesday', 'Mercredi'), times)
thursday = st.multiselect(translate(language, 'Thursday', 'Jeudi'), times)
friday = st.multiselect(translate(language, 'Friday', 'Vendredi'), times)
# if st.button(translate(language, 'Submit Availability', 'Envoyer la Disponibilité')):
if st.form_submit_button(translate(language, 'Submit Availability', 'Envoyer la Disponibilité')):
if not name or not studentNumber:
st.error(translate(language, "Please provide your Name and Student Number.", "Veuillez fournir votre Nom et Numéro d'étudiant."))
else:
data = {
"studentID": studentNumber,
"info": {
"name": name,
"tuesday": tuesday,
"wednesday": wednesday,
"thursday": thursday,
"friday": friday
}
}
doc_ref = db.collection("week_sept_3_6").document(studentNumber)
doc_ref.set(data["info"])
st.success(translate(language, 'Availability submitted!', 'Disponibilité envoyée!'))