From fddc39d3f09d2c2ad95453c6cd4a159a30546051 Mon Sep 17 00:00:00 2001 From: Christian Henriksen Date: Wed, 4 Feb 2026 21:03:56 +0100 Subject: [PATCH] Add 'year' property for camp model. Before we had to do 'camp.camp.lower.year' to get the year, now we can do 'camp.year' --- src/camps/models.py | 5 + src/camps/tests.py | 7 + src/program/views.py | 2 +- .../copy_tickets_from_camp_to_camp.py | 20 +- src/tickets/views.py | 2 +- src/tokens/templates/token_dashboard.html | 4 +- src/utils/bootstrap/base.py | 189 ++++++++---------- 7 files changed, 106 insertions(+), 123 deletions(-) diff --git a/src/camps/models.py b/src/camps/models.py index d92a2417e..2e5a67662 100644 --- a/src/camps/models.py +++ b/src/camps/models.py @@ -322,6 +322,11 @@ def teardown_days(self): # convenience properties to access Camp-related stuff easily from the Camp object + @property + def year(self) -> int: + """Return the year of this camp.""" + return self.camp.lower.year + @property def event_types(self): """Return all event types with at least one event in this camp.""" diff --git a/src/camps/tests.py b/src/camps/tests.py index 871bd05e7..9ed6370e1 100644 --- a/src/camps/tests.py +++ b/src/camps/tests.py @@ -213,3 +213,10 @@ def test_participant_count(self) -> None: child_one_day.save() assert self.camp.participant_count == 4 + + def test_year_of_camp(self) -> None: + """Test the property `year` return current year of camp.""" + expected = self.camp.camp.lower.year + + assert self.camp.year == expected + diff --git a/src/program/views.py b/src/program/views.py index c0a1b827e..1323714a7 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -1085,7 +1085,7 @@ def get(self, *args, **kwargs): E.version("BornHack Frab XML Generator v2.0"), E.conference( E.title(self.camp.title), - E.acronym(str(self.camp.camp.lower.year)), + E.acronym(str(self.camp.year)), E.start(self.camp.camp.lower.date().isoformat()), E.end(self.camp.camp.upper.date().isoformat()), E.days(len(self.camp.get_days("camp"))), diff --git a/src/shop/management/commands/copy_tickets_from_camp_to_camp.py b/src/shop/management/commands/copy_tickets_from_camp_to_camp.py index 27033c4be..9c04d74ba 100644 --- a/src/shop/management/commands/copy_tickets_from_camp_to_camp.py +++ b/src/shop/management/commands/copy_tickets_from_camp_to_camp.py @@ -2,14 +2,14 @@ import logging -from django.core.management import call_command from django.core.management.base import BaseCommand from django.utils import timezone from datetime import timedelta from camps.models import Camp from tickets.models import TicketType -from shop.models import Product, SubProductRelation +from shop.models import Product +from shop.models import SubProductRelation logger = logging.getLogger(f"bornhack.{__name__}") @@ -56,16 +56,16 @@ def handle(self, *args, **options) -> None: print(f"Created new TicketType {newtt}") for product in tt.product_set.filter(sub_products__isnull=True): newprod, created = Product.objects.get_or_create( - name=product.name.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + name=product.name.replace(str(fromcamp.year), str(tocamp.year)), ticket_type=newtt, - slug=product.slug.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + slug=product.slug.replace(str(fromcamp.year), str(tocamp.year)), defaults={ "price": product.price, "category": product.category, - "description": product.description.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + "description": product.description.replace(str(fromcamp.year), str(tocamp.year)), "available_in": (timezone.now(), tocamp.camp.upper + timedelta(days=30)), "cost": product.cost, - "comment": product.comment.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + "comment": product.comment.replace(str(fromcamp.year), str(tocamp.year)), } ) if created: @@ -77,15 +77,15 @@ def handle(self, *args, **options) -> None: print(product) # create bundle product newprod, created = Product.objects.get_or_create( - name=product.name.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), - slug=product.slug.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + name=product.name.replace(str(fromcamp.year), str(tocamp.year)), + slug=product.slug.replace(str(fromcamp.year), str(tocamp.year)), defaults={ "price": product.price, "category": product.category, - "description": product.description.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + "description": product.description.replace(str(fromcamp.year), str(tocamp.year)), "available_in": (timezone.now(), tocamp.camp.upper + timedelta(days=30)), "cost": product.cost, - "comment": product.comment.replace(str(fromcamp.camp.lower.year), str(tocamp.camp.lower.year)), + "comment": product.comment.replace(str(fromcamp.year), str(tocamp.year)), } ) for spr in product.sub_product_relations.all(): diff --git a/src/tickets/views.py b/src/tickets/views.py index 2df2ecc9a..99fb53a8c 100644 --- a/src/tickets/views.py +++ b/src/tickets/views.py @@ -65,7 +65,7 @@ def get(self, request, *args, **kwargs): ticket = self.get_object(*args, **kwargs) response = HttpResponse(content_type="application/pdf") response["Content-Disposition"] = ( - f'attachment; filename="BornHack_{ticket.ticket_type.camp.camp.lower.year}_{ticket.shortname}_ticket_{ticket.pk}.pdf"' + f'attachment; filename="BornHack_{ticket.ticket_type.camp.year}_{ticket.shortname}_ticket_{ticket.pk}.pdf"' ) response.write(ticket.generate_pdf().getvalue()) return response diff --git a/src/tokens/templates/token_dashboard.html b/src/tokens/templates/token_dashboard.html index a08ed352b..d09dd455a 100644 --- a/src/tokens/templates/token_dashboard.html +++ b/src/tokens/templates/token_dashboard.html @@ -65,13 +65,13 @@

How to play?

Token examples:

Tokens are hidden or in plain sight physically or virtually on the BornHack venue, online and offline.

-

Submit the tokens you find in the field below. You can start with this one: HelloTokenHunters{{ camp.camp.lower.year }}

+

Submit the tokens you find in the field below. You can start with this one: HelloTokenHunters{{ camp.year }}

diff --git a/src/utils/bootstrap/base.py b/src/utils/bootstrap/base.py index 1c56b3c4b..f1dbff7d2 100644 --- a/src/utils/bootstrap/base.py +++ b/src/utils/bootstrap/base.py @@ -603,7 +603,7 @@ def create_product_categories(self) -> None: def create_camp_ticket_types(self, camp: Camp) -> dict: """Create camp ticket types.""" types = {} - self.output(f"Creating tickettypes for {camp.camp.lower.year}...") + self.output(f"Creating tickettypes for {camp.year}...") types["adult_full_week"] = TicketType.objects.create( name="Adult Full Week", camp=camp, @@ -652,8 +652,7 @@ def create_camp_products( ) -> dict: """Create camp shop products.""" products = {} - year = camp.camp.lower.year - camp_prefix = f"BornHack {year}" + camp_prefix = f"BornHack {camp.year}" name = f"{camp_prefix} Standard ticket" products["ticket1"] = Product.objects.create( @@ -662,8 +661,8 @@ def create_camp_products( price=1200, category=categories["tickets"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-standard-ticket", ticket_type=ticket_types["adult_full_week"], @@ -676,8 +675,8 @@ def create_camp_products( price=1337, category=categories["tickets"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-hacker-ticket", ticket_type=ticket_types["adult_full_week"], @@ -690,8 +689,8 @@ def create_camp_products( price=495, category=categories["tickets"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-child-ticket", ticket_type=ticket_types["child_full_week"], @@ -704,8 +703,8 @@ def create_camp_products( price=300, category=categories["tickets"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-one-day-ticket", ticket_type=ticket_types["adult_one_day"], @@ -718,8 +717,8 @@ def create_camp_products( price=165, category=categories["tickets"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-one-day-child-ticket", ticket_type=ticket_types["child_one_day"], @@ -732,8 +731,8 @@ def create_camp_products( price=3325, category=categories["villages"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-village-tent-3x3m-no-floor", ticket_type=ticket_types["village"], @@ -746,8 +745,8 @@ def create_camp_products( price=3675, category=categories["villages"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-village-tent-3x3m-with-floor", ticket_type=ticket_types["village"], @@ -760,8 +759,8 @@ def create_camp_products( price=150, category=categories["merchandise"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-tshirt-large", ticket_type=ticket_types["merchandise"], @@ -774,8 +773,8 @@ def create_camp_products( price=150, category=categories["merchandise"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-tshirt-medium", ticket_type=ticket_types["merchandise"], @@ -788,8 +787,8 @@ def create_camp_products( price=150, category=categories["merchandise"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-tshirt-small", ticket_type=ticket_types["merchandise"], @@ -802,8 +801,8 @@ def create_camp_products( price=100, category=categories["facilities"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-100-hax", ticket_type=ticket_types["facilities"], @@ -816,8 +815,8 @@ def create_camp_products( price=18000, category=categories["packages"], available_in=( - datetime(year, 1, 1, 12, 0, tzinfo=tz), - datetime(year, 12, 20, 12, 0, tzinfo=tz), + datetime(camp.year, 1, 1, 12, 0, tzinfo=tz), + datetime(camp.year, 12, 20, 12, 0, tzinfo=tz), ), slug=f"{camp.slug}-corporate-hackers-small", ) @@ -918,11 +917,10 @@ def create_orders(self, users: dict, camp_products: dict) -> dict: def create_camp_tracks(self, camp: Camp) -> dict: """Create camp event tracks.""" tracks = {} - year = camp.camp.lower.year - self.output(f"Creating event_tracks for {year}...") + self.output(f"Creating event_tracks for {camp.year}...") tracks[1] = EventTrack.objects.create( camp=camp, - name=f"BornHack {year}", + name=f"BornHack {camp.year}", slug=camp.slug, ) @@ -931,8 +929,7 @@ def create_camp_tracks(self, camp: Camp) -> dict: def create_event_locations(self, camp: Camp) -> dict: """Create all event locations.""" locations = {} - year = camp.camp.lower.year - self.output(f"Creating event_locations for {year}...") + self.output(f"Creating event_locations for {camp.year}...") locations["speakers_tent"] = EventLocation.objects.create( name="Speakers Tent", slug="speakers-tent", @@ -992,17 +989,16 @@ def create_event_locations(self, camp: Camp) -> dict: def create_camp_news(self, camp: Camp) -> None: """Create camp news.""" - year = camp.camp.lower.year - self.output(f"Creating news for {year}...") + self.output(f"Creating news for {camp.year}...") NewsItem.objects.create( title=f"Welcome to {camp.title}", content="news body here with html support", - published_at=datetime(year, 8, 27, 12, 0, tzinfo=tz), + published_at=datetime(camp.year, 8, 27, 12, 0, tzinfo=tz), ) NewsItem.objects.create( title=f"{camp.title} is over", content="news body here", - published_at=datetime(year, 9, 4, 12, 0, tzinfo=tz), + published_at=datetime(camp.year, 9, 4, 12, 0, tzinfo=tz), ) def create_camp_event_sessions( @@ -1099,8 +1095,7 @@ def create_camp_event_sessions( def create_camp_proposals(self, camp: Camp, event_types: dict) -> None: """Create camp proposals: talks, workshops and keynotes.""" - year = camp.camp.lower.year - self.output(f"Creating event- and speaker_proposals for {year}...") + self.output(f"Creating event- and speaker_proposals for {camp.year}...") # add 45 talks talkproposals = EventProposalFactory.create_batch( @@ -1164,9 +1159,8 @@ def create_camp_proposals(self, camp: Camp, event_types: dict) -> None: def create_proposal_urls(self, camp: Camp) -> None: """Create URL objects for the proposals.""" - year = camp.camp.lower.year self.output( - f"Creating URLs for Speaker- and EventProposals for {year}...", + f"Creating URLs for Speaker- and EventProposals for {camp.year}...", ) SpeakerProposalUrlFactory.create_batch( 100, @@ -1183,9 +1177,8 @@ def create_proposal_urls(self, camp: Camp) -> None: def generate_speaker_availability(self, camp: Camp) -> None: """Create SpeakerAvailability objects for the SpeakerProposals.""" - year = camp.camp.lower.year self.output( - f"Generating random SpeakerProposalAvailability for {year}...", + f"Generating random SpeakerProposalAvailability for {camp.year}...", ) for sp in camp.speaker_proposals.all(): # generate a matrix for this speaker_proposals event_types @@ -1254,8 +1247,7 @@ def approve_event_proposals(self, camp: Camp) -> None: def create_camp_scheduling(self, camp: Camp, autoschedule: bool) -> None: """Create camp scheduling.""" - year = camp.camp.lower.year - self.output(f"Creating scheduling for {year}...") + self.output(f"Creating scheduling for {camp.year}...") # create a lunchbreak daily in speakers tent lunch = Event.objects.get(track__camp=camp, title="Lunch break") @@ -1287,14 +1279,13 @@ def create_camp_scheduling(self, camp: Camp, autoschedule: bool) -> None: self.output(f"Got exception while calculating autoschedule: {E}") scheduleduration = timezone.now() - schedulestart self.output( - f"Done running autoscheduler for {year}... It took {scheduleduration}", + f"Done running autoscheduler for {camp.year}... It took {scheduleduration}", ) def create_camp_speaker_event_conflicts(self, camp: Camp) -> None: """Create speaker event conflicts.""" - year = camp.camp.lower.year self.output( - f"Generating event_conflicts for SpeakerProposals for {year}...", + f"Generating event_conflicts for SpeakerProposals for {camp.year}...", ) # loop over all for sp in camp.speaker_proposals.all(): @@ -1311,12 +1302,11 @@ def create_camp_speaker_event_conflicts(self, camp: Camp) -> None: def create_camp_rescheduling(self, camp: Camp, autoschedule: bool) -> None: """Reschedule program for this camp.""" - year = camp.camp.lower.year # reapprove all speaker_proposals so the new availability takes effect for prop in camp.speaker_proposals.filter(proposal_status="approved"): prop.mark_as_approved() # exercise the autoscheduler a bit - self.output(f"Rescheduling {year}...") + self.output(f"Rescheduling {camp.year}...") if autoschedule: scheduler = AutoScheduler(camp=camp) schedulestart = timezone.now() @@ -1329,12 +1319,11 @@ def create_camp_rescheduling(self, camp: Camp, autoschedule: bool) -> None: ) autoschedule = None scheduleduration = timezone.now() - schedulestart - self.output(f"Done rescheduling for {year}... It took {scheduleduration}.") + self.output(f"Done rescheduling for {camp.year}... It took {scheduleduration}.") def create_camp_villages(self, camp: Camp, users: dict) -> None: """Create camp villages.""" - year = camp.camp.lower.year - self.output(f"Creating villages for {year}...") + self.output(f"Creating villages for {camp.year}...") Village.objects.create( contact=users[1], camp=camp, @@ -1370,8 +1359,7 @@ def create_camp_villages(self, camp: Camp, users: dict) -> None: def create_camp_teams(self, camp: Camp) -> dict: """Create camp teams.""" teams = {} - year = camp.camp.lower.year - self.output(f"Creating teams for {year}...") + self.output(f"Creating teams for {camp.year}...") teams["orga"] = Team.objects.create( name="Orga", description="The Orga team are the main organisers. " @@ -1442,8 +1430,7 @@ def create_camp_teams(self, camp: Camp) -> dict: def create_camp_team_tasks(self, camp: Camp, teams: dict) -> None: """Create camp team tasks.""" - year = camp.camp.lower.year - self.output(f"Creating TeamTasks for {year}...") + self.output(f"Creating TeamTasks for {camp.year}...") TeamTask.objects.create( team=teams["noc"], name="Setup private networks", @@ -1498,8 +1485,7 @@ def create_camp_team_memberships( ) -> dict: """Create camp team memberships.""" memberships = {} - year = camp.camp.lower.year - self.output(f"Creating team memberships for {year}...") + self.output(f"Creating team memberships for {camp.year}...") # noc team memberships["noc"] = {} memberships["noc"]["user4"] = TeamMember.objects.create( @@ -1617,13 +1603,12 @@ def create_camp_team_shifts( ) -> None: """Create camp team shifts.""" shifts = {} - year = camp.camp.lower.year - self.output(f"Creating team shifts for {year}...") + self.output(f"Creating team shifts for {camp.year}...") shifts[0] = TeamShift.objects.create( team=teams["shuttle"], shift_range=( - datetime(year, 8, 27, 2, 0, tzinfo=tz), - datetime(year, 8, 27, 8, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 2, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 8, 0, tzinfo=tz), ), people_required=1, ) @@ -1631,16 +1616,16 @@ def create_camp_team_shifts( shifts[1] = TeamShift.objects.create( team=teams["shuttle"], shift_range=( - datetime(year, 8, 27, 8, 0, tzinfo=tz), - datetime(year, 8, 27, 14, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 8, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 14, 0, tzinfo=tz), ), people_required=1, ) shifts[2] = TeamShift.objects.create( team=teams["shuttle"], shift_range=( - datetime(year, 8, 27, 14, 0, tzinfo=tz), - datetime(year, 8, 27, 20, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 14, 0, tzinfo=tz), + datetime(camp.year, 8, 27, 20, 0, tzinfo=tz), ), people_required=1, ) @@ -1648,8 +1633,7 @@ def create_camp_team_shifts( def create_camp_info_categories(self, camp: Camp, teams: dict) -> dict: """Create camp info categories.""" categories = {} - year = camp.camp.lower.year - self.output(f"Creating infocategories for {year}...") + self.output(f"Creating infocategories for {camp.year}...") categories["when"] = InfoCategory.objects.create( team=teams["orga"], headline="When is BornHack happening?", @@ -1675,13 +1659,12 @@ def create_camp_info_categories(self, camp: Camp, teams: dict) -> dict: def create_camp_info_items(self, camp: Camp, categories: dict) -> None: """Create the camp info items.""" - year = camp.camp.lower.year - self.output(f"Creating infoitems for {year}...") + self.output(f"Creating infoitems for {camp.year}...") InfoItem.objects.create( category=categories["when"], headline="Opening", anchor="opening", - body=f"BornHack {year} starts saturday, august 27th, at noon (12:00). " + body=f"BornHack {camp.year} starts saturday, august 27th, at noon (12:00). " "It will be possible to access the venue before noon if for example you arrive early " "in the morning with the ferry. But please dont expect everything to be ready before noon :)", ) @@ -1689,7 +1672,7 @@ def create_camp_info_items(self, camp: Camp, categories: dict) -> None: category=categories["when"], headline="Closing", anchor="closing", - body=f"BornHack {year} ends saturday, september 3rd, at noon (12:00). " + body=f"BornHack {camp.year} ends saturday, september 3rd, at noon (12:00). " "Rented village tents must be empty and cleaned at this time, ready to take down. " "Participants must leave the site no later than 17:00 on the closing day " "(or stay and help us clean up).", @@ -1740,8 +1723,7 @@ def create_camp_info_items(self, camp: Camp, categories: dict) -> None: def create_camp_feedback(self, camp: Camp, users: dict[User]) -> None: """Create camp feedback.""" - year = camp.camp.lower.year - self.output(f"Creating feedback for {year}...") + self.output(f"Creating feedback for {camp.year}...") Feedback.objects.create( camp=camp, user=users[1], @@ -1765,15 +1747,14 @@ def create_camp_feedback(self, camp: Camp, users: dict[User]) -> None: def create_camp_rides(self, camp: Camp, users: dict) -> None: """Create camp rides.""" - year = camp.camp.lower.year - self.output(f"Creating rides for {year}...") + self.output(f"Creating rides for {camp.year}...") Ride.objects.create( camp=camp, user=users[1], seats=2, from_location="Copenhagen", to_location="BornHack", - when=datetime(year, 8, 27, 12, 0, tzinfo=tz), + when=datetime(camp.year, 8, 27, 12, 0, tzinfo=tz), description="I have space for two people and a little bit of luggage", ) Ride.objects.create( @@ -1782,7 +1763,7 @@ def create_camp_rides(self, camp: Camp, users: dict) -> None: seats=2, from_location="BornHack", to_location="Copenhagen", - when=datetime(year, 9, 4, 12, 0, tzinfo=tz), + when=datetime(camp.year, 9, 4, 12, 0, tzinfo=tz), description="I have space for two people and a little bit of luggage", ) Ride.objects.create( @@ -1791,31 +1772,28 @@ def create_camp_rides(self, camp: Camp, users: dict) -> None: seats=1, from_location="Aarhus", to_location="BornHack", - when=datetime(year, 8, 27, 12, 0, tzinfo=tz), + when=datetime(camp.year, 8, 27, 12, 0, tzinfo=tz), description="I need a ride and have a large backpack", ) def create_camp_cfp(self, camp: Camp) -> None: """Create the camp call for participation.""" - year = camp.camp.lower.year - self.output(f"Creating CFP for {year}...") + self.output(f"Creating CFP for {camp.year}...") camp.call_for_participation_open = True - camp.call_for_participation = f"Please give a talk at Bornhack {year}..." + camp.call_for_participation = f"Please give a talk at Bornhack {camp.year}..." camp.save() def create_camp_cfs(self, camp: Camp) -> None: """Create the camp call for sponsors.""" - year = camp.camp.lower.year - self.output(f"Creating CFS for {year}...") + self.output(f"Creating CFS for {camp.year}...") camp.call_for_sponsors_open = True - camp.call_for_sponsors = f"Please give us ALL the money so that we can make Bornhack {year} the best ever!" + camp.call_for_sponsors = f"Please give us ALL the money so that we can make Bornhack {camp.year} the best ever!" camp.save() def create_camp_sponsor_tiers(self, camp: Camp) -> dict: """Create the camp sponsor tiers.""" tiers = {} - year = camp.camp.lower.year - self.output(f"Creating sponsor tiers for {year}...") + self.output(f"Creating sponsor tiers for {camp.year}...") tiers["platinum"] = SponsorTier.objects.create( name="Platinum sponsors", description="- 10 tickets\n- logo on website\n- physical banner in the speaker's tent\n- " @@ -1854,9 +1832,8 @@ def create_camp_sponsor_tiers(self, camp: Camp) -> dict: def create_camp_sponsors(self, camp: Camp, tiers: dict) -> list: """Create the camp sponsors.""" - year = camp.camp.lower.year sponsors = [] - self.output(f"Creating sponsors for {year}...") + self.output(f"Creating sponsors for {camp.year}...") sponsors.append( Sponsor.objects.create( name="PROSA", @@ -1913,8 +1890,7 @@ def create_camp_sponsor_tickets( ticket_types: dict, ) -> None: """Create tickets for camp sponsors""" - year = camp.camp.lower.year - self.output(f"Creating sponsor tickets for {year}...") + self.output(f"Creating sponsor tickets for {camp.year}...") for sponsor in sponsors: if sponsor.tier == tiers["platinum"] or sponsor.tier == tiers["gold"]: for _ in range(10): @@ -1937,8 +1913,7 @@ def create_camp_sponsor_tickets( def create_token_categories(self, camp: Camp) -> dict[str, TokenCategory]: """Create the camp tokens.""" - year = camp.camp.lower.year - self.output(f"Creating token categories for {year}...") + self.output(f"Creating token categories for {camp.year}...") categories = {} categories["physical"], _ = TokenCategory.objects.get_or_create( name="Physical", @@ -1965,8 +1940,7 @@ def create_token_categories(self, camp: Camp) -> dict[str, TokenCategory]: def create_camp_tokens(self, camp: Camp, categories: dict) -> dict[Token]: """Create the camp tokens.""" tokens = {} - year = camp.camp.lower.year - self.output(f"Creating tokens for {year}...") + self.output(f"Creating tokens for {camp.year}...") tokens[0] = Token.objects.create( camp=camp, token=get_random_string(length=32), @@ -2004,7 +1978,7 @@ def create_camp_tokens(self, camp: Camp, categories: dict) -> dict[Token]: token=get_random_string(length=32), category=categories["physical"], hint="Gadget", - description=f"Token on the back of the BornHack {year} badge", + description=f"Token on the back of the BornHack {camp.year} badge", active=True, ) tokens[5] = Token.objects.create( @@ -2025,8 +1999,7 @@ def create_camp_token_finds( users: dict[User], ) -> None: """Create the camp token finds.""" - year = camp.camp.lower.year - self.output(f"Creating token finds for {year}...") + self.output(f"Creating token finds for {camp.year}...") TokenFind.objects.create(token=tokens[3], user=users[4]) TokenFind.objects.create(token=tokens[5], user=users[4]) TokenFind.objects.create(token=tokens[2], user=users[7]) @@ -2038,8 +2011,7 @@ def create_camp_token_finds( def create_prize_ticket(self, camp: Camp, ticket_types: dict) -> None: """Create prize tickets""" - year = camp.camp.lower.year - self.output(f"Creating prize tickets for {year}...") + self.output(f"Creating prize tickets for {camp.year}...") PrizeTicket.objects.create( user=self.users[5], comment="Prize winner", @@ -2342,8 +2314,7 @@ def bootstrap_tests(self) -> None: self.create_product_categories() teams = {} for camp, read_only in self.camps: - year = camp.camp.lower.year - if year <= settings.UPCOMING_CAMP_YEAR: + if camp.year <= settings.UPCOMING_CAMP_YEAR: ticket_types = self.create_camp_ticket_types(camp) camp_products = self.create_camp_products( camp, @@ -2362,8 +2333,8 @@ def bootstrap_tests(self) -> None: self.create_prize_ticket(camp, ticket_types) self.create_camp_tracks(camp) - teams[year] = self.create_camp_teams(camp) - self.create_camp_team_memberships(camp, teams[year], self.users) + teams[camp.year] = self.create_camp_teams(camp) + self.create_camp_team_memberships(camp, teams[camp.year], self.users) camp.read_only = read_only camp.call_for_participation_open = not read_only camp.call_for_sponsors_open = not read_only @@ -2371,7 +2342,7 @@ def bootstrap_tests(self) -> None: self.camp = self.camps[1][0] self.add_team_permissions(self.camp) - self.teams = teams[self.camp.camp.lower.year] + self.teams = teams[self.camp.year] for member in TeamMember.objects.filter(team__camp=self.camp): member.save() @@ -2381,10 +2352,10 @@ def bootstrap_camp(self, options: dict) -> None: self.teams = {} for camp, read_only in self.camps: self.output( - f"----------[ Bornhack {camp.camp.lower.year} ]----------", + f"----------[ Bornhack {camp.year} ]----------", ) - if camp.camp.lower.year <= timezone.now().year: + if camp.year <= timezone.now().year: ticket_types = self.create_camp_ticket_types(camp) camp_products = self.create_camp_products( @@ -2402,7 +2373,7 @@ def bootstrap_camp(self, options: dict) -> None: self.create_camp_news(camp) teams = self.create_camp_teams(camp) - self.teams[camp.camp.lower.year] = teams + self.teams[camp.year] = teams if not read_only and not permissions_added: # add permissions for the first camp that is not read_only @@ -2504,7 +2475,7 @@ def bootstrap_camp(self, options: dict) -> None: camp.save() # Update team permissions. - if camp.camp.lower.year == settings.UPCOMING_CAMP_YEAR: + if camp.year == settings.UPCOMING_CAMP_YEAR: for member in TeamMember.objects.filter(team__camp=camp): member.save()