Fix some outstanding issues with the team controlled info categories functionality.

This commit is contained in:
Víðir Valberg Guðmundsson 2018-06-21 09:19:09 +02:00
parent 635e57b7f9
commit 43f076262b
5 changed files with 175 additions and 163 deletions

View File

@ -1,6 +1,7 @@
# Generated by Django 2.0.4 on 2018-05-08 07:42
from django.db import migrations
from django.core.exceptions import ObjectDoesNotExist
def add_teams_to_categories(apps, schema_editor):
@ -8,59 +9,62 @@ def add_teams_to_categories(apps, schema_editor):
Team = apps.get_model("teams", "Team")
Camp = apps.get_model("camps", "Camp")
# 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)
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)
# 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)
# 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)
# 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)
# 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)
# 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)
# 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)
# 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)
# 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)
# Make info team catch all remaining
infocategories2018.filter(team__isnull=True).update(team=infoteam)
except ObjectDoesNotExist:
pass
class Migration(migrations.Migration):

View File

@ -32,7 +32,7 @@ class InfoCategory(CampRelatedModel):
)
def clean(self):
if InfoItem.objects.filter(category__camp=self.camp, anchor=self.anchor).exists():
if InfoItem.objects.filter(category__team__camp=self.camp, anchor=self.anchor).exists():
# this anchor is already in use on an item, so it cannot be used (must be unique on the page)
raise ValidationError(
{'anchor': 'Anchor is already in use on an info item for this camp'}
@ -42,6 +42,8 @@ class InfoCategory(CampRelatedModel):
def camp(self):
return self.team.camp
camp_filter = 'team__camp'
def __str__(self):
return '%s (%s)' % (self.headline, self.camp)
@ -81,10 +83,10 @@ class InfoItem(CampRelatedModel):
def camp(self):
return self.category.camp
camp_filter = 'category__camp'
camp_filter = 'category__team__camp'
def clean(self):
if hasattr(self, 'category') and InfoCategory.objects.filter(camp=self.category.camp, anchor=self.anchor).exists():
if hasattr(self, 'category') and InfoCategory.objects.filter(team__camp=self.category.team.camp, anchor=self.anchor).exists():
# this anchor is already in use on a category, so it cannot be used here (they must be unique on the entire page)
raise ValidationError({'anchor': 'Anchor is already in use on an info category for this camp'})

View File

@ -7,11 +7,16 @@
Team: {{ team.name }} | {{ block.super }}
{% endblock %}
{% block content %}
<div class="page-header">
<h1>{{ team.name }} Team Details</h1>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4>Description</h4>
</div>
<div class="panel-body">
{{ team.description|untrustedcommonmark }}
</div>
@ -139,7 +144,7 @@ Team: {{ team.name }} | {{ block.super }}
</div>
{# Team info categories section - only visible for team responsible #}
{% if request.user in team.responsible_members.all %}
{% if request.user in team.responsible_members.all and team.info_categories.exists %}
<div class="panel panel-default">
<div class="panel-heading">
<h4>Info Categories</h4>
@ -148,7 +153,7 @@ Team: {{ team.name }} | {{ block.super }}
{% for info_category in team.info_categories.all %}
{{ info_category.headline }}
<h4>{{ info_category.headline }}</h4>
<table class="table table-hover">
<thead>
<tr>
@ -173,6 +178,8 @@ Team: {{ team.name }} | {{ block.super }}
<a href="{% url 'teams:info_item_create' camp_slug=camp.slug team_slug=team.slug category_anchor=info_category.anchor %}" class="btn btn-primary"><i class="fas fa-plus"></i> Create Info Item</a>
<hr />
{% endfor %}
</div>
</div>

View File

@ -91,22 +91,22 @@ urlpatterns = [
]),
),
url(
r'^info/(?P<category_anchor>[-_\w+]+)/', include([
url(
r'^create/$',
path(
'info/<slug:category_anchor>/', include([
path(
'create/',
InfoItemCreateView.as_view(),
name='info_item_create',
),
url(
r'^(?P<item_anchor>[-_\w+]+)/', include([
url(
r'^update/$',
path(
'<slug:item_anchor>/', include([
path(
'update/',
InfoItemUpdateView.as_view(),
name='info_item_update',
),
url(
r'^delete/$',
path(
'delete/',
InfoItemDeleteView.as_view(),
name='info_item_delete',
),

View File

@ -1401,110 +1401,6 @@ programming for a danish startup.
)
)
self.output("Creating infocategories for {}...".format(year))
info_cat1 = InfoCategory.objects.create(
camp=camp,
headline='When is BornHack happening?',
anchor='when'
)
info_cat2 = InfoCategory.objects.create(
camp=camp,
headline='Travel Information',
anchor='travel'
)
info_cat3 = InfoCategory.objects.create(
camp=camp,
headline='Where do I sleep?',
anchor='sleep'
)
self.output("Creating infoitems for {}...".format(year))
InfoItem.objects.create(
category=info_cat1,
headline='Opening',
anchor='opening',
body='BornHack 2016 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 :)'
)
InfoItem.objects.create(
category=info_cat1,
headline='Closing',
anchor='closing',
body='BornHack 2016 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).'
)
InfoItem.objects.create(
category=info_cat2,
headline='Public Transportation',
anchor='public-transportation',
body='''
From/Via Copenhagen
There are several ways to get to Bornholm from Copenhagen. A domestic plane departs from Copenhagen Airport, and you can get from Copenhagen Central station by either bus or train via Ystad or the Køge-Rønne ferry connection.
Plane (very fast, most expensive)
You can check plane departures and book tickets at dat.dk. There are multiple departures daily. The flight takes approximately 25 minutes.
Via Ystad (quick, cheap and easy, crosses Sweden border)
You can drive over Øresundsbroen to Ystad or you can take the train/bus from Copenhagen Central Station. You can buy train and ferry ticket at dsb.dk (Type in "København H" and "Rønne Havn"). More information about the crossing. The crossing takes 1 hour 20 minutes. In total about 3 hours 15 minutes. Due to recent developments an ID (passport, drivers license or similar) is required when crossing the Denmark/Sweden border.
Via Køge (cheap, slow)
Take the S-train to Køge Station (you need an "all zones" ticket) or travel by car. The ferry terminal is within walking distance from the station. You can check out prices here. It takes approximately 1 hour to get to Køge. The crossing takes 5 hours 30 minutes.
From Sweden/Malmö
To get to Bornholm from Malmö you may take a train from Malmö to Ystad and the ferry from Ystad to Bornholm.
Skånetrafiken runs trains from Malmö C to Ystad every 30 minutes. Trains leave at 08 and 38 minutes past the hour. Go to skanetrafiken for details.
The ferry from Ystad to Rønne leaves four times per day. Morning: 08:30-09:50 Noon: 12:30-13:50 Afternoon: 16:30-17:50 Evening: 20:30-21:50 Booking the ferry tickets prior to departure can drastically reduce the price. See "Getting from Rønne to the Venue" final step.
From Abroad
If you are going to BornHack from abroad you have different options as well.
Berlin (Germany)
There are no public transport routes from Berlin to Mukran, Sassnitz ferry terminal on Saturdays, including Aug 27 and Sept 03 the Bornhack start/end dates. Your best bet is to get a train to Dubnitz, Sassnitz station. Unfortunately it is still 1.7km to the actual ferry terminal: map of route. There is a bus, but it only goes once a weekday at 12:28 and not at all on Weekends. You can of course take a taxi. Search for routes Berlin Dubnitz on bahn.de. At the time of writing, the best route is:
08:45 Berlin Hbf train with 2 changes, 50 for a 2-way return ticket.
12:52 Sassnitz taxi, ~14, 10 min.
13:00 Mukran-Sassnitz ferry terminal
If you want to try your luck at a direct route to the ferry terminal, search for routes Berlin Sassnitz-Mukran Fährhafen on bahn.de or for routes Berlin Fährhafen Sassnitz on checkmybus.com.
Sassnitz (Germany)
There is a direct ferry taking cars going from Sassnitz ferry terminal which is 4km away from Sassnitz itself. The company is called BornholmerFærgen and the tickets cost 32 (outgoing) and 25 (return). It can also be booked from aferry.co.uk. The ferry departs for Bornholm on Aug 27 at 11:50, 13:30, and returns to Sassnitz on Sept 03 at 08:00, 09:00. Detailed timetable: English, Danish.
Kolobrzeg (Poland)
There is a passenger ferry from Kolobrzeg to Nexø havn.
Getting from Rønne to the Venue
The venue is 24km from Rønne. We will have a shuttle bus that will pick people up and take them to the venue. It is also possible to take a public bus to near the venue. Local taxis can also get you here. The company operating on Bornholm is called Dantaxi and the local phonenumber is +4556952301.
'''
)
InfoItem.objects.create(
category=info_cat1,
headline='Bus to and from BornHack',
anchor='bus-to-and-from-bornhack',
body='PROSA, the union of IT-professionals in Denmark, has set up a great deal for BornHack attendees travelling from Copenhagen to BornHack. For only 125kr, about 17 euros, you can be transported to the camp on opening day, and back to Copenhagen at the end of the camp!'
)
InfoItem.objects.create(
category=info_cat1,
headline='Driving and Parking',
anchor='driving-and-parking',
body='''
A car is very convenient when bringing lots of equipment, and we know that hackers like to bring all the things. We welcome cars and vans at BornHack. We have ample parking space very close (less than 50 meters) to the main entrance.
Please note that sleeping in the parking lot is not permitted. If you want to sleep in your car/RV/autocamper/caravan please contact us, and we will work something out.
'''
)
InfoItem.objects.create(
category=info_cat3,
headline='Camping',
anchor='camping',
body='BornHack is first and foremost a tent camp. You need to bring a tent to sleep in. Most people go with some friends and make a camp somewhere at the venue. See also the section on Villages - you might be able to find some likeminded people to camp with.'
)
InfoItem.objects.create(
category=info_cat3,
headline='Cabins',
anchor='cabins',
body='We rent out a few cabins at the venue with 8 beds each for people who don\'t want to sleep in tents for some reason. A tent is the cheapest sleeping option (you just need a ticket), but the cabins are there if you want them.'
)
self.output("Creating villages for {}...".format(year))
Village.objects.create(
contact=user1,
@ -1671,6 +1567,109 @@ Please note that sleeping in the parking lot is not permitted. If you want to sl
user=user4,
)
self.output("Creating infocategories for {}...".format(year))
info_cat1 = InfoCategory.objects.create(
team=orga_team,
headline='When is BornHack happening?',
anchor='when'
)
info_cat2 = InfoCategory.objects.create(
team=orga_team,
headline='Travel Information',
anchor='travel'
)
info_cat3 = InfoCategory.objects.create(
team=orga_team,
headline='Where do I sleep?',
anchor='sleep'
)
self.output("Creating infoitems for {}...".format(year))
InfoItem.objects.create(
category=info_cat1,
headline='Opening',
anchor='opening',
body='BornHack 2016 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 :)'
)
InfoItem.objects.create(
category=info_cat1,
headline='Closing',
anchor='closing',
body='BornHack 2016 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).'
)
InfoItem.objects.create(
category=info_cat2,
headline='Public Transportation',
anchor='public-transportation',
body='''
From/Via Copenhagen
There are several ways to get to Bornholm from Copenhagen. A domestic plane departs from Copenhagen Airport, and you can get from Copenhagen Central station by either bus or train via Ystad or the Køge-Rønne ferry connection.
Plane (very fast, most expensive)
You can check plane departures and book tickets at dat.dk. There are multiple departures daily. The flight takes approximately 25 minutes.
Via Ystad (quick, cheap and easy, crosses Sweden border)
You can drive over Øresundsbroen to Ystad or you can take the train/bus from Copenhagen Central Station. You can buy train and ferry ticket at dsb.dk (Type in "København H" and "Rønne Havn"). More information about the crossing. The crossing takes 1 hour 20 minutes. In total about 3 hours 15 minutes. Due to recent developments an ID (passport, drivers license or similar) is required when crossing the Denmark/Sweden border.
Via Køge (cheap, slow)
Take the S-train to Køge Station (you need an "all zones" ticket) or travel by car. The ferry terminal is within walking distance from the station. You can check out prices here. It takes approximately 1 hour to get to Køge. The crossing takes 5 hours 30 minutes.
From Sweden/Malmö
To get to Bornholm from Malmö you may take a train from Malmö to Ystad and the ferry from Ystad to Bornholm.
Skånetrafiken runs trains from Malmö C to Ystad every 30 minutes. Trains leave at 08 and 38 minutes past the hour. Go to skanetrafiken for details.
The ferry from Ystad to Rønne leaves four times per day. Morning: 08:30-09:50 Noon: 12:30-13:50 Afternoon: 16:30-17:50 Evening: 20:30-21:50 Booking the ferry tickets prior to departure can drastically reduce the price. See "Getting from Rønne to the Venue" final step.
From Abroad
If you are going to BornHack from abroad you have different options as well.
Berlin (Germany)
There are no public transport routes from Berlin to Mukran, Sassnitz ferry terminal on Saturdays, including Aug 27 and Sept 03 the Bornhack start/end dates. Your best bet is to get a train to Dubnitz, Sassnitz station. Unfortunately it is still 1.7km to the actual ferry terminal: map of route. There is a bus, but it only goes once a weekday at 12:28 and not at all on Weekends. You can of course take a taxi. Search for routes Berlin Dubnitz on bahn.de. At the time of writing, the best route is:
08:45 Berlin Hbf train with 2 changes, 50 for a 2-way return ticket.
12:52 Sassnitz taxi, ~14, 10 min.
13:00 Mukran-Sassnitz ferry terminal
If you want to try your luck at a direct route to the ferry terminal, search for routes Berlin Sassnitz-Mukran Fährhafen on bahn.de or for routes Berlin Fährhafen Sassnitz on checkmybus.com.
Sassnitz (Germany)
There is a direct ferry taking cars going from Sassnitz ferry terminal which is 4km away from Sassnitz itself. The company is called BornholmerFærgen and the tickets cost 32 (outgoing) and 25 (return). It can also be booked from aferry.co.uk. The ferry departs for Bornholm on Aug 27 at 11:50, 13:30, and returns to Sassnitz on Sept 03 at 08:00, 09:00. Detailed timetable: English, Danish.
Kolobrzeg (Poland)
There is a passenger ferry from Kolobrzeg to Nexø havn.
Getting from Rønne to the Venue
The venue is 24km from Rønne. We will have a shuttle bus that will pick people up and take them to the venue. It is also possible to take a public bus to near the venue. Local taxis can also get you here. The company operating on Bornholm is called Dantaxi and the local phonenumber is +4556952301.
'''
)
InfoItem.objects.create(
category=info_cat1,
headline='Bus to and from BornHack',
anchor='bus-to-and-from-bornhack',
body='PROSA, the union of IT-professionals in Denmark, has set up a great deal for BornHack attendees travelling from Copenhagen to BornHack. For only 125kr, about 17 euros, you can be transported to the camp on opening day, and back to Copenhagen at the end of the camp!'
)
InfoItem.objects.create(
category=info_cat1,
headline='Driving and Parking',
anchor='driving-and-parking',
body='''
A car is very convenient when bringing lots of equipment, and we know that hackers like to bring all the things. We welcome cars and vans at BornHack. We have ample parking space very close (less than 50 meters) to the main entrance.
Please note that sleeping in the parking lot is not permitted. If you want to sleep in your car/RV/autocamper/caravan please contact us, and we will work something out.
'''
)
InfoItem.objects.create(
category=info_cat3,
headline='Camping',
anchor='camping',
body='BornHack is first and foremost a tent camp. You need to bring a tent to sleep in. Most people go with some friends and make a camp somewhere at the venue. See also the section on Villages - you might be able to find some likeminded people to camp with.'
)
InfoItem.objects.create(
category=info_cat3,
headline='Cabins',
anchor='cabins',
body='We rent out a few cabins at the venue with 8 beds each for people who don\'t want to sleep in tents for some reason. A tent is the cheapest sleeping option (you just need a ticket), but the cabins are there if you want them.'
)
self.output("Adding event routing...")
Routing.objects.create(
team=orga_team,