Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-newsbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WebU
shared
django-newsbox
Commits
0930c06e
Commit
0930c06e
authored
10 years ago
by
Dylann Cordel
Browse files
Options
Downloads
Patches
Plain Diff
Correction for python >= 3.0 with "u''" deletion
parent
db53239b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+66
-4
66 additions, 4 deletions
README.md
tests/myapp/tests.py
+2
-2
2 additions, 2 deletions
tests/myapp/tests.py
with
68 additions
and
6 deletions
README.md
+
66
−
4
View file @
0930c06e
...
...
@@ -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)
This diff is collapsed.
Click to expand it.
tests/myapp/tests.py
+
2
−
2
View file @
0930c06e
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment