Skip to content

Commit

Permalink
added per item help display_text, might need to move to not be associ…
Browse files Browse the repository at this point in the history
…ated with a specific item but an item type
  • Loading branch information
mikhuang committed Jul 9, 2013
1 parent 543cf04 commit 23e2f89
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
20 changes: 20 additions & 0 deletions deme_django/cms/models.py
Expand Up @@ -250,6 +250,8 @@ class Meta:
email_list_address = models.CharField(_('email list address'), max_length=63, null=True, blank=True, unique=True, default=None, validators=[RegexValidator(email_local_address_re1, 'Field must be a valid local part of an email address (before the at-sign)'), RegexValidator(email_local_address_re2, 'Cannot be of the form "item-#" or "comment-#"')], help_text=_('(Advanced) The local part (before the at-sign) of the to email address of emails sent to subscribers of this item'))
email_sets_reply_to_all_subscribers = FixedBooleanField(_('email sets reply to all subscribers'), default=True, help_text=_('(Advanced) For the reply-to field of emails sent to subscribers of this item: if set, reply to all subscribers, else reply to sender'))

help_text = "Default item help text"

def __unicode__(self):
return u'%s[%s] "%s"' % (self.item_type_string, self.pk, self.name)

Expand All @@ -268,6 +270,24 @@ def display_name(self, can_view_name_field=True):
else:
return u'%s %s' % (capfirst(self.actual_item_type()._meta.verbose_name), self.pk)

def display_help_text(self):
help_text = None
breadcrumb_iter = self.actual_item_type()
while breadcrumb_iter != models.base.Model and help_text == None:
# look for help text as html doc
try:
name = breadcrumb_iter.__name__.lower()
template = loader.get_template('help_text/%s.html' % name)
help_text = template.render(Context({}))
except:
pass
breadcrumb_iter = breadcrumb_iter.__base__

if help_text == None:
if self.help_text:
return self.help_text
return help_text

def actual_item_type(self):
"""
Return the actual item type for this item as a class (not a string).
Expand Down
1 change: 1 addition & 0 deletions deme_django/cms/templates/help_text/contactmethod.html
@@ -0,0 +1 @@
HTML contact method item help text
@@ -0,0 +1 @@
HTML email contact method item help text
1 change: 1 addition & 0 deletions deme_django/cms/templates/help_text/item.html
@@ -0,0 +1 @@
HTML default item help text
12 changes: 8 additions & 4 deletions deme_django/cms/templates/includes/metabar_swap.html
Expand Up @@ -44,11 +44,9 @@
{% include 'includes/metabar_section_list.html' %}
{% endwith %}{% endwith %}

{% if metabar_contents %}
{% with "metadata_contents" as id %}{% with "Help" as title %}
{% include 'includes/metabar_section_list.html' %}
{% endwith %}{% endwith %}
{% endif %}
</ul>
</li>
<li class="pull-right">
Expand Down Expand Up @@ -103,14 +101,20 @@
{% include 'includes/metabar_section_swap.html' %}
{% endwith %}{% endwith %}

{% if metabar_contents %}
<div class="block" id="metadata_contents">
<div class="content content-no-ajax">
<h3>Help</h3>
{% if metabar_contents %}
<div class="metabar_contents">
{{ metabar_contents }}
</div>
{% endif %}
<div class="help_text">
{{ item.display_help_text }}
</div>
</div>
</div>
{% endif %}


{% else %}
<ul class="title nav navbar-nav">
Expand Down
3 changes: 3 additions & 0 deletions deme_django/static/css/deme.css
Expand Up @@ -5134,6 +5134,9 @@ body.nonadmin #metabar {
padding: 0;
border-radius: 5px;
}
#metabar .metabar_contents {
margin-bottom: 1em;
}
#metabar .section ~ .section {
border-top: 1px solid #a6a6a6;
}
Expand Down
3 changes: 3 additions & 0 deletions deme_django/static/less/deme/metabar.less
Expand Up @@ -105,6 +105,9 @@
border-radius: 5px;
}
}
.metabar_contents {
margin-bottom: 1em;
}
.section {
~ .section {
border-top: 1px solid lighten(@grayLight,5%); //@grayLight;
Expand Down

0 comments on commit 23e2f89

Please sign in to comment.