2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00: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

View File

@ -110,14 +110,21 @@ def make_new_expo_dir(year):
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')
if expos:
year = str(datetime.now(timezone.utc).year)
last_expo = expos[0].year
make_new_expo_dir(year)
if last_expo != year: # coming year, after Dec.31st
make_new_expo(year)
make_new_expo_dir(year)
if int(last_expo) < int(year): # coming year, after Dec.31st
for y in range(int(last_expo)+1, int(year)+1):
print(f"--!{year}---")
make_new_expo(str(y))
make_new_expo_dir(str(y))
# print(f"---{year}---")
return year