Skip to content

Commit

Permalink
Filtro por gratuidade
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamaia committed Nov 8, 2024
1 parent 7a23244 commit 5dd11d5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
23 changes: 21 additions & 2 deletions curadoria_coletiva/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ def _create_filter_dropdowns(df):
placeholder="Dificuldade",
style={"width": "100%"},
),
dcc.Checklist(
id="free-filter",
options=[
{"label": " É gratuito", "value": "gratuito"}
],
value=[],
style={"width": "100%", "margin-top": "10px"},
),
dcc.Dropdown(
id="sort-dropdown",
options=[
Expand Down Expand Up @@ -226,7 +234,7 @@ def _generate_field_content(row, col):
field_content.append(
html.P(
[
html.Strong(f"{col.replace('_', ' ').capitalize()}: "),
html.Span(f"{col.replace('_', ' ').capitalize()}: "),
html.A(
row[col],
href=row[col],
Expand All @@ -241,7 +249,7 @@ def _generate_field_content(row, col):
field_content.append(
html.P(
[
html.Strong("Recomendado por: "),
html.Span("Recomendado por: "),
html.A(
f"@{recomendado_usuario}",
href=f"https://github.com/{recomendado_usuario}",
Expand All @@ -251,6 +259,12 @@ def _generate_field_content(row, col):
]
)
)
elif col == "eh_gratuito":
field_content.append(
html.P(
f"{col.replace('_', ' ').capitalize()}: {'sim' if row[col] else 'não'}"
)
)
else:
field_content.append(
html.P(
Expand Down Expand Up @@ -297,6 +311,7 @@ def _register_callbacks(app, df):
Input("learning-style-dropdown", "value"),
Input("language-dropdown", "value"),
Input("level-dropdown", "value"),
Input("free-filter", "value"),
Input("sort-dropdown", "value"),
)
def update_table(
Expand All @@ -306,6 +321,7 @@ def update_table(
selected_learning_style,
selected_language,
selected_level,
free_filter,
sort_column,
):
"""Atualiza a tabela com base nos filtros de busca, assunto, formato, estilo de aprendizagem e ordenação."""
Expand Down Expand Up @@ -349,6 +365,9 @@ def update_table(
if sort_column:
filtered_df = filtered_df.sort_values(by=sort_column)

if free_filter:
filtered_df = filtered_df[filtered_df["eh_gratuito"] == True]

if not filtered_df.empty:
return generate_result_layout(filtered_df)
else:
Expand Down
2 changes: 1 addition & 1 deletion curadoria_coletiva/material_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# 'expert'
nivel_dificuldade:

# Indica se o material é gratuito para acesso. Umas das opções: true ou false
# Indica se o material é gratuito para acesso. Umas das opções: True ou False
eh_gratuito:

# Lista de usernames do GitHub de pessoas que recomendam o material
Expand Down
2 changes: 1 addition & 1 deletion curadoria_coletiva/materials/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
estilo_aprendizagem: visual
idioma: inglês
nivel_dificuldade: iniciante
eh_gratuito: true
eh_gratuito: True
recomendado_por:
- "camilamaia"
comentarios:
Expand Down
2 changes: 1 addition & 1 deletion curadoria_coletiva/materials/example2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
estilo_aprendizagem: "cinestésico"
idioma: português (BR)
nivel_dificuldade: intermediário
eh_gratuito: false
eh_gratuito: False
recomendado_por:
- "mariagabriela"
comentarios:
Expand Down

0 comments on commit 5dd11d5

Please sign in to comment.