2018-05-08 15:05:12 +00:00
|
|
|
# Generated by Django 2.0.4 on 2018-05-08 07:42
|
|
|
|
|
2018-06-21 07:19:09 +00:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2020-02-12 12:10:41 +00:00
|
|
|
from django.db import migrations
|
2018-05-08 15:05:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def add_teams_to_categories(apps, schema_editor):
|
|
|
|
InfoCategory = apps.get_model("info", "InfoCategory")
|
|
|
|
Team = apps.get_model("teams", "Team")
|
|
|
|
Camp = apps.get_model("camps", "Camp")
|
|
|
|
|
2018-06-21 07:19:09 +00:00
|
|
|
try:
|
|
|
|
# 2016 - Everything is orga team
|
|
|
|
camp2016 = Camp.objects.get(slug="bornhack-2016")
|
|
|
|
orga2016 = Team.objects.get(camp=camp2016, name="Orga")
|
|
|
|
InfoCategory.objects.filter(camp=camp2016).update(team=orga2016)
|
|
|
|
|
|
|
|
# 2017 - Everything is orga team
|
|
|
|
camp2017 = Camp.objects.get(slug="bornhack-2017")
|
|
|
|
orga2017 = Team.objects.get(camp=camp2017, name="Orga")
|
|
|
|
InfoCategory.objects.filter(camp=camp2017).update(team=orga2017)
|
|
|
|
|
|
|
|
# 2018 - Map categories to teams
|
|
|
|
camp2018 = Camp.objects.get(slug="bornhack-2018")
|
|
|
|
team2018 = Team.objects.filter(camp=camp2018)
|
|
|
|
infocategories2018 = InfoCategory.objects.filter(camp=camp2018)
|
|
|
|
|
|
|
|
# Info team
|
|
|
|
infoteam = team2018.get(name="Info")
|
|
|
|
info_anchors = [
|
|
|
|
"what",
|
|
|
|
"when",
|
|
|
|
"travel",
|
|
|
|
"where",
|
|
|
|
"sleep",
|
|
|
|
"bicycles",
|
|
|
|
"infodesk-and-cert",
|
|
|
|
"shower-and-toilets",
|
|
|
|
"venue-map",
|
|
|
|
"villages",
|
|
|
|
]
|
|
|
|
infocategories2018.filter(anchor__in=info_anchors).update(team=infoteam)
|
|
|
|
|
|
|
|
# Food team
|
|
|
|
food = team2018.get(name="Food")
|
|
|
|
infocategories2018.filter(anchor__in=["food-and-groceries"]).update(team=food)
|
|
|
|
|
|
|
|
# NOC team
|
|
|
|
noc = team2018.get(name="NOC")
|
|
|
|
infocategories2018.filter(anchor__in=["network"]).update(team=noc)
|
|
|
|
|
|
|
|
# Power team
|
|
|
|
power = team2018.get(name="Power")
|
|
|
|
infocategories2018.filter(anchor__in=["power"]).update(team=power)
|
|
|
|
|
|
|
|
# Shuttle bus
|
|
|
|
shuttle_bus = team2018.get(name="Shuttle Bus")
|
|
|
|
infocategories2018.filter(anchor__in=["shuttle-bus"]).update(team=shuttle_bus)
|
|
|
|
|
|
|
|
# Bar
|
|
|
|
bar = team2018.get(name="Bar")
|
|
|
|
infocategories2018.filter(anchor__in=["bar"]).update(team=bar)
|
|
|
|
|
|
|
|
# Make info team catch all remaining
|
|
|
|
infocategories2018.filter(team__isnull=True).update(team=infoteam)
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
pass
|
2018-05-20 20:27:41 +00:00
|
|
|
|
2018-05-08 15:05:12 +00:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
dependencies = [("info", "0004_infocategory_team")]
|
2018-05-08 15:05:12 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
operations = [migrations.RunPython(add_teams_to_categories)]
|