Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
django-cms-highlighted-content
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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-cms-highlighted-content
Commits
276da397
Commit
276da397
authored
4 years ago
by
Christine Ho
Browse files
Options
Downloads
Patches
Plain Diff
fix readme + one py3 change
parent
a3be05fb
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
+15
-15
15 additions, 15 deletions
README.md
cms_highlighted_content/cms_plugins.py
+1
-1
1 addition, 1 deletion
cms_highlighted_content/cms_plugins.py
with
16 additions
and
16 deletions
README.md
+
15
−
15
View file @
276da397
...
@@ -13,7 +13,7 @@ item which is a `News` instance, then a item which is a `Page` instance, then a
...
@@ -13,7 +13,7 @@ item which is a `News` instance, then a item which is a `Page` instance, then a
### 0. Configuration
### 0. Configuration
Add
`highlighted_content`
in
`INSTALLED_APPS`
and configure models which can be used as "item":
Add
`
cms_
highlighted_content`
in
`INSTALLED_APPS`
and configure models which can be used as "item":
```
python
```
python
# settings.py
# settings.py
...
@@ -21,7 +21,7 @@ Add `highlighted_content` in `INSTALLED_APPS` and configure models which can be
...
@@ -21,7 +21,7 @@ Add `highlighted_content` in `INSTALLED_APPS` and configure models which can be
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
# ...
# ...
'
highlighted_content
'
,
'
cms_
highlighted_content
'
,
]
]
CMS_HIGHLIGHTED_CONTENT_ITEMS_MODELS
=
(
CMS_HIGHLIGHTED_CONTENT_ITEMS_MODELS
=
(
...
@@ -38,7 +38,7 @@ In your HighlightedContentItem, you **MUST** define the highlighted_content Fore
...
@@ -38,7 +38,7 @@ In your HighlightedContentItem, you **MUST** define the highlighted_content Fore
```
python
```
python
# models.py
# models.py
from
highlighted_content.models
import
HighlightedContentPluginBase
,
HighlightedContentItemBase
from
cms_
highlighted_content.models
import
HighlightedContentPluginBase
,
HighlightedContentItemBase
class
HighlightedContentPlugin
(
HighlightedContentPluginBase
):
class
HighlightedContentPlugin
(
HighlightedContentPluginBase
):
pass
pass
...
@@ -55,7 +55,7 @@ Make your migration and apply it.
...
@@ -55,7 +55,7 @@ Make your migration and apply it.
```
python
```
python
# cms_plugins.py
# cms_plugins.py
from
highlighted_content.cms_plugins
import
HighlightedContentPluginBase
from
cms_
highlighted_content.cms_plugins
import
HighlightedContentPluginBase
from
.models
import
HighlightedContentPlugin
as
HighlightedContentPluginModel
from
.models
import
HighlightedContentPlugin
as
HighlightedContentPluginModel
...
@@ -83,7 +83,7 @@ You can also create a template for earch model:
...
@@ -83,7 +83,7 @@ You can also create a template for earch model:
*
`fosm/note/highlighted_content_item.html`
*
`fosm/note/highlighted_content_item.html`
*
`fosm/conference/highlighted_content_item.html`
*
`fosm/conference/highlighted_content_item.html`
Logic is the same
tha
n django-admin: we check first if a model template exists, then we check for
Logic is the same
as i
n django-admin: we check first if a model template exists, then we check for
an app template, then we fallback for a general template.
an app template, then we fallback for a general template.
```
```
...
@@ -91,26 +91,26 @@ an app template, then we fallback for a general template.
...
@@ -91,26 +91,26 @@ an app template, then we fallback for a general template.
{% load i18n %}
{% load i18n %}
{% if item.content_type.model == 'image' %}
{% if item.content_type.model == 'image' %}
<img class="background" src="{{
item.item
.url }}" alt="" />
<img class="background" src="{{
object
.url }}" alt="" />
{% if
item.item
.default_alt_text %}
{% if
object
.default_alt_text %}
<h2>{{
item.item
.default_alt_text }}</h2>
<h2>{{
object
.default_alt_text }}</h2>
{% elif
item.item
.default_caption %}
{% elif
object
.default_caption %}
<h2>{{
item.item
.default_caption }}</h2>
<h2>{{
object
.default_caption }}</h2>
{% endif %}
{% endif %}
{% else %}
{% else %}
{% with illustration=
item.item
.highlighted_content_illustration|default:
item.item
.illustration %}
{% with illustration=
object
.highlighted_content_illustration|default:
object
.illustration %}
{% if illustration %}
{% if illustration %}
<img class="background" src="{{ illustration.url }}" alt="" />
<img class="background" src="{{ illustration.url }}" alt="" />
{% endif %}
{% endif %}
{% endwith %}
{% endwith %}
<h2><a href="{{
item.item
.get_absolute_url }}">{{
item.item
}}</a></h2>
<h2><a href="{{
object
.get_absolute_url }}">{{
object
}}</a></h2>
{% if
item.item
.summary %}
{% if
object
.summary %}
<div>
<div>
{{
item.item
.summary|truncatewords_html:20 }}
{{
object
.summary|truncatewords_html:20 }}
<p class="readmore-link">
<p class="readmore-link">
<a href="{{
item.item
.get_absolute_url }}">{% trans "Read more" %} ></a>
<a href="{{
object
.get_absolute_url }}">{% trans "Read more" %} ></a>
</p>
</p>
</div>
</div>
{% endif %}
{% endif %}
...
...
This diff is collapsed.
Click to expand it.
cms_highlighted_content/cms_plugins.py
+
1
−
1
View file @
276da397
...
@@ -31,7 +31,7 @@ class HighlightedContentPluginBase(CMSPluginBase):
...
@@ -31,7 +31,7 @@ class HighlightedContentPluginBase(CMSPluginBase):
class_name
=
smart_bytes
(
highlighted_content_item_model
.
__name__
+
'
Inline
'
)
class_name
=
smart_bytes
(
highlighted_content_item_model
.
__name__
+
'
Inline
'
)
bases
=
(
HighlightedContentItemInlineBase
,
)
bases
=
(
HighlightedContentItemInlineBase
,
)
attributes
=
{
'
model
'
:
highlighted_content_item_model
}
attributes
=
{
'
model
'
:
highlighted_content_item_model
}
inline_class
=
type
(
class_name
,
bases
,
attributes
)
inline_class
=
type
(
class_name
.
decode
(
"
utf-8
"
)
,
bases
,
attributes
)
setattr
(
self
.
__class__
,
'
highlighted_content_item_inline_class
'
,
inline_class
)
setattr
(
self
.
__class__
,
'
highlighted_content_item_inline_class
'
,
inline_class
)
if
self
.
__class__
.
highlighted_content_item_inline_class
not
in
self
.
inlines
:
if
self
.
__class__
.
highlighted_content_item_inline_class
not
in
self
.
inlines
:
self
.
inlines
.
append
(
self
.
__class__
.
highlighted_content_item_inline_class
)
self
.
inlines
.
append
(
self
.
__class__
.
highlighted_content_item_inline_class
)
...
...
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