CSS fixes and tags autocomplete

This commit is contained in:
Iacopo Spalletti 2014-01-08 07:25:18 +01:00
parent c11141e74b
commit 63d7496f98
5 changed files with 71 additions and 24 deletions

View file

@ -6,6 +6,7 @@ from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from .models import AuthorEntriesPlugin, LatestPostsPlugin, Post
from .forms import LatestEntriesForm
class BlogPlugin(CMSPluginBase):
@ -18,6 +19,8 @@ class LatestEntriesPlugin(BlogPlugin):
render_template = 'djangocms_blog/plugins/latest_entries.html'
name = _('Latest Blog Entries')
model = LatestPostsPlugin
form = LatestEntriesForm
filter_horizontal = ('categories',)
def render(self, context, instance, placeholder):
context['instance'] = instance

19
djangocms_blog/forms.py Normal file
View file

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from django import forms
from django.conf import settings
import django_select2
class LatestEntriesForm(forms.ModelForm):
class Meta:
widgets = {
'tags': django_select2.Select2MultipleWidget
}
class Media:
css = {
'all': ('%s/css/%s' % (settings.STATIC_URL, "djangocms_blog_admin.css"),)
}

View file

@ -119,6 +119,7 @@ class LatestPostsPlugin(CMSPlugin):
latest_posts = models.IntegerField(default=5, help_text=_('The number of latests posts to be displayed.'))
tags = models.ManyToManyField('taggit.Tag', blank=True, help_text=_('Show only the blog posts tagged with chosen tags.'))
categories = models.ManyToManyField('BlogCategory', blank=True, help_text=_('Show only the blog posts tagged with chosen tags.'))
def __unicode__(self):
return u"%s latest post by tag" % self.latest_posts

View file

@ -0,0 +1,46 @@
.select2-container-multi .select2-choices .select2-search-field input {
min-width: 100px;
}
.selector select[multiple] {
display: block;
}
.selector {
width: auto;
margin-right: 12px;
}
.selector-available, .selector-chosen {
width: auto;
}
.selector .selector-available input, .selector .selector-chosen input {
margin: 0;
}
form select {
max-width: 266px;
}
.as-selections.vTextField {
width: 300px;
}
.as-results ul.as-list {
margin-left:9em;
padding-left:0;
box-shadow: none !important;
border: 1px solid #888888 !important;
}
.as-results ul.as-list li {
list-style: none;
}
ul.as-selections.vTextField {
padding-left: 10px;
margin-left:9em;
}
ul.as-selections li {
list-style: none;
}

View file

@ -1,29 +1,7 @@
{% extends "admin/hvad/change_form.html" %}
{% load i18n admin_modify %}
{% load static %}
{% block extrahead %}
{{ block.super }}
<style type="text/css">
.as-selections.vTextField {
width: 300px;
}
.as-results ul.as-list {
margin-left:9em;
padding-left:0;
box-shadow: none !important;
border: 1px solid #888888 !important;
}
.as-results ul.as-list li {
list-style: none;
}
ul.as-selections.vTextField {
padding-left: 10px;
margin-left:9em;
}
ul.as-selections li {
list-style: none;
}
</style>
<link href="{% static 'css/djangocms_blog_admin.css' %}" media="screen, projection" rel="stylesheet" type="text/css">
{% endblock %}