# # Copyright (c) 2015 NIBIO <http://www.nibio.no/>. # # This file is part of VIPSWeb. # VIPSWeb is free software: you can redistribute it and/or modify # it under the terms of the NIBIO Open Source License as published by # NIBIO, either version 1 of the License, or (at your option) any # later version. # # VIPSWeb is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # NIBIO Open Source License for more details. # # You should have received a copy of the NIBIO Open Source License # along with VIPSWeb. If not, see <http://www.nibio.no/licenses/>. # from django.contrib import admin from django.forms import Textarea from information.models import Information, InformationLocale, InformationIllustration, InformationAttachment from django.db import models from tinymce.widgets import TinyMCE from tinymce import models as tinymce_models # Register your models here. class InformationLocaleInline(admin.StackedInline): extra = 1 model = InformationLocale formfield_overrides = { #models.TextField: {'widget': Textarea(attrs={'rows':4, 'cols':40})}, tinymce_models.HTMLField: {'widget':TinyMCE(attrs={'cols': 120, 'rows': 30})} } fields = ['language_code', 'headline', 'lead_paragraph', 'body'] """ # This actually works, but CSS overrides the size attribute... def formfield_for_dbfield(self, db_field, **kwargs): field = super(InformationLocaleInline, self).formfield_for_dbfield(db_field, **kwargs) # Get the default field if db_field.name == "language_code": # Check if it's the one you want field.widget.attrs['size'] = "2" # Poke in the new return field """ class InformationIllustrationInline(admin.TabularInline): extra = 1 model = InformationIllustration class InformationAttachmentInline(admin.TabularInline): extra = 1 model = InformationAttachment class InformationAdmin(admin.ModelAdmin): inlines = [ InformationLocaleInline, InformationIllustrationInline, InformationAttachmentInline, ] admin.site.register(Information, InformationAdmin)