Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #169 from mozilla/development

allow links in image_credit fields
  • Loading branch information...
commit 03869e30614a509fd59ed17e9f2fefdd1f483223 2 parents 9fe50da + 04eb425
@rossbruniges rossbruniges authored
View
4 source/articles/admin.py
@@ -16,6 +16,8 @@ def formfield_for_dbfield(self, db_field, **kwargs):
field = super(ArticleBlockInline, self).formfield_for_dbfield(db_field, **kwargs)
if db_field.name == 'image_caption':
field.widget.attrs['style'] = 'height: 5em;'
+ if db_field.name == 'image_credit':
+ field.widget.attrs['style'] = 'width: 45em;'
return field
class ArticleAdmin(AdminImageMixin, admin.ModelAdmin):
@@ -46,7 +48,7 @@ def save_model(self, request, obj, form, change):
def formfield_for_dbfield(self, db_field, **kwargs):
# More usable heights and widths in admin form fields
field = super(ArticleAdmin, self).formfield_for_dbfield(db_field, **kwargs)
- if db_field.name in ['subhead','tags','technology_tags','concept_tags']:
+ if db_field.name in ['subhead','tags','technology_tags','concept_tags','image_credit']:
field.widget.attrs['style'] = 'width: 45em;'
if db_field.name in ['title','slug']:
field.widget.attrs['style'] = 'width: 30em;'
View
4 source/articles/models.py
@@ -106,7 +106,7 @@ class Article(CachingMixin, models.Model):
authors = models.ManyToManyField(Person, blank=True, null=True, related_name='article_authors')
image = ImageField(upload_to='img/uploads/article_images', help_text='Resized to fit 100% column width in template', blank=True, null=True)
image_caption = models.TextField(blank=True)
- image_credit = models.CharField(max_length=128, blank=True, help_text='Optional. Will be appended to end of caption in parens.')
+ image_credit = models.CharField(max_length=128, blank=True, help_text='Optional. Will be appended to end of caption in parens. Accepts HTML.')
body = models.TextField()
summary = models.TextField()
article_type = models.CharField(max_length=32, choices=ARTICLE_TYPE_CHOICES, blank=True)
@@ -205,7 +205,7 @@ class ArticleBlock(CachingMixin, models.Model):
image = ImageField(upload_to='img/uploads/article_images', blank=True, null=True)
image_presentation = models.CharField(max_length=24, choices=IMAGE_PRESENTATION_CHOICES, blank=True)
image_caption = models.TextField(blank=True)
- image_credit = models.CharField(max_length=128, blank=True, help_text='Optional. Will be appended to end of caption in parens.')
+ image_credit = models.CharField(max_length=128, blank=True, help_text='Optional. Will be appended to end of caption in parens. Accepts HTML.')
body = models.TextField()
objects = models.Manager()
View
6 source/articles/templates/articles/article_detail.html
@@ -26,7 +26,7 @@
{% if article.image %}
<div class="image-full-width-wrapper">
<img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "800") }}" alt="{{ article.title }}">
- {% if article.pretty_caption %}<p class="caption">{{ article.pretty_caption }}</p>{% endif %}
+ {% if article.pretty_caption %}<p class="caption">{{ article.pretty_caption|safe }}</p>{% endif %}
</div>
{% endif %}
@@ -79,7 +79,7 @@ <h3 id="{{ articleblock.slug }}">{{ articleblock.title }}</h3>
{% set _this_image_width = _image_width_options[articleblock.image_presentation] %}
<div class="image-{{ articleblock.image_presentation }}-wrapper">
<img src="{{ MEDIA_URL }}{{ thumbnail(articleblock.image, _this_image_width) }}" alt="{{ articleblock.title }}">
- {% if articleblock.pretty_caption %}<p class="caption">{{ articleblock.pretty_caption }}</p>{% endif %}
+ {% if articleblock.pretty_caption %}<p class="caption">{{ articleblock.pretty_caption|safe }}</p>{% endif %}
</div>
{% endif %}
@@ -88,7 +88,7 @@ <h3 id="{{ articleblock.slug }}">{{ articleblock.title }}</h3>
{% if articleblock.image and articleblock.image_presentation == 'full-width-below' %}
<div class="image-full-width-wrapper">
<img src="{{ MEDIA_URL }}{{ thumbnail(articleblock.image, "800") }}" alt="{{ articleblock.title }}">
- {% if articleblock.pretty_caption %}<p class="caption">{{ articleblock.pretty_caption }}</p>{% endif %}
+ {% if articleblock.pretty_caption %}<p class="caption">{{ articleblock.pretty_caption|safe }}</p>{% endif %}
</div>
{% endif %}
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.