diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2024-03-15 15:26:32 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2024-03-15 15:26:32 +0000 |
commit | 5dfaa893add978e72a2a0ec38ba7664cfbbe668c (patch) | |
tree | 71f6f6b9dae1a018d4f676dcd7dc4094d4d12c43 /core/utils.py | |
parent | 5523c7a4840460857954819c8ae2b09c12103877 (diff) | |
download | troggle-5dfaa893add978e72a2a0ec38ba7664cfbbe668c.tar.gz troggle-5dfaa893add978e72a2a0ec38ba7664cfbbe668c.tar.bz2 troggle-5dfaa893add978e72a2a0ec38ba7664cfbbe668c.zip |
make missing Expo work if mroe than one year skipped
Diffstat (limited to 'core/utils.py')
-rw-r--r-- | core/utils.py | 15 |
1 files changed, 11 insertions, 4 deletions
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 |