Skip to content

Commit

Permalink
add desc field to Calendar data model
Browse files Browse the repository at this point in the history
add calendar field to events filter in admin
  • Loading branch information
itmagistr committed Apr 8, 2018
1 parent 9340f93 commit 0a008fe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions schedule/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]
}),
)
Expand All @@ -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')
Expand Down
20 changes: 20 additions & 0 deletions schedule/migrations/0012_calendar_desc.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
1 change: 1 addition & 0 deletions schedule/models/calendars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0a008fe

Please sign in to comment.