示例#1
0
 def __init__(self, *args, **kwargs):
     super(TaskForm, self).__init__(*args, **kwargs)
     self.fields['title'].widget = widgets.AdminTextareaWidget(attrs={'cols': 80, 'rows': 1})
     self.fields['description'].widget = widgets.AdminTextareaWidget(attrs={'cols': 90, 'rows': 10})
     self.fields['comments'].widget = widgets.AdminTextareaWidget(attrs={'cols': 90, 'rows': 10})
     self.fields['start'].widget =    SelectDateWidget()
     self.fields['start'].widget.attrs['disabled'] = True
     self.fields['finish'].widget = SelectDateWidget()
class EntryAdmin(SeoEntryAdminMixin, _entry_admin_base):
    """
    The Django admin class for the default blog :class:`~fluent_blogs.models.Entry` model.
    When using a custom model, you can use :class:`AbstractEntryBaseAdmin`, which isn't attached to any of the optional fields.
    """
    # Redefine the fieldset, because it will be extended with auto-detected fields.
    FIELDSET_GENERAL = (
        None,
        {
            'fields': (
                'title',
                'slug',
                'status',
            ),  # is filled with ('intro', 'contents', 'categories', 'tags', 'enable_comments') below
        })

    # For Django 1.4, the fieldsets shouldn't be declared with 'fieldsets ='
    # as the admin validation won't recognize the translated fields.
    # The 1.4 validation didn't check the form at all, but only checks the model fields.
    # As of Django 1.5, using 'fieldsets = ..' with translated fields just works.
    declared_fieldsets = (
        FIELDSET_GENERAL,
        AbstractEntryBaseAdmin.FIELDSET_PUBLICATION,
        SeoEntryAdminMixin.FIELDSET_SEO,
    )

    list_filter = list(_entry_admin_base.list_filter)
    formfield_overrides = {}
    formfield_overrides.update(SeoEntryAdminMixin.formfield_overrides)
    formfield_overrides.update({
        'intro': {
            'widget': widgets.AdminTextareaWidget(attrs={'rows': 4})
        },
    })
示例#3
0
 def __init__(self, *args, **kwargs):
     super(ThreadAdminForm, self).__init__(*args, **kwargs)
     self.fields['title'].widget = widgets.AdminTextInputWidget(
         {_('class'): _('form-control')})
     self.fields['content'].widget = widgets.AdminTextareaWidget(
         {_('class'): _('form-control')})
     self.fields['views'].widget = widgets.AdminTextInputWidget(
         {_('class'): _('form-control')})
示例#4
0
 def formfield_for_dbfield(self, db_field, *args, **kwargs):
     if db_field.name == 'content':
         kwargs['widget'] = widgets.AdminTextareaWidget({
             'id':
             'admin-form-control',
             'class':
             'form-control'
         })
     return super(PostsInLine,
                  self).formfield_for_dbfield(db_field, *args, **kwargs)
示例#5
0
class EntryAdmin(SeoEntryAdminMixin, _entry_admin_base):
    """
    The Django admin class for the blog model.
    When another blog model is used, the ``fieldsets`` include it's additional fields.
    You can also use :class:`AbstractEntryBaseAdmin` with an optional ``SeoEntryAdminMixin``,
    to control the admin field layout completley.
    """
    # Redefine the fieldset, because it will be extended with auto-detected fields.
    FIELDSET_GENERAL = (
        None,
        {
            'fields': (
                'title',
                'slug',
                'status',
            ),  # is filled with ('contents', 'categories', 'tags', 'enable_comments') below
        })

    if 'meta_keywords' in _model_fields:
        fieldsets = [
            FIELDSET_GENERAL,
            SeoEntryAdminMixin.FIELDSET_SEO,
            AbstractEntryBaseAdmin.FIELDSET_PUBLICATION,
        ]
    else:
        fieldsets = [
            FIELDSET_GENERAL,
            AbstractEntryBaseAdmin.FIELDSET_PUBLICATION,
        ]

    list_filter = ['status']  # reset, is rebuilt below.
    html_fields = []  # auto filled with excerpt_text
    formfield_overrides = {}
    formfield_overrides.update(SeoEntryAdminMixin.formfield_overrides)
    formfield_overrides.update({
        'intro': {
            'widget': widgets.AdminTextareaWidget(attrs={'rows': 4})
        },
    })

    def add_view(self, request, form_url='', extra_context=None):
        extra_context = extra_context or {}
        extra_context['html_fields'] = self.html_fields
        return super(EntryAdmin, self).add_view(request,
                                                form_url=form_url,
                                                extra_context=extra_context)

    def change_view(self, request, object_id, form_url='', extra_context=None):
        extra_context = extra_context or {}
        extra_context['html_fields'] = self.html_fields
        return super(EntryAdmin, self).change_view(request,
                                                   object_id,
                                                   form_url=form_url,
                                                   extra_context=extra_context)
示例#6
0
    class Meta:
        model = ContactUs
        fields = '__all__'

        widgets = {
            'email': widgets.AdminEmailInputWidget(attrs={
                'placeholder': '*****@*****.**'
            }),
            'message': widgets.AdminTextareaWidget(attrs={
                'placeholder': "Write your notes or questions here..."
            }),
        }
示例#7
0
 def __init__(self, *args, **kwargs):
     super(QuizChoiceInLineForm, self).__init__(*args, **kwargs)
     self.fields['choice'].widget = widgets.AdminTextareaWidget({
         _('class'):
         _('form-control'),
         _('placeholder'):
         _('One of the quiz choices')
     })
     self.fields['Quiz'].widget = widgets.AdminURLFieldWidget({
         _('class'):
         _('form-control'),
         _('placeholder'):
         _('Lecture Slide URL')
     })
     self.fields['correct'].widget = widgets.AdminURLFieldWidget({
         _('class'):
         _('form-control'),
         _('placeholder'):
         _('A generic Document will be provided if left empty')
     })
示例#8
0
class AccountEntryNoteInline(admin.TabularInline):
    model = AccountEntryNote
    fk_name = "account_entry"
    verbose_name = _("account entry note")
    verbose_name_plural = _("account entry notes")
    extra = 1
    can_delete = True
    fields = [
        "created",
        "note",
        "created_by",
    ]
    readonly_fields = [
        "created",
        "created_by",
    ]
    formfield_overrides = {
        models.TextField: {
            "widget": widgets.AdminTextareaWidget(attrs={"rows": 3})
        },
    }
示例#9
0
 class Meta:
     widgets = {
         'publication_date': widgets.AdminDateWidget(),
         'description': widgets.AdminTextareaWidget()
     }
示例#10
0
 def __init__(self, *args, **kwargs):
     super(CodeSnippetAdminForm, self).__init__(*args, **kwargs)
     self.fields['code'].widget = widgets.AdminTextareaWidget(
         {_('class'): _('form-control')})
示例#11
0
 def __init__(self, *args, **kwargs):
     super(QuizAdminForm, self).__init__(*args, **kwargs)
     self.fields['question'].widget = widgets.AdminTextareaWidget(
         {_('class'): _('form-control')})