Skip to content
Snippets Groups Projects
Commit 276da397 authored by Christine Ho's avatar Christine Ho
Browse files

fix readme + one py3 change

parent a3be05fb
No related branches found
No related tags found
No related merge requests found
...@@ -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 than django-admin: we check first if a model template exists, then we check for Logic is the same as in 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" %}&nbsp;&gt;</a> <a href="{{ object.get_absolute_url }}">{% trans "Read more" %}&nbsp;&gt;</a>
</p> </p>
</div> </div>
{% endif %} {% endif %}
......
...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment