diff --git a/README.md b/README.md index 2c1169702a277f854cc2526dcc27ba435c53a56a..43e08783a8073cf9e51e440ff91dc6e5f50bebdb 100644 --- a/README.md +++ b/README.md @@ -12,26 +12,77 @@ This django app is a toolbox to easily setup news in your projects. ## Installation +Add newsbox to your ``INSTALLED_APPS``. If you need newsbox_cms and/or +newsbox_hvad, add those too. + +## django integration + +## models.py + + + ## django CMS integration ### models.py - class News(NewsboxCMSBase, NewsboxSEOBase): +For basic news, you just have to inherit from NewsboxCMSBase : + + from newsbox_cms.models import NewsboxCMSBase + + class News(NewsboxCMSBase): + + class Meta: + newsbox_detail_url_name = "news_detail" # optional + +You can create news with i18n via HVAD. Inherit first from NewsboxHVADBase, then +from NewsboxCMSBase : + + from newsbox_cms.models import NewsboxCMSBase + from newsbox_hvad.models import NewsboxHVADBase + + class News(NewsboxHVADBase, NewsboxCMSBase): + + class Meta: + newsbox_detail_url_name = "news_detail" # optional + +If you need SEO fields and/or expiration fields, inherit from +NewsboxSEOBase and/or NewsboxExpiredBase : + + from newsbox.models import NewsboxSEOBase, NewsboxExpiredBase + from newsbox_cms.models import NewsboxCMSBase + + class News(NewsboxCMSBase, NewsboxSEOBase, NewsboxExpiredBase): class Meta: newsbox_detail_url_name = "news_detail" # optional +For the plugin, you just have to inherit from NewsboxPluginBase : + + from newsbox_cms.models import NewsboxPluginBase + + class NewsPlugin(NewsboxPluginBase): + newsbox_model = News + + ### cms_app.py +Nothing special here. Just create your basic cms app : + + from cms.app_base import CMSApp + from cms.apphook_pool import apphook_pool + class NewsApphook(CMSApp): name = _("News") urls = ["myproject.news_urls"] apphook_pool.register(NewsApphook) - - + + ### news_urls.py +This file is used by your CMS App. You have to specify the news detail URL and +set the template and the model to use for this url. + from django.conf.urls import patterns, url from newsbox.views import NewsboxDetailView from .models import News @@ -48,4 +99,15 @@ This django app is a toolbox to easily setup news in your projects. ### cms_plugin.py -TODO +You just have to inherit from NewsboxPluginBase to create a plugin to manage +your news. + + from cms.plugin_pool import plugin_pool + from newsbox_cms.cms_plugins import NewsboxPluginBase + from .models import NewsPlugin as NewsPluginModel + + + class NewsPlugin(NewsboxPluginBase): + model = NewsPluginModel + + plugin_pool.register_plugin(NewsPlugin) diff --git a/tests/myapp/tests.py b/tests/myapp/tests.py index e9ca0137a6e480e9cd0bcd97eb82fd7ad834c9be..05eca97f4a54b5d13954e951a637ad3bf89bd1f5 100644 --- a/tests/myapp/tests.py +++ b/tests/myapp/tests.py @@ -155,7 +155,7 @@ class NewsboxAbstractModelsTests(TestCase): """ c = Client() r = c.get('/news/?page=2') - news = self.get_news_in_list_by_summary(r, u'Summary of the news 4') + news = self.get_news_in_list_by_summary(r, 'Summary of the news 4') self.assertIsNotNone(news) found = self.has_readmore_link(news) @@ -167,7 +167,7 @@ class NewsboxAbstractModelsTests(TestCase): """ c = Client() r = c.get('/news/2005/') - news = self.get_news_in_list_by_summary(r, u'Summary of the news 6') + news = self.get_news_in_list_by_summary(r, 'Summary of the news 6') self.assertIsNotNone(news) found = self.has_readmore_link(news)