Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lucas #7

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a4a6740
Create .gitignore
LucasBonii Aug 1, 2024
d74a18a
Criação de main, requirements e views
LuizCenci Aug 1, 2024
bf2f0a1
Add config, modified requirements, views, index
LuizCenci Aug 2, 2024
7de2009
Merge pull request #2 from LucasBonii/Luiz
LuizCenci Aug 2, 2024
e67009f
add styles, modified views
LuizCenci Aug 2, 2024
b08453b
add medals
LuizCenci Aug 2, 2024
3d2620f
modified index.html
LuizCenci Aug 2, 2024
b9ee208
Merge pull request #3 from LucasBonii/Luiz
LuizCenci Aug 2, 2024
65aafe8
Começo agenda e resultados
LucasBonii Aug 2, 2024
d154018
Começo agenda e resultados
LucasBonii Aug 2, 2024
1a9e79a
Merge branch 'main' into Lucas
LucasBonii Aug 2, 2024
b510217
Merge pull request #4 from LucasBonii/Lucas
LucasBonii Aug 2, 2024
dea3732
add scroll
LuizCenci Aug 2, 2024
9e5a644
Merge pull request #5 from LucasBonii/Luiz
LuizCenci Aug 2, 2024
c08601c
add template.html
LuizCenci Aug 2, 2024
2d5dea8
updating agenda
LucasBonii Aug 3, 2024
55f2cb5
Merge pull request #6 from LucasBonii/Lucas
LucasBonii Aug 3, 2024
6a90d37
fixing requests
LucasBonii Aug 3, 2024
f832b23
modified agenda, add styles
LuizCenci Aug 3, 2024
941fef5
Merge branch 'main' of https://github.com/LucasBonii/mp-hackathon-oli…
LuizCenci Aug 3, 2024
f842f6d
back button at agenda
LucasBonii Aug 3, 2024
99564c6
Merge branch 'main' of https://github.com/LucasBonii/mp-hackathon-oli…
LucasBonii Aug 3, 2024
eacff49
timezone to saopaulo
LucasBonii Aug 3, 2024
c3c64ae
timezone to saopaulo
LucasBonii Aug 3, 2024
8481b5e
refactoring
LucasBonii Aug 4, 2024
6b816b9
refactoring frontend
LucasBonii Aug 4, 2024
44db8c8
results and sports transations
LucasBonii Aug 4, 2024
9d1a414
Merge pull request #9 from LucasBonii/Lucas
LucasBonii Aug 4, 2024
5453021
modified agenda, template, add styles
LuizCenci Aug 5, 2024
60c57d2
Merge pull request #10 from LucasBonii/Luiz
LuizCenci Aug 5, 2024
a4345cf
history page
LucasBonii Aug 5, 2024
4e9d47a
Merge branch 'main' into Lucas
LucasBonii Aug 5, 2024
e94dc87
history page
LucasBonii Aug 5, 2024
88cd01f
updating history and header
LucasBonii Aug 5, 2024
4c60e5d
Merge branch 'Lucas' of https://github.com/LucasBonii/mp-hackathon-ol…
LucasBonii Aug 5, 2024
92a4a9e
add filters, changed styles
LuizCenci Aug 5, 2024
d8734da
updating header and history
LucasBonii Aug 5, 2024
f847ae6
Merge branch 'main' into Luiz
LuizCenci Aug 6, 2024
f655274
Merge pull request #13 from LucasBonii/Luiz
LuizCenci Aug 6, 2024
017eef8
fix calendario-filtrado.html
LucasBonii Aug 6, 2024
c746540
Merge pull request #14 from LucasBonii/Lucas
LucasBonii Aug 6, 2024
e3bee05
error
LucasBonii Aug 6, 2024
978a95a
error page
LucasBonii Aug 6, 2024
080845d
correct header
LuizCenci Aug 6, 2024
c6fc550
Merge pull request #16 from LucasBonii/Luiz
LuizCenci Aug 6, 2024
a89562f
add sedes, images
LuizCenci Aug 6, 2024
f640142
Merge pull request #17 from LucasBonii/Luiz
LuizCenci Aug 6, 2024
4b66a53
delete useless files
LucasBonii Aug 6, 2024
95fe71e
delete useless files
LucasBonii Aug 6, 2024
156db5a
comments
LucasBonii Aug 6, 2024
458f6ca
comments
LucasBonii Aug 6, 2024
65a894f
add sedes, change header
LuizCenci Aug 6, 2024
98eba3c
delete test
LuizCenci Aug 6, 2024
ae494a2
Merge pull request #21 from LucasBonii/Luiz
LuizCenci Aug 6, 2024
39aec97
Create vercel.json
LucasBonii Aug 6, 2024
cfd14b5
titles
LucasBonii Aug 6, 2024
63bcf14
vercel.json
LucasBonii Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 66 additions & 15 deletions hackaton/static/css/styles.css
Original file line number Diff line number Diff line change
@@ -162,28 +162,62 @@ body{
.schedule-container{
width: 100%;
background-color: #012a4a;
display: flex;
justify-content: center;
align-items: center;
}
.filter{
width: 88%;
text-decoration: none;
background-color: #ED7632;
width: 40%;
display: flex;
gap: 15%;
margin: 1% auto 0.5% auto;
justify-content: right;
justify-content: center;
align-items: center;
gap: 1rem;
margin: 1% auto 0.5% 55%;
border-radius: 1.25rem;
}
.filter form {
display: flex;
align-items: center;
gap: 1rem;
}
.filter-text{
font-family: "Zain", sans-serif;
font-size: 120%;
font-weight: 600;
width: auto;
color: #F7F6F4;

.filter .filter-image {
width: 2rem;
height: auto;
}
.schedule {

.filter select {
background-color: #ED7632;
padding: 0.5rem;
font-size: 100%;
font-family: "Montserrat", sans-serif;
font-weight: 500;
}

.filter button {
font-size: 100%;
font-family: "Montserrat", sans-serif;
font-weight: 500;
padding: 0.5rem 1rem;
font-size: 1rem;
background-color: #ED7632;
color: #F7F6F4;
border: none;
border-radius: 0.25rem;
cursor: pointer;
transition: background-color 0.3s ease; /* Efeito de transição para hover */
}

.filter button:hover {
background-color: #D65A1E;
}

.schedule {
margin: 0;
height: 100%;
width: 100%;
padding-left: 1%;
margin: 0% 0 0 0;
width: 90%;
border-spacing: 0.6rem;
border-radius: 1.25rem;
overflow-y: auto;
@@ -200,8 +234,8 @@ body{
text-align: center;

}

.schedule th, .schedule td {
width: 19rem;
padding: 1% 1%;
border-collapse: separate;
border-radius: 1vh;
@@ -212,13 +246,30 @@ body{
font-size: 120%;
color: #1E212B ;
background-color: #f4f1de;
text-align: center;
vertical-align: middle;

}
.schedule tbody tr td{
text-align: center;
vertical-align: middle;

}
.schedule tr td:nth-child(1) {
width: 20%;
}

.schedule tr td:nth-child(2) {
width: 30%;
}

.schedule tr td:nth-child(3) {
width: 35%;
}

.schedule tr td:nth-child(4) {
width: 15%;
}
.schedule::-webkit-scrollbar {
width: 1rem;
height: 1rem;
Binary file added hackaton/static/images/filtro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 25 additions & 37 deletions hackaton/templates/pages/agenda.html
Original file line number Diff line number Diff line change
@@ -6,23 +6,23 @@
<h1 class="date">{{agenda[0]['day']}}</h1>
<div class="filter">
<form action="{{ url_for('calendario_filtrado') }}" method="post">
<label class="filter-text" for="options">Escolha uma opção:</label>
<select name="selecao_esporte" id="options">
<img class="filter-image" src="{{url_for('static', filename='images/filtro.png')}}" alt="">
<select class="" name="selecao_esporte" id="options">
<option value="" disabled selected>Selecione um esporte</option>
{% for sport in disciplines %}
<option value="{{ sport['id'] }}">{{ translations.get(sport['name']) }}</option>
{% endfor %}
</select>
<button type="submit">Enviar</button>
</form>
<button type="submit">Filtrar</button>
</form>

{% if show_previous %}
<a href="{{ url_for('calendário', day=day_minus_one) }}">
<a href="{{ url_for('resultados', day=day_minus_one) }}">
<button>Anterior</button>
</a>
{% endif %}
{% if show_next %}
<a href="{{ url_for('calendário', day=day_plus_one) }}">
<a href="{{ url_for('resultados', day=day_plus_one) }}">
<button>Próximo</button>
</a>
{% endif %}
@@ -50,49 +50,37 @@ <h1 class="date">{{agenda[0]['day']}}</h1>
{%elif item['competitors']|length == 0%}
TBD
{% else %}
{%set competitors_list = []%}
{% for competitor in item['competitors'] %}
{{ competitor['competitor_name'] }}
{%if loop.index == 1%}
{%set competitors_list = competitors_list.append(competitor['competitor_name'] + ' X ')%}
{% else %}
{%set competitors_list = competitors_list.append(competitor['competitor_name'])%}
{%endif%}
{% endfor %}
{{ competitors_list | join(' ') }}
{% endif %}
</td>
<td>{{ item['start_date'][-8:] }}
</td>
<td>{{ item['start_date'][-8:] }}</td>
</tr>
{%endfor%}
</tbody>

</table>

</section>
{% if show_more %}
<a href="{{ url_for('calendário', day=day, actual=actual) }}">
<a class="filter" href="{{ url_for('resultados', day=day, actual=actual) }}">
<button>Mostrar mais</button>
</a>
{% endif %}
{% if (actual - 10) > 0 %}
<a href="{{ url_for('calendário', day=day, actual=(actual-10)) }}">
<button>Mostrar menos</button>
</a>
{% endif %}
<br>
{% if show_previous %}
<a href="{{ url_for('calendário', day=day_minus_one) }}">
<button>Anterior</button>
</a>
{% endif %}
{% if show_next %}
<a href="{{ url_for('calendário', day=day_plus_one) }}">
<button>Próximo</button>
</a>
{% endif %}
{% endif %}
{% if (actual - 10) > 0 %}
<a class="filter" href="{{ url_for('resultados', day=day, actual=(actual-10)) }}">
<button>Mostrar menos</button>
</a>
{% endif %}



<form action="{{ url_for('calendario_filtrado') }}" method="post">
<label for="options">Escolha uma opção:</label>
<select name="selecao_esporte" id="options">
<option value="" disabled selected>Selecione um esporte</option>
{% for sport in disciplines %}
<option value="{{ sport['id'] }}">{{ sport['name'] }}</option>
{% endfor %}
</select>
<button type="submit">Enviar</button>
</form>

{%endblock%}
48 changes: 31 additions & 17 deletions hackaton/templates/pages/calendario_filtrado.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{%extends "partials/template.html"%}
{% block background_image %}
<!-- Nenhuma imagem de fundo aqui -->
{% endblock %}
{%block content%}

<h1 class="date">{{agenda[0]['day']}}</h1>
<div class="filter">
<form action="{{ url_for('calendario_filtrado') }}" method="post">
<label for="options">Escolha uma opção:</label>
<select name="selecao_esporte" id="options">
<img class="filter-image" src="{{url_for('static', filename='images/filtro.png')}}" alt="">
<select class="" name="selecao_esporte" id="options">
<option value="" disabled selected>Selecione um esporte</option>
{% for sport in disciplines %}
<option value="{{ sport['id'] }}">{{ translations.get(sport['name']) }}</option>
{% endfor %}
</select>
<button type="submit">Enviar</button>
</form>
<button type="submit">Filtrar</button>
</form>

{% if show_previous %}
<a href="{{ url_for('calendário', day=day_minus_one) }}">
@@ -25,29 +29,39 @@
{% endif %}
</div>

<section class="container">
<section class="schedule-container">
<table class="schedule">
<thead >
<tr >
<th>#</th>
<th>País</th>
<th>Data</th>
<th>Esporte</th>
<th>Evento</th>
<th>Competidores</th>
<th>Hora</th>
</tr>
</thead>
<tbody >
{%for item in agenda%}
<tr>
<td>{{ translations.get(item['discipline_name']) }}</td>
<td>{{ item['detailed_event_name'] }}</td>
<td>{{ item['start_date'] }}
<td>{{item['detailed_event_name']}}</td>
<td>
{% if len(item['competitors']) < 3 %}
{% for competidor in item['competitors'] %}
{{ competidor['competitor_name'] }}
{% endfor %}
{% endif %}
</td>

{% if item['competitors']|length > 2%}
Qualificator
{%elif item['competitors']|length == 0%}
TBD
{% else %}
{%set competitors_list = []%}
{% for competitor in item['competitors'] %}
{%if loop.index == 1%}
{%set competitors_list = competitors_list.append(competitor['competitor_name'] + ' X ')%}
{% else %}
{%set competitors_list = competitors_list.append(competitor['competitor_name'])%}
{%endif%}
{% endfor %}
{{ competitors_list | join(' ') }}
{% endif %}
</td>
<td>{{ item['start_date'][-8:] }}</td>
</tr>

{%endfor%}
51 changes: 33 additions & 18 deletions hackaton/templates/pages/resultados.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{%extends "partials/template.html"%}
{% block background_image %}
<!-- Nenhuma imagem de fundo aqui -->
{% endblock %}
{%block content%}

<h1 class="date">{{agenda[0]['day']}}</h1>
<div class="filter">
<form action="{{ url_for('calendario_filtrado') }}" method="post">
<label for="options">Escolha uma opção:</label>
<select name="selecao_esporte" id="options">
<form action="{{ url_for('resultados_filtrados') }}" method="post">
<img class="filter-image" src="{{url_for('static', filename='images/filtro.png')}}" alt="">
<select class="" name="selecao_esporte" id="options">
<option value="" disabled selected>Selecione um esporte</option>
{% for sport in disciplines %}
<option value="{{ sport['id'] }}">{{ translations.get(sport['name']) }}</option>
{% endfor %}
</select>
<button type="submit">Enviar</button>
</form>
<button type="submit">Filtrar</button>
</form>

{% if show_previous %}
<a href="{{ url_for('calendário', day=day_minus_one) }}">
<a href="{{ url_for('resultados', day=day_minus_one) }}">
<button>Anterior</button>
</a>
{% endif %}
{% if show_next %}
<a href="{{ url_for('calendário', day=day_plus_one) }}">
<a href="{{ url_for('resultados', day=day_plus_one) }}">
<button>Próximo</button>
</a>
{% endif %}
@@ -29,24 +33,35 @@
<table class="schedule">
<thead >
<tr >
<th>#</th>
<th>País</th>
<th>Data</th>
<th>Esporte</th>
<th>Evento</th>
<th>Competidores</th>
<th>Hora</th>
</tr>
</thead>
<tbody >
{%for item in agenda%}
<tr>
<td>{{ translations.get(item['discipline_name']) }}</td>
<td>{{ item['detailed_event_name'] }}</td>
<td>{{ item['start_date'] }}
<td>{{ item['detailed_event_name'] }}</td>
<td>
{% if len(item['competitors']) < 3 %}
{% for competidor in item['competitors'] %}
{{ competidor['competitor_name'] }}
{% if item['competitors']|length > 2%}
Qualificator
{%elif item['competitors']|length == 0%}
TBD
{% else %}
{%set competitors_list = []%}
{% for competitor in item['competitors'] %}
{%if loop.index == 1%}
{%set competitors_list = competitors_list.append(competitor['competitor_name'] + ' ' + competitor['result_mark'] + ' X ')%}
{% else %}
{%set competitors_list = competitors_list.append(competitor['result_mark'] + ' ' + competitor['competitor_name'] )%}
{%endif%}
{% endfor %}
{{ competitors_list | join(' ') }}
{% endif %}
</td>
</td>
<td>{{ item['start_date'][-8:] }}</td>

</tr>

@@ -56,12 +71,12 @@
</table>
</section>
{% if show_more %}
<a href="{{ url_for('calendário', day=day, actual=actual) }}">
<a class="filter" href="{{ url_for('calendário', day=day, actual=actual) }}">
<button>Mostrar mais</button>
</a>
{% endif %}
{% if (actual - 10) > 0 %}
<a href="{{ url_for('calendário', day=day, actual=(actual-10)) }}">
<a class="filter" href="{{ url_for('calendário', day=day, actual=(actual-10)) }}">
<button>Mostrar menos</button>
</a>
{% endif %}
83 changes: 83 additions & 0 deletions hackaton/templates/pages/resultados_filtrados.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{%extends "partials/template.html"%}
{% block background_image %}
<!-- Nenhuma imagem de fundo aqui -->
{% endblock %}
{%block content%}

<h1 class="date">{{agenda[0]['day']}}</h1>
<div class="filter">
<form action="{{ url_for('resultados') }}" method="post">
<img class="filter-image" src="{{url_for('static', filename='images/filtro.png')}}" alt="">
<select class="" name="selecao_esporte" id="options">
<option value="" disabled selected>Selecione um esporte</option>
{% for sport in disciplines %}
<option value="{{ sport['id'] }}">{{ translations.get(sport['name']) }}</option>
{% endfor %}
</select>
<button type="submit">Filtrar</button>
</form>

{% if show_previous %}
<a href="{{ url_for('resultados', day=day_minus_one) }}">
<button>Anterior</button>
</a>
{% endif %}
{% if show_next %}
<a href="{{ url_for('resultados', day=day_plus_one) }}">
<button>Próximo</button>
</a>
{% endif %}
</div>

<section class="container">
<table class="schedule">
<thead >
<tr >
<th>Esporte</th>
<th>Evento</th>
<th>Competidores</th>
<th>Hora</th>
</tr>
</thead>
<tbody >
{%for item in agenda%}
<tr>
<td>{{ translations.get(item['discipline_name']) }}</td>
<td>{{ item['detailed_event_name'] }}</td>
<td>
{% if item['competitors']|length > 2%}
Qualificator
{%elif item['competitors']|length == 0%}
TBD
{% else %}
{%set competitors_list = []%}
{% for competitor in item['competitors'] %}
{%if loop.index == 1%}
{%set competitors_list = competitors_list.append(competitor['competitor_name'] + ' ' + competitor['result_mark'] + ' X ')%}
{% else %}
{%set competitors_list = competitors_list.append(competitor['result_mark'] + ' ' + competitor['competitor_name'] )%}
{%endif%}
{% endfor %}
{{ competitors_list | join(' ') }}
{% endif %}
</td>
<td>{{ item['start_date'][-8:] }}</td>

</tr>

{%endfor%}
</tbody>

</table>
</section>
{% if show_more %}
<a class="filter" href="{{ url_for('calendário', day=day, actual=actual) }}">
<button>Mostrar mais</button>
</a>
{% endif %}
{% if (actual - 10) > 0 %}
<a class="filter" href="{{ url_for('calendário', day=day, actual=(actual-10)) }}">
<button>Mostrar menos</button>
</a>
{% endif %}
{%endblock%}
31 changes: 30 additions & 1 deletion hackaton/views.py
Original file line number Diff line number Diff line change
@@ -99,8 +99,37 @@ def resultados():
context = {"agenda": agenda, "day_plus_one": day_plus_one, "day_minus_one": day_minus_one,
"show_previous": show_previous, "show_next": show_next, "disciplines": disciplines, "actual": actual, "day":day,
"show_more":show_more, "translations": TRANSLATIONS}
return render_template('pages/resultados.html', **context)

return render_template('pages/agenda.html', **context)
@app.route('/resultados_filtrados', methods=['POST', 'GET'])
def resultados_filtrados():
day = request.args.get('day', datetime.now().strftime('%Y-%m-%d'))
sport = request.args.get('sport')
disciplines = get_disciplines()

if request.method == 'POST':
form_data = request.form.to_dict()
if form_data.get('selecao_esporte'):
sport = form_data.get('selecao_esporte')

else:
return redirect('resultados')

show_next, show_previous, day_plus_one, day_minus_one = check_if_days_are_valid(day)

actual = request.args.get('actual', 1)

agenda, final_url, show_more = get_agenda(actual, day, sport)

if show_more:
actual = casting_actual(final_url, day)
agenda = time_to_saopaulo(agenda)

context = {"agenda": agenda, "day_plus_one": day_plus_one, "day_minus_one": day_minus_one,
"show_previous": show_previous, "show_next": show_next, "sport": sport, "actual": actual,
"translations": TRANSLATIONS, "disciplines": disciplines}

return render_template('pages/resultados_filtrados.html', **context, len=len)

@app.route('/historia')
def historia():
38 changes: 6 additions & 32 deletions teste.py
Original file line number Diff line number Diff line change
@@ -14,16 +14,16 @@

#print(requisicao)

# url = f'https://apis.codante.io/olympic-games/disciplines'
# req = requests.get(url)
# req = req.json()
# url = f'https://apis.codante.io/olympic-games/disciplines'
# req = requests.get(url)
# req = req.json()

# for i in req['data']:
# print(i['name'])
# for i in req['data']:
# print(i['name'])

#for i in requisicao['links']:

#url = f'https://apis.codante.io/olympic-games/events?page=27&date={formatted_date}'
#url = f'https://apis.codante.io/olympic-games/events?page=1&date=2024-08-01'
#req = requests.get(url)
#req = req.json()

@@ -36,29 +36,3 @@
#for i in requisicao['data']:
# print(f"{i['rank']} - {i['name']} - Ouro: {i['gold_medals']} | Prata: {i['silver_medals']} | Bronze: {i['bronze_medals']}")

def get_agenda(actual, day, sport=None):
show_more = True
url = f'https://apis.codante.io/olympic-games/events?page={actual}&date={day}'
if sport:
url = f'https://apis.codante.io/olympic-games/events?page={actual}&date={day}&discipline={sport}'
req = requests.get(url)
req = req.json()
agenda = []
total_pages = 0
while url != None and total_pages<5:
for game in req['data']:
for competitor in game['competitors']:
if len(competitor) > 2:
competitor['competitors_name'] = 'Quali'
agenda.extend(req['data']) #Pega todos os jogos
req = requests.get(url)
req = req.json()

if req['links']['next'] != None:
url = f"{req['links']['next']}&date={day}"
if sport:
url = f"{url}&discipline={sport}"
total_pages +=1
else:
url = None
show_more = False