Permalink
Browse files

Merge pull request #163 from ryanpitts/learning

revisions for Learning section
  • Loading branch information...
2 parents 2e2ed45 + 3f08ac4 commit 546d8be6b765dc6f81b05494c8740174f01a2514 @ryanpitts ryanpitts committed Mar 8, 2013
View
@@ -23,6 +23,7 @@ class ArticleAdmin(AdminImageMixin, admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
filter_horizontal = ('authors', 'people', 'organizations', 'code',)
list_filter = ('is_live', 'article_type',)
+ list_display = ('title', 'pubdate', 'article_type', 'is_live')
search_fields = ('title', 'body', 'summary',)
date_hierarchy = 'pubdate'
fieldsets = (
View
@@ -2,7 +2,7 @@
import itertools
from django.db import models
-from django.template.defaultfilters import date as dj_date, linebreaks
+from django.template.defaultfilters import date as dj_date, linebreaks, removetags
from caching.base import CachingManager, CachingMixin
from sorl.thumbnail import ImageField
@@ -21,10 +21,7 @@
('roundup', 'Roundup'),
('event', 'Event'),
('update', 'Community Update'),
- ('ethics', 'Ethics'),
- ('data', 'Data'),
- ('data-viz', 'Data Visualization'),
- ('mapping', 'Mapping'),
+ ('learning', 'Learning'),
)
# Current iteration does not use this in nav, but leaving dict
@@ -39,7 +36,7 @@
'learning': {
'name': 'Learning',
'slug': 'learning',
- 'article_types': ['ethics', 'data', 'data-viz', 'mapping',],
+ 'article_types': ['learning',],
'gets_promo_items': True,
},
}
@@ -87,23 +84,8 @@
'parent_name': 'Features',
'parent_slug': 'articles',
},
- 'ethics': {
- 'name': 'Ethics',
- 'parent_name': 'Learning',
- 'parent_slug': 'learning',
- },
- 'data': {
- 'name': 'Data',
- 'parent_name': 'Learning',
- 'parent_slug': 'learning',
- },
- 'data-viz': {
- 'name': 'Data Visualization',
- 'parent_name': 'Learning',
- 'parent_slug': 'learning',
- },
- 'mapping': {
- 'name': 'Mapping',
+ 'learning': {
+ 'name': 'Learning',
'parent_name': 'Learning',
'parent_slug': 'learning',
},
@@ -182,6 +164,11 @@ def pretty_body_text(self):
# that already contains <p> tags
_body = linebreaks(_body)
return _body
+
+ @property
+ def safe_summary(self):
+ '''suitable for use in places that must avoid nested anchor tags'''
+ return removetags(self.summary, 'a')
@property
def merged_tag_list(self):
@@ -7,29 +7,33 @@
{% include "articles/_article_list_section_overline.html" %}
{% endif %}
-<p class="intro">In-depth case studies by the best journalist-developers in the field. <span class="tinyhide">Get schooled on how journalist-developers find and build web-native stories, what kinds of questions they ask of data, how choices in presenting the news affects how it’s interpreted, and the ethics they encounter along the way.</span></p>
+<p class="intro">In-depth case studies by the best journalist-developers in the field. <span class="tinyhide">Get schooled on how journo-coders find and build web-native stories, what kinds of questions they ask of data, how choices in presenting the news affects how it’s interpreted, and the ethics they encounter along the way.</span></p>
{% if lead_promo %}
-<div class="page-block lead promo">
{% with article=lead_promo %}
- {# lead promo item goes in here #}
- {% if article.image %}<a href="{{ article.get_absolute_url() }}"><img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "525x400", crop="center") }}" alt="{{ article.title }}"></a>{% endif %}
- <h2>{% include "articles/_article_category_and_tags_overline.html" %}<a href="{{ article.get_absolute_url() }}">{{ article.title }}</a></h2>
- <p>{{ article.summary|safe }}</p>
+ <a class="page-block lead promo" href="{{ article.get_absolute_url() }}">
+ {% if article.image %}<img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "525x400", crop="center") }}" alt="{{ article.title }}">{% endif %}
+ <h2>
+ <span class="category">{% if article.article_type %}{{ article.get_article_type_display() }}{% endif %}{% if article.tags.all().exists() %} <span class="tags">/ {% for tag in article.tags.all() %}{{ tag }}{% if not loop.last %} {% endif %}{% endfor %}</span>{% endif %}</span>
+ {{ article.title }}
+ </h2>
+ <p>{{ article.safe_summary|safe }}</p>
+ </a>
{% endwith %}
-</div>
-
-<div class="secondary-promo-wrap">
- {# two secondary promo items go in here #}
- {% for article in secondary_promos %}
- <div class="page-block promo secondary-promo{% if not loop.first %} second-promo{% endif %}">
- {% if article.image %}<a href="{{ article.get_absolute_url() }}"><img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "200x90", crop="center") }}" alt="{{ article.title }}"></a>{% endif %}
- <h2>{% include "articles/_article_category_and_tags_overline.html" %}<a href="{{ article.get_absolute_url() }}">{{ article.title }}</a></h2>
- <p>{{ article.summary|safe }}</p>
-
- </div>
- {% endfor %}
-</div>
+
+ <div class="secondary-promo-wrap">
+ {# two secondary promo items go in here #}
+ {% for article in secondary_promos %}
+ <a class="page-block promo secondary-promo{% if not loop.first %} second-promo{% endif %}" href="{{ article.get_absolute_url() }}">
+ {% if article.image %}<img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "200x90", crop="center") }}" alt="{{ article.title }}">{% endif %}
+ <h2>
+ <span class="category">{% if article.article_type %}{{ article.get_article_type_display() }}{% endif %}{% if article.tags.all().exists() %} <span class="tags">/ {% for tag in article.tags.all() %}{{ tag }}{% if not loop.last %} {% endif %}{% endfor %}</span>{% endif %}</span>
+ {{ article.title }}
+ </h2>
+ <p>{{ article.safe_summary|safe }}</p>
+ </a>
+ {% endfor %}
+ </div>
{% endif %}
{% if lead_promo and page.object_list|length > 3 %}
View
@@ -1,5 +1,5 @@
from django.core.urlresolvers import reverse
-from django.http import Http404
+from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.generic import ListView, DetailView
@@ -17,6 +17,11 @@ def dispatch(self, *args, **kwargs):
self.tag_slugs = kwargs.get('tag_slugs', None)
self.tags = []
+ if self.category == 'learning' and not self.section:
+ # redirecting this to our "Section" page for Learning
+ # until we refactor Sections into database models
+ return HttpResponseRedirect(reverse('article_list_by_section', args=('learning',)))
+
if self.section:
# check for template override based on section name
self.template_list = [
@@ -813,8 +813,29 @@ pre.prettyprint {
clear: both;
}
-.learning h2 span.category {
- color: #6ca25f
+a.promo {
+ display: block;
+}
+
+a.promo:hover {
+ text-decoration: none;
+}
+
+a.promo span.category {
+ color: #fc6e1f;
+}
+
+a.promo span.tags {
+ color: #bebebe;
+}
+
+a.promo span.tags:before {
+ content: "";
+}
+
+a.promo p {
+ color: #333;
+ margin-bottom: .25em;
}
.promo.lead {
@@ -1132,6 +1153,7 @@ pre.prettyprint {
.promo.secondary-promo {
width: 100%;
margin-right: 20px;
+ margin-bottom: 1.5em;
}
.promo.second-promo {

0 comments on commit 546d8be

Please sign in to comment.