Adjust weekend page high pithing
Don't highlight a week number when showing weekends for different year. Example: https://edwardbetts.com/agenda/weekends?year=2100&week=1 Closes: #198
This commit is contained in:
parent
7f12282c42
commit
f499015466
|
|
@ -16,9 +16,12 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
{% set current_isocalendar = today.isocalendar() %}
|
||||||
|
|
||||||
{% for weekend in items %}
|
{% for weekend in items %}
|
||||||
{% set week_number = weekend.date.isocalendar().week %}
|
{% set week_number = weekend.date.isocalendar().week %}
|
||||||
{% if week_number == current_week_number %}
|
{% set iso_week_year = weekend.date.isocalendar().year %}
|
||||||
|
{% if week_number == current_week_number and iso_week_year == current_isocalendar.year %}
|
||||||
{% set extra_class = " bg-warning-subtle" %}
|
{% set extra_class = " bg-warning-subtle" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set extra_class = "" %}
|
{% set extra_class = "" %}
|
||||||
|
|
|
||||||
21
web_view.py
21
web_view.py
|
|
@ -28,6 +28,7 @@ import agenda.trip
|
||||||
import agenda.trip_schengen
|
import agenda.trip_schengen
|
||||||
import agenda.utils
|
import agenda.utils
|
||||||
from agenda import calendar, format_list_with_ampersand, travel, uk_tz
|
from agenda import calendar, format_list_with_ampersand, travel, uk_tz
|
||||||
|
from agenda.schengen import get_country_flag
|
||||||
from agenda.types import StrDict, Trip
|
from agenda.types import StrDict, Trip
|
||||||
|
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
@ -40,7 +41,6 @@ agenda.error_mail.setup_error_mail(app)
|
||||||
@app.template_filter("country_flag")
|
@app.template_filter("country_flag")
|
||||||
def country_flag_filter(country_code: str) -> str:
|
def country_flag_filter(country_code: str) -> str:
|
||||||
"""Convert country code to emoji flag."""
|
"""Convert country code to emoji flag."""
|
||||||
from agenda.schengen import get_country_flag
|
|
||||||
return get_country_flag(country_code)
|
return get_country_flag(country_code)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -247,13 +247,17 @@ async def weekends() -> str:
|
||||||
week = int(week_str)
|
week = int(week_str)
|
||||||
year = int(year_str) if year_str else today.year
|
year = int(year_str) if year_str else today.year
|
||||||
if week < 1 or week > 53:
|
if week < 1 or week > 53:
|
||||||
return flask.abort(400, description="Week number must be between 1 and 53.")
|
return flask.abort(
|
||||||
|
400, description="Week number must be between 1 and 53."
|
||||||
|
)
|
||||||
# Calculate the date of the first day of the given week
|
# Calculate the date of the first day of the given week
|
||||||
jan_1 = date(year, 1, 1)
|
jan_1 = date(year, 1, 1)
|
||||||
week_1_start = jan_1 - timedelta(days=jan_1.weekday())
|
week_1_start = jan_1 - timedelta(days=jan_1.weekday())
|
||||||
start = week_1_start + timedelta(weeks=week - 1)
|
start = week_1_start + timedelta(weeks=week - 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return flask.abort(400, description="Invalid week or year format. Use integers.")
|
return flask.abort(
|
||||||
|
400, description="Invalid week or year format. Use integers."
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
start = date(today.year, 1, 1)
|
start = date(today.year, 1, 1)
|
||||||
|
|
||||||
|
|
@ -263,7 +267,10 @@ async def weekends() -> str:
|
||||||
busy_events = agenda.busy.get_busy_events(start, app.config, trip_list)
|
busy_events = agenda.busy.get_busy_events(start, app.config, trip_list)
|
||||||
weekends = agenda.busy.weekends(start, busy_events)
|
weekends = agenda.busy.weekends(start, busy_events)
|
||||||
return flask.render_template(
|
return flask.render_template(
|
||||||
"weekends.html", items=weekends, current_week_number=current_week_number
|
"weekends.html",
|
||||||
|
items=weekends,
|
||||||
|
current_week_number=current_week_number,
|
||||||
|
today=today,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -415,11 +422,11 @@ def get_trip_list(
|
||||||
for trip in agenda.trip.build_trip_list(route_distances=route_distances)
|
for trip in agenda.trip.build_trip_list(route_distances=route_distances)
|
||||||
if flask.g.user.is_authenticated or not trip.private
|
if flask.g.user.is_authenticated or not trip.private
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add Schengen compliance information to each trip
|
# Add Schengen compliance information to each trip
|
||||||
for trip in trips:
|
for trip in trips:
|
||||||
agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
||||||
|
|
||||||
return trips
|
return trips
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -556,7 +563,7 @@ def trip_page(start: str) -> str:
|
||||||
prev_trip, trip, next_trip = get_prev_current_and_next_trip(start, trip_list)
|
prev_trip, trip, next_trip = get_prev_current_and_next_trip(start, trip_list)
|
||||||
if not trip:
|
if not trip:
|
||||||
flask.abort(404)
|
flask.abort(404)
|
||||||
|
|
||||||
# Add Schengen compliance information
|
# Add Schengen compliance information
|
||||||
trip = agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
trip = agenda.trip_schengen.add_schengen_compliance_to_trip(trip)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue