Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #168 from ryanpitts/development
Browse files Browse the repository at this point in the history
allow links in image credit field
  • Loading branch information
ryanpitts committed Mar 26, 2013
2 parents d0fb1b1 + fe6914c commit 04eb425
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion source/articles/admin.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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;'
Expand Down
4 changes: 2 additions & 2 deletions source/articles/models.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions source/articles/templates/articles/article_detail.html
Expand Up @@ -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 %}

Expand Down Expand Up @@ -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 %}

Expand All @@ -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>
Expand Down

0 comments on commit 04eb425

Please sign in to comment.