Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit a83cac40d3b4c84ca618cc8970c77c9ee921e241 @mbrochh mbrochh committed Jan 22, 2013
@@ -0,0 +1,8 @@
+*.egg-info/
+*.pyc
+.ropeproject
+.tox
+chromedriver.log
+coverage/
+db.sqlite
+dist/
@@ -0,0 +1,6 @@
+language: python
+python:
+ - "2.6"
+ - "2.7"
+install: pip install -r requirements.txt --use-mirrors
+script: python online_docs/tests/runtests.py
@@ -0,0 +1,7 @@
+Current or previous core committers
+
+Martin Brochhaus
+
+Contributors (in alphabetical order)
+
+* Your name could stand here :)
@@ -0,0 +1,3 @@
+=== 0.1 ===
+
+Initial commit
@@ -0,0 +1 @@
+Extension for cmsplugin-blog which adds categories to the blog.
20 LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+Copyright (c) 2012 Martin Brochhaus
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
@@ -0,0 +1,9 @@
+include AUTHORS
+include LICENSE
+include DESCRIPTION
+include CHANGELOG.txt
+include README.md
+graft cmsplugin_blog_categories
+global-exclude *.orig *.pyc *.log
+prune cmsplugin_blog_categories/tests/coverage/
+prune cmsplugin_blog_categories/.ropeproject/
@@ -0,0 +1,71 @@
+cmsplugin-blog Categories
+=========================
+
+An extension for `cmsplugin-blog <https://github.com/fivethreeo/cmsplugin-blog/>`_
+which adds categories to the blog. Out of the box cmsplugin-blog only supports
+tags.
+
+
+Installation
+------------
+
+You need to install the following prerequisites in order to use this app::
+
+ pip install Django
+ pip install django-cms
+ pip install cmsplugin-blog
+ pip install simple-translation
+
+If you want to install the latest stable release from PyPi::
+
+ $ pip install cmsplugin-blog-categories
+
+If you feel adventurous and want to install the latest commit from GitHub::
+
+ $ pip install -e git://github.com/bitmazk/cmsplugin-blog-categories.git#egg=cmsplugin_blog_categories
+
+Add ``cmsplugin_blog_categories`` to your ``INSTALLED_APPS``::
+
+ INSTALLED_APPS = (
+ ...,
+ 'cmsplugin_blog_categories',
+ )
+
+In your django-cms instance change the `Blog Apphook` to the `Blog Categories
+Apphook`.
+
+
+Usage
+-----
+
+TODO: Describe usage
+
+
+Contribute
+----------
+
+If you want to contribute to this project, please perform the following steps::
+
+ # Fork this repository
+ # Clone your fork
+ $ mkvirtualenv -p python2.7 cmsplugin-blog-categories
+ $ pip install -r requirements.txt
+ $ ./logger/tests/runtests.sh
+ # You should get no failing tests
+
+ $ git co -b feature_branch master
+ # Implement your feature and tests
+ # Describe your change in the CHANGELOG.txt
+ $ git add . && git commit
+ $ git push origin feature_branch
+ # Send us a pull request for your feature branch
+
+Whenever you run the tests a coverage output will be generated in
+``tests/coverage/index.html``. When adding new features, please make sure that
+you keep the coverage at 100%.
+
+
+Roadmap
+-------
+
+Check the issue tracker on github for milestones and features to come.
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+__version__ = '0.1'
@@ -0,0 +1,51 @@
+"""Admin classes for the ``cmsplugin_blog_categories`` app."""
+from django.contrib import admin
+from django.utils.translation import get_language
+from django.utils.translation import ugettext_lazy as _
+
+from cmsplugin_blog.admin import EntryAdmin
+from cmsplugin_blog.models import Entry
+from simple_translation.admin import TranslationAdmin
+from simple_translation.utils import get_translation_queryset
+
+from cmsplugin_blog_categories.models import Category, EntryCategory
+
+
+class EntryCategoryInline(admin.TabularInline):
+ model = EntryCategory
+ max_num = 1
+
+
+class CustomEntryAdmin(EntryAdmin):
+ inlines = [EntryCategoryInline, ]
+
+
+class EntryCategoryAdmin(admin.ModelAdmin):
+ list_display = ['entry_title', 'category_title', ]
+
+ def category_title(self, obj):
+ lang = get_language()
+ return get_translation_queryset(obj.category).filter(
+ language=lang)[0].title
+ category_title.short_description = _('Category')
+
+ def entry_title(self, obj):
+ lang = get_language()
+ return get_translation_queryset(obj.entry).filter(
+ language=lang)[0].title
+ entry_title.short_description = _('Entry title')
+
+
+class CategoryAdmin(TranslationAdmin):
+ list_display = ['title', 'languages', ]
+
+ def title(self, obj):
+ lang = get_language()
+ return get_translation_queryset(obj).filter(language=lang)[0].title
+ title.short_description = _('Title')
+
+
+admin.site.register(Category, CategoryAdmin)
+admin.site.register(EntryCategory, EntryCategoryAdmin)
+admin.site.unregister(Entry)
+admin.site.register(Entry, CustomEntryAdmin)
@@ -0,0 +1,13 @@
+"""CMS apphook for the ``cmsplugin_blog_categories`` app."""
+from django.utils.translation import ugettext_lazy as _
+
+from cms.app_base import CMSApp
+from cms.apphook_pool import apphook_pool
+
+
+class BlogCategoriesApphook(CMSApp):
+ name = _("Blog Categories Apphook")
+ urls = ["cmsplugin_blog_categories.urls"]
+
+
+apphook_pool.register(BlogCategoriesApphook)
@@ -0,0 +1,32 @@
+"""Models for the ``cmsplugin_blog_categories`` app."""
+from django.db import models
+from django.utils.translation import get_language
+from django.utils.translation import ugettext_lazy as _
+
+from simple_translation.utils import get_translation_queryset
+
+
+class Category(models.Model):
+ """A blog ``Entry`` can belong to one category."""
+ creation_date = models.DateTimeField(auto_now_add=True)
+
+ def __unicode__(self):
+ lang = get_language()
+ return get_translation_queryset(self).filter(language=lang)[0].title
+
+
+class CategoryTitle(models.Model):
+ title = models.CharField(
+ max_length=256,
+ verbose_name=_('Title'),
+ )
+
+ # Needed by simple-translation
+ category = models.ForeignKey(Category)
+ language = models.CharField(max_length=5)
+
+
+class EntryCategory(models.Model):
+ """Model that extends the ``Entry`` model of cmsplugin-blog."""
+ entry = models.ForeignKey('cmsplugin_blog.Entry')
+ category = models.ForeignKey(Category)
@@ -0,0 +1,7 @@
+"""Registering translated models for the ``cmsplugin_blog_categories`` app."""
+from simple_translation.translation_pool import translation_pool
+
+from cmsplugin_blog_categories.models import Category, CategoryTitle
+
+
+translation_pool.register_translation(Category, CategoryTitle)
No changes.
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+"""
+This script is a trick to setup a fake Django environment, since this reusable
+app will be developed and tested outside any specifiv Django project.
+
+Via ``settings.configure`` you will be able to set all necessary settings
+for your app and run the tests as if you were calling ``./manage.py test``.
+
+"""
+import sys
+
+from django.conf import settings
+import test_settings
+
+
+if not settings.configured:
+ settings.configure(**test_settings.__dict__)
+
+
+from django_coverage.coverage_runner import CoverageRunner
+from django_nose import NoseTestSuiteRunner
+
+
+class NoseCoverageTestRunner(CoverageRunner, NoseTestSuiteRunner):
+ """Custom test runner that uses nose and coverage"""
+ pass
+
+
+def runtests(*test_args):
+ failures = NoseCoverageTestRunner(verbosity=2, interactive=True).run_tests(test_args)
+ sys.exit(failures)
+
+
+if __name__ == '__main__':
+ runtests(*sys.argv[1:])
@@ -0,0 +1,22 @@
+"""
+These settings are used by the ``manage.py`` command.
+
+With normal tests we want to use the fastest possible way which is an
+in-memory sqlite database but if you want to create South migrations you
+need a persistant database.
+
+Unfortunately there seems to be an issue with either South or syncdb so that
+defining two routers ("default" and "south") does not work.
+
+"""
+from cmsplugin_blog_categories.tests.test_settings import *
+
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'db.sqlite',
+ }
+}
+
+INSTALLED_APPS.append('south', )
@@ -0,0 +1,4 @@
+{% load sekizai_tags %}
+{% render_block "css" %}
+{% block main %}{% endblock %}
+{% render_block "js" %}
@@ -0,0 +1,5 @@
+{% extends "cms/base.html" %}
+
+{% block main %}
+Home
+{% endblock %}
Oops, something went wrong.

0 comments on commit a83cac4

Please sign in to comment.