From 0a008fe707c9092460ed7c1d6f820f9301f853ca Mon Sep 17 00:00:00 2001 From: Oleksandr Yatsenko Date: Sun, 8 Apr 2018 09:26:22 +0300 Subject: [PATCH] add desc field to Calendar data model add calendar field to events filter in admin --- schedule/admin.py | 8 ++++---- schedule/migrations/0012_calendar_desc.py | 20 ++++++++++++++++++++ schedule/models/calendars.py | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 schedule/migrations/0012_calendar_desc.py diff --git a/schedule/admin.py b/schedule/admin.py index 392d5d76..2e37a4b2 100644 --- a/schedule/admin.py +++ b/schedule/admin.py @@ -6,13 +6,13 @@ @admin.register(Calendar) class CalendarAdmin(admin.ModelAdmin): - list_display = ('name', 'slug') + list_display = ('name', 'slug', 'desc') prepopulated_fields = {'slug': ('name',)} search_fields = ['name'] fieldsets = ( (None, { 'fields': [ - ('name', 'slug'), + ('name', 'slug', 'desc'), ] }), ) @@ -35,8 +35,8 @@ class CalendarRelationAdmin(admin.ModelAdmin): @admin.register(Event) class EventAdmin(admin.ModelAdmin): - list_display = ('title', 'start', 'end') - list_filter = ('start',) + list_display = ('title', 'calendar', 'start', 'end') + list_filter = ('calendar', 'start') ordering = ('-start',) date_hierarchy = 'start' search_fields = ('title', 'description') diff --git a/schedule/migrations/0012_calendar_desc.py b/schedule/migrations/0012_calendar_desc.py new file mode 100644 index 00000000..5bb34d64 --- /dev/null +++ b/schedule/migrations/0012_calendar_desc.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-03-21 12:50 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('schedule', '0011_event_calendar_not_null'), + ] + + operations = [ + migrations.AddField( + model_name='calendar', + name='desc', + field=models.CharField(default='', max_length=200, verbose_name='desc'), + ), + ] diff --git a/schedule/models/calendars.py b/schedule/models/calendars.py index 13ace559..29a1ab04 100644 --- a/schedule/models/calendars.py +++ b/schedule/models/calendars.py @@ -141,6 +141,7 @@ class Calendar(models.Model): name = models.CharField(_("name"), max_length=200) slug = models.SlugField(_("slug"), max_length=200, unique=True) + desc = models.CharField(_("desc"), max_length=200, default="") objects = CalendarManager() class Meta(object):