Skip to content
Snippets Groups Projects
Commit 63a7291f authored by Nadja Geisler's avatar Nadja Geisler :sunny: Committed by Benjamin Hättasch
Browse files

rename room's building to lacation

more general model
parent 01681abe
No related branches found
No related tags found
No related merge requests found
...@@ -141,10 +141,10 @@ class AKAdmin(SimpleHistoryAdmin): ...@@ -141,10 +141,10 @@ class AKAdmin(SimpleHistoryAdmin):
@admin.register(Room) @admin.register(Room)
class RoomAdmin(admin.ModelAdmin): class RoomAdmin(admin.ModelAdmin):
model = Room model = Room
list_display = ['name', 'building', 'capacity', 'event'] list_display = ['name', 'location', 'capacity', 'event']
list_filter = ['building', 'properties', 'event'] list_filter = ['location', 'properties', 'event']
list_editable = [] list_editable = []
ordering = ['building', 'name'] ordering = ['location', 'name']
def formfield_for_foreignkey(self, db_field, request, **kwargs): def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'event': if db_field.name == 'event':
......
...@@ -425,8 +425,8 @@ msgid "Building" ...@@ -425,8 +425,8 @@ msgid "Building"
msgstr "Gebäude" msgstr "Gebäude"
#: AKModel/models.py:262 #: AKModel/models.py:262
msgid "Name or number of the building" msgid "Name or number of the location"
msgstr "Name oder Nummer des Gebäudes" msgstr "Name oder Nummer des Ortes"
#: AKModel/models.py:263 #: AKModel/models.py:263
msgid "Capacity" msgid "Capacity"
......
# Generated by Django 3.0.6 on 2020-05-17 20:02
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('AKModel', '0032_AK_history'),
]
operations = [
migrations.RenameField(
model_name='room',
old_name='building',
new_name='location',
),
]
from datetime import timedelta
from django.utils.datetime_safe import datetime
import itertools import itertools
from datetime import timedelta
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
from django.utils.datetime_safe import datetime
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from simple_history.models import HistoricalRecords from simple_history.models import HistoricalRecords
...@@ -258,8 +257,8 @@ class Room(models.Model): ...@@ -258,8 +257,8 @@ class Room(models.Model):
""" A room describes where an AK can be held. """ A room describes where an AK can be held.
""" """
name = models.CharField(max_length=64, verbose_name=_('Name'), help_text=_('Name or number of the room')) name = models.CharField(max_length=64, verbose_name=_('Name'), help_text=_('Name or number of the room'))
building = models.CharField(max_length=256, blank=True, verbose_name=_('Building'), location = models.CharField(max_length=256, blank=True, verbose_name=_('Location'),
help_text=_('Name or number of the building')) help_text=_('Name or number of the location'))
capacity = models.IntegerField(verbose_name=_('Capacity'), help_text=_('Maximum number of people')) capacity = models.IntegerField(verbose_name=_('Capacity'), help_text=_('Maximum number of people'))
properties = models.ManyToManyField(to=AKRequirement, blank=True, verbose_name=_('Properties'), properties = models.ManyToManyField(to=AKRequirement, blank=True, verbose_name=_('Properties'),
help_text=_('AK requirements fulfilled by the room')) help_text=_('AK requirements fulfilled by the room'))
...@@ -270,13 +269,13 @@ class Room(models.Model): ...@@ -270,13 +269,13 @@ class Room(models.Model):
class Meta: class Meta:
verbose_name = _('Room') verbose_name = _('Room')
verbose_name_plural = _('Rooms') verbose_name_plural = _('Rooms')
ordering = ['building', 'name'] ordering = ['location', 'name']
unique_together = ['event', 'name', 'building'] unique_together = ['event', 'name', 'location']
@property @property
def title(self): def title(self):
if self.building: if self.location:
return f"{self.building} {self.name}" return f"{self.location} {self.name}"
return self.name return self.name
def __str__(self): def __str__(self):
......
...@@ -38,8 +38,8 @@ class PlanIndexView(FilterByEventSlugMixin, ListView): ...@@ -38,8 +38,8 @@ class PlanIndexView(FilterByEventSlugMixin, ListView):
if akslot.room is not None: if akslot.room is not None:
rooms.add(akslot.room) rooms.add(akslot.room)
# Store buildings for hierarchical view # Store buildings for hierarchical view
if akslot.room.building != '': if akslot.room.location != '':
buildings.add(akslot.room.building) buildings.add(akslot.room.location)
# Recent AKs: Started but not ended yet # Recent AKs: Started but not ended yet
if akslot.start <= current_timestamp <= akslot.end: if akslot.start <= current_timestamp <= akslot.end:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment