Remove camp from infocategory and derive it from team.
This commit is contained in:
parent
d3273eb1bb
commit
317a1c0b1c
|
@ -8,19 +8,19 @@ from .models import (
|
|||
|
||||
@admin.register(InfoItem)
|
||||
class InfoItemAdmin(VersionAdmin):
|
||||
list_filter = ['category', 'category__camp',]
|
||||
list_filter = ['category', 'category__team__camp',]
|
||||
list_display = ['headline',]
|
||||
|
||||
|
||||
class InfoItemInlineAdmin(admin.StackedInline):
|
||||
model = InfoItem
|
||||
list_filter = ['category', 'category__camp',]
|
||||
list_filter = ['category', 'category__team__camp',]
|
||||
list_display = ['headline',]
|
||||
|
||||
|
||||
@admin.register(InfoCategory)
|
||||
class InfoCategorydmin(admin.ModelAdmin):
|
||||
list_filter = ['camp',]
|
||||
list_filter = ['team__camp',]
|
||||
list_display = ['headline',]
|
||||
search_fields = ['headline', 'body']
|
||||
inlines = [InfoItemInlineAdmin]
|
||||
|
|
27
src/info/migrations/0006_auto_20180520_1113.py
Normal file
27
src/info/migrations/0006_auto_20180520_1113.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.0.4 on 2018-05-20 16:13
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('info', '0005_add_teams_to_categories'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='infocategory',
|
||||
name='team',
|
||||
field=models.ForeignKey(blank=True, help_text='The team responsible for this info category.', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='info_categories', to='teams.Team'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='infocategory',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='infocategory',
|
||||
name='camp',
|
||||
),
|
||||
]
|
|
@ -8,15 +8,8 @@ import reversion
|
|||
class InfoCategory(CampRelatedModel):
|
||||
class Meta:
|
||||
ordering = ['weight', 'headline']
|
||||
unique_together = (('anchor', 'camp'), ('headline', 'camp'))
|
||||
verbose_name_plural = "Info Categories"
|
||||
|
||||
camp = models.ForeignKey(
|
||||
'camps.Camp',
|
||||
related_name='infocategories',
|
||||
on_delete=models.PROTECT
|
||||
)
|
||||
|
||||
headline = models.CharField(
|
||||
max_length=100,
|
||||
help_text="The headline of this info category"
|
||||
|
@ -52,6 +45,10 @@ class InfoCategory(CampRelatedModel):
|
|||
{'team': 'Team is a team from another camp.'}
|
||||
)
|
||||
|
||||
@property
|
||||
def camp(self):
|
||||
return self.team.camp
|
||||
|
||||
def __str__(self):
|
||||
return '%s (%s)' % (self.headline, self.camp)
|
||||
|
||||
|
|
Loading…
Reference in a new issue