2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-04-13 06:11:45 +01:00

make missing Expo work if mroe than one year skipped

This commit is contained in:
Philip Sargent 2024-03-15 15:26:32 +00:00
parent 5523c7a484
commit 5dfaa893ad

@ -110,14 +110,21 @@ def make_new_expo_dir(year):
def current_expo(): def current_expo():
"""Returns the current expo year, but also checks if the most recent expo year is the same
as this year. If it is not, then it creates an empty Expedition and fixes some files and
folders. If were are more than one year out of date, it creates all intervening Expo objects
and folders. You will need to tidy this up manually.
"""
expos = Expedition.objects.all().order_by('-year') expos = Expedition.objects.all().order_by('-year')
if expos: if expos:
year = str(datetime.now(timezone.utc).year) year = str(datetime.now(timezone.utc).year)
last_expo = expos[0].year last_expo = expos[0].year
make_new_expo_dir(year) if int(last_expo) < int(year): # coming year, after Dec.31st
if last_expo != year: # coming year, after Dec.31st for y in range(int(last_expo)+1, int(year)+1):
make_new_expo(year) print(f"--!{year}---")
make_new_expo_dir(year)
make_new_expo(str(y))
make_new_expo_dir(str(y))
# print(f"---{year}---") # print(f"---{year}---")
return year return year