Fix unique slugs
This commit is contained in:
parent
56a821ae2f
commit
3a772007f1
5 changed files with 21 additions and 17 deletions
|
|
@ -13,7 +13,7 @@ class Migration(SchemaMigration):
|
||||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||||
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
|
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
|
||||||
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
||||||
('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, blank=True)),
|
('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, blank=True)),
|
||||||
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.BlogCategory'])),
|
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.BlogCategory'])),
|
||||||
))
|
))
|
||||||
db.send_create_signal(u'djangocms_blog', ['BlogCategoryTranslation'])
|
db.send_create_signal(u'djangocms_blog', ['BlogCategoryTranslation'])
|
||||||
|
|
@ -35,7 +35,7 @@ class Migration(SchemaMigration):
|
||||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||||
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
|
('language_code', self.gf('django.db.models.fields.CharField')(max_length=15, db_index=True)),
|
||||||
('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
('title', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
||||||
('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, blank=True)),
|
('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=50, blank=True)),
|
||||||
('abstract', self.gf('djangocms_text_ckeditor.fields.HTMLField')()),
|
('abstract', self.gf('djangocms_text_ckeditor.fields.HTMLField')()),
|
||||||
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.Post'])),
|
('master', self.gf('django.db.models.fields.related.ForeignKey')(related_name='translations', null=True, to=orm['djangocms_blog.Post'])),
|
||||||
))
|
))
|
||||||
|
|
@ -77,7 +77,7 @@ class Migration(SchemaMigration):
|
||||||
db.send_create_signal(u'djangocms_blog', ['LatestPostsPlugin'])
|
db.send_create_signal(u'djangocms_blog', ['LatestPostsPlugin'])
|
||||||
|
|
||||||
# Adding M2M table for field tags on 'LatestPostsPlugin'
|
# Adding M2M table for field tags on 'LatestPostsPlugin'
|
||||||
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_tags')
|
m2m_table_name = db.shorten_name(u'cmsplugin_latestpostsplugin_tags')
|
||||||
db.create_table(m2m_table_name, (
|
db.create_table(m2m_table_name, (
|
||||||
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
||||||
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
|
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
|
||||||
|
|
@ -86,7 +86,7 @@ class Migration(SchemaMigration):
|
||||||
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'tag_id'])
|
db.create_unique(m2m_table_name, ['latestpostsplugin_id', 'tag_id'])
|
||||||
|
|
||||||
# Adding M2M table for field categories on 'LatestPostsPlugin'
|
# Adding M2M table for field categories on 'LatestPostsPlugin'
|
||||||
m2m_table_name = db.shorten_name(u'djangocms_blog_latestpostsplugin_categories')
|
m2m_table_name = db.shorten_name(u'cmsplugin_latestpostsplugin_categories')
|
||||||
db.create_table(m2m_table_name, (
|
db.create_table(m2m_table_name, (
|
||||||
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
||||||
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
|
('latestpostsplugin', models.ForeignKey(orm[u'djangocms_blog.latestpostsplugin'], null=False)),
|
||||||
|
|
@ -102,7 +102,7 @@ class Migration(SchemaMigration):
|
||||||
db.send_create_signal(u'djangocms_blog', ['AuthorEntriesPlugin'])
|
db.send_create_signal(u'djangocms_blog', ['AuthorEntriesPlugin'])
|
||||||
|
|
||||||
# Adding M2M table for field authors on 'AuthorEntriesPlugin'
|
# Adding M2M table for field authors on 'AuthorEntriesPlugin'
|
||||||
m2m_table_name = db.shorten_name(u'djangocms_blog_authorentriesplugin_authors')
|
m2m_table_name = db.shorten_name(u'cmsplugin_authorentriesplugin_authors')
|
||||||
db.create_table(m2m_table_name, (
|
db.create_table(m2m_table_name, (
|
||||||
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
|
||||||
('authorentriesplugin', models.ForeignKey(orm[u'djangocms_blog.authorentriesplugin'], null=False)),
|
('authorentriesplugin', models.ForeignKey(orm[u'djangocms_blog.authorentriesplugin'], null=False)),
|
||||||
|
|
@ -137,16 +137,16 @@ class Migration(SchemaMigration):
|
||||||
db.delete_table(u'cmsplugin_latestpostsplugin')
|
db.delete_table(u'cmsplugin_latestpostsplugin')
|
||||||
|
|
||||||
# Removing M2M table for field tags on 'LatestPostsPlugin'
|
# Removing M2M table for field tags on 'LatestPostsPlugin'
|
||||||
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_tags'))
|
db.delete_table(db.shorten_name(u'cmsplugin_latestpostsplugin_tags'))
|
||||||
|
|
||||||
# Removing M2M table for field categories on 'LatestPostsPlugin'
|
# Removing M2M table for field categories on 'LatestPostsPlugin'
|
||||||
db.delete_table(db.shorten_name(u'djangocms_blog_latestpostsplugin_categories'))
|
db.delete_table(db.shorten_name(u'cmsplugin_latestpostsplugin_categories'))
|
||||||
|
|
||||||
# Deleting model 'AuthorEntriesPlugin'
|
# Deleting model 'AuthorEntriesPlugin'
|
||||||
db.delete_table(u'cmsplugin_authorentriesplugin')
|
db.delete_table(u'cmsplugin_authorentriesplugin')
|
||||||
|
|
||||||
# Removing M2M table for field authors on 'AuthorEntriesPlugin'
|
# Removing M2M table for field authors on 'AuthorEntriesPlugin'
|
||||||
db.delete_table(db.shorten_name(u'djangocms_blog_authorentriesplugin_authors'))
|
db.delete_table(db.shorten_name(u'cmsplugin_authorentriesplugin_authors'))
|
||||||
|
|
||||||
|
|
||||||
models = {
|
models = {
|
||||||
|
|
@ -235,7 +235,7 @@ class Migration(SchemaMigration):
|
||||||
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
|
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
|
||||||
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.BlogCategory']"}),
|
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.BlogCategory']"}),
|
||||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'})
|
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'blank': 'True'})
|
||||||
},
|
},
|
||||||
u'djangocms_blog.latestpostsplugin': {
|
u'djangocms_blog.latestpostsplugin': {
|
||||||
'Meta': {'object_name': 'LatestPostsPlugin', 'db_table': "u'cmsplugin_latestpostsplugin'", '_ormbases': ['cms.CMSPlugin']},
|
'Meta': {'object_name': 'LatestPostsPlugin', 'db_table': "u'cmsplugin_latestpostsplugin'", '_ormbases': ['cms.CMSPlugin']},
|
||||||
|
|
@ -265,7 +265,7 @@ class Migration(SchemaMigration):
|
||||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
|
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
|
||||||
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.Post']"}),
|
'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'null': 'True', 'to': u"orm['djangocms_blog.Post']"}),
|
||||||
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}),
|
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'blank': 'True'}),
|
||||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
|
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
|
||||||
},
|
},
|
||||||
'filer.file': {
|
'filer.file': {
|
||||||
|
|
@ -310,6 +310,7 @@ class Migration(SchemaMigration):
|
||||||
u'file_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['filer.File']", 'unique': 'True', 'primary_key': 'True'}),
|
u'file_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['filer.File']", 'unique': 'True', 'primary_key': 'True'}),
|
||||||
'must_always_publish_author_credit': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
'must_always_publish_author_credit': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
'must_always_publish_copyright': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
'must_always_publish_copyright': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'related_url': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
'subject_location': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '64', 'null': 'True', 'blank': 'True'})
|
'subject_location': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '64', 'null': 'True', 'blank': 'True'})
|
||||||
},
|
},
|
||||||
u'taggit.tag': {
|
u'taggit.tag': {
|
||||||
|
|
@ -320,4 +321,4 @@ class Migration(SchemaMigration):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
complete_apps = ['djangocms_blog']
|
complete_apps = ['djangocms_blog']
|
||||||
|
|
@ -28,7 +28,7 @@ class BlogCategory(TranslatableModel):
|
||||||
|
|
||||||
translations = TranslatedFields(
|
translations = TranslatedFields(
|
||||||
name=models.CharField(_('name'), max_length=255),
|
name=models.CharField(_('name'), max_length=255),
|
||||||
slug=models.SlugField(_('slug'), blank=True),
|
slug=models.SlugField(_('slug'), blank=True, unique=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
@ -76,7 +76,7 @@ class Post(TranslatableModel):
|
||||||
|
|
||||||
translations = TranslatedFields(
|
translations = TranslatedFields(
|
||||||
title=models.CharField(max_length=255),
|
title=models.CharField(max_length=255),
|
||||||
slug=models.SlugField(_('slug'), blank=True),
|
slug=models.SlugField(_('slug'), blank=True, unique=True),
|
||||||
abstract=HTMLField(),
|
abstract=HTMLField(),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<ul class="blog-authors">
|
<ul class="blog-authors">
|
||||||
{% for author in instance.get_authors %}
|
{% for author in instance.get_authors %}
|
||||||
|
|
||||||
<li><a href="{% url 'djangocms_blog:author-posts' author.username %}">{{ author.get_full_name }} <span>{% if author.count %}{{ author.count }}{% else %}0{% endif %} articles</span></a></li>
|
<li><a href="{% url 'djangocms_blog:author-posts' author.username %}">{{ author.get_full_name }} <span>{% if author.count %}({{ author.count }}{% else %}0{% endif %} articles</span></a></li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<li class="blog-empty"><p>{% trans "No entry found." %}</p></li>
|
<li class="blog-empty"><p>{% trans "No entry found." %}</p></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@
|
||||||
<header>
|
<header>
|
||||||
<h3>
|
<h3>
|
||||||
{% if author %}{% trans "Entries by" %} {{ author.get_full_name }}
|
{% if author %}{% trans "Entries by" %} {{ author.get_full_name }}
|
||||||
{% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }}{% elif tagged_entries %}
|
{% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }}
|
||||||
{% trans "Tag" %} – {{ tagged_entries|capfirst }}{% endif %}
|
{% elif tagged_entries %}{% trans "Tag" %} – {{ tagged_entries|capfirst }}
|
||||||
|
{% elif category %}{% trans "Category" %} – {{ category }}{% endif %}
|
||||||
</h3>
|
</h3>
|
||||||
</header>
|
</header>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,9 @@ class CategoryEntriesView(BaseBlogView, ListView):
|
||||||
def category(self):
|
def category(self):
|
||||||
if not self._category:
|
if not self._category:
|
||||||
language = get_language_from_request(self.request)
|
language = get_language_from_request(self.request)
|
||||||
self._category = BlogCategory._default_manager.language(language).get(translations__slug=self.kwargs['category'])
|
self._category = BlogCategory._default_manager.language(language).get(
|
||||||
|
translations__language_code=language,
|
||||||
|
translations__slug=self.kwargs['category'])
|
||||||
return self._category
|
return self._category
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue