Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django cms integration #1

Merged
merged 13 commits into from Dec 13, 2012
Merged

Conversation

jssevestre
Copy link
Contributor

Hello

please see attached simple code to use django-terms with django-cms:

TermsProcessor
a context processor to parse all plugins output

TermsIndexPlugin
to display all terms on a page as

BR

@BertrandBordage
Copy link
Owner

Excellent! I start reviewing it right now!

"""
if 'terms' in original_context:
return rendered_content
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else statement is useless. If 'terms' in original_context is True, you return something, which also means you leave this function. The else is therefore verified each time it is parsed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok removed!

@BertrandBordage
Copy link
Owner

That's it! Do you have anything else to change, or can I merge your pull request?
Besides, I will then create an AUTHORS file containing our names.

@jssevestre
Copy link
Contributor Author

Fine,
No more change in code right now !
May be a usage note will be usefull : just wait a moment !

for cms_plugin_processor and TermsIndexPLugin
@jssevestre
Copy link
Contributor Author

2ea5f2a fix README review

render_template = "term_plugin.html"

def render(self, context, instance, placeholder):
terms = Term.objects.all()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized something: if you select every Term, you will also display those who have no definition but a link instead. So you either need to apply a .exclude(description='') to this QuerySet or handle this (not so) special case in the template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should add link in the template, maybe a short version like

<dd>{{ term.definition|safe }} {{ term.url|urlizetrunc:15 }}</dd>

If there is a description, it will be add after. Else, it will be the only content.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Maybe a newline this time? Only if there is a url, of course. And maybe more letters shown in the urlizetrunc. Something like:

<dd>
  {{ term.definition|safe }}
  {% if term.url %}
    <br/>
    {{ term.url|urlizetrunc:40 }}
  {% endif %}
</dd>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if definition is empty and url not, the new line is still there.
Perhaps, but more complex :

{{ term.definition|safe }}
{% if term.url and term.definition %}<br/>{%endif %}
{{ term.url|urlizetrunc:40 }}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes. Sorry. Go on, I think this will be the last one before I merge all your changes.

BertrandBordage added a commit that referenced this pull request Dec 13, 2012
@BertrandBordage BertrandBordage merged commit 5f2558a into BertrandBordage:master Dec 13, 2012
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling d70125f on jssevestre:master into * on BertrandBordage:master*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants