crismunoz commited on
Commit
07048d9
1 Parent(s): 4caca4a
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -140,10 +140,11 @@ def program():
140
  # Display the filtered news as a grid of cards
141
  if len(filtered_data_by_group) > 0:
142
  for risk in set([item['risk'] for item in filtered_data_by_group]):
 
 
143
  st.header(risk)
144
- # Filter data based on current risk
145
- filtered_data_by_risk = [item for item in filtered_data_by_group if item['risk'] == risk]
146
-
147
  # Define the number of columns
148
  num_columns = 3
149
  col_index = 0
@@ -154,25 +155,24 @@ def program():
154
  # Initialize an empty row
155
  row = grid.columns(num_columns)
156
 
157
- for item in filtered_data_by_risk:
158
- for news in item['examples']:
159
- with row[col_index]:
160
- st.markdown(
161
- f"""
162
- <div class="grid-item">
163
- <div class="card">
164
- <h3>{news['title']}</h3>
165
- <p>{news['incident']}</p>
166
- <a href="{news['link']}" target="_blank">Read more</a>
167
- </div>
168
  </div>
169
- """,
170
- unsafe_allow_html=True
171
- )
172
- col_index = (col_index + 1) % num_columns
173
- # Start a new row after the last column
174
- if col_index == 0:
175
- row = grid.columns(num_columns)
 
176
 
177
  if len(filtered_data_by_group) == 0:
178
  st.write("No news found for the selected task and group.")
 
140
  # Display the filtered news as a grid of cards
141
  if len(filtered_data_by_group) > 0:
142
  for risk in set([item['risk'] for item in filtered_data_by_group]):
143
+ item = [item for item in filtered_data_by_group if item['risk'] == risk][0]
144
+
145
  st.header(risk)
146
+ st.write(f"**Description**: {item['description']}")
147
+
 
148
  # Define the number of columns
149
  num_columns = 3
150
  col_index = 0
 
155
  # Initialize an empty row
156
  row = grid.columns(num_columns)
157
 
158
+ for news in item['examples']:
159
+ with row[col_index]:
160
+ st.markdown(
161
+ f"""
162
+ <div class="grid-item">
163
+ <div class="card">
164
+ <h3>{news['title']}</h3>
165
+ <p>{news['incident']}</p>
166
+ <a href="{news['link']}" target="_blank">Read more</a>
 
 
167
  </div>
168
+ </div>
169
+ """,
170
+ unsafe_allow_html=True
171
+ )
172
+ col_index = (col_index + 1) % num_columns
173
+ # Start a new row after the last column
174
+ if col_index == 0:
175
+ row = grid.columns(num_columns)
176
 
177
  if len(filtered_data_by_group) == 0:
178
  st.write("No news found for the selected task and group.")