diff --git a/core/utils.py b/core/utils.py index e4fda48..6670a65 100644 --- a/core/utils.py +++ b/core/utils.py @@ -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