-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor news and make admin more pretty
- Loading branch information
1 parent
e3acfd5
commit d944295
Showing
5 changed files
with
129 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
# coding: utf-8 | ||
|
||
from django.contrib import admin | ||
from django import forms | ||
# Register your models here. | ||
from ckeditor.widgets import CKEditorWidget | ||
from .models import News | ||
|
||
from . import models | ||
|
||
|
||
class NewsAdminForm(forms.ModelForm): | ||
class Meta: | ||
model = News | ||
model = models.NewsEntry | ||
fields = '__all__' | ||
|
||
text = forms.CharField(widget=CKEditorWidget()) | ||
|
||
|
||
@admin.register(models.NewsEntry) | ||
class NewsAdmin(admin.ModelAdmin): | ||
form = NewsAdminForm | ||
readonly_fields = ('slug',) | ||
|
||
admin.site.register(News, NewsAdmin) | ||
list_display = ( | ||
'title', | ||
'subtitle', | ||
'slug', | ||
'creation_date', | ||
'facility', | ||
'organization' | ||
) | ||
list_filter = ( | ||
'facility', | ||
'organization' | ||
) | ||
readonly_fields = ('slug',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organizations', '0007_auto_20151023_2129'), | ||
('news', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name='News', | ||
new_name='NewsEntry' | ||
), | ||
migrations.AlterModelOptions( | ||
name='newsentry', | ||
options={'ordering': ('facility', 'organization', 'creation_date'), | ||
'verbose_name': 'news entry', | ||
'verbose_name_plural': 'news entries'}, | ||
), | ||
migrations.AlterField( | ||
model_name='newsentry', | ||
name='facility', | ||
field=models.ForeignKey(related_name='news_entries', blank=True, | ||
to='organizations.Facility', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='newsentry', | ||
name='organization', | ||
field=models.ForeignKey(related_name='news_entries', blank=True, | ||
to='organizations.Organization', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='newsentry', | ||
name='text', | ||
field=models.TextField(verbose_name='articletext'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organizations', '0006_auto_20151022_1445'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='facility', | ||
name='contact_info', | ||
field=models.TextField(verbose_name='contact info'), | ||
), | ||
migrations.AlterField( | ||
model_name='organization', | ||
name='contact_info', | ||
field=models.TextField(verbose_name='contact info'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters