Skip to content

Commit

Permalink
Modify skeds macros and move the template to aap repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur Dhamanwala committed Jun 8, 2016
1 parent 93aa0c2 commit 6978b9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ include/
/server/.settings/org.eclipse.core.resources.prefs
/results/
/superdesk-content-api/
/node_modules/
13 changes: 13 additions & 0 deletions server/aap/macros/generate_slugline_story_by_desk.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ def get_articles(self, query, repo):
def create_query(self):
raise NotImplementedError()

@abstractmethod
def process(self):
raise NotImplementedError()

def generate(self, template_name):
query, repo = self.create_query()
articles = self.get_articles(query, repo)
if not articles:
return ''

self.process(articles)
return render_template(template_name, items=articles)


Expand Down Expand Up @@ -113,6 +118,14 @@ def create_query(self):

return query, ['archive', 'published']

def process(self, articles):
for article in articles:
article['anpa_take_key'] = article.get('anpa_take_key') or ''
article['abstract'] = article.get('abstract') or ''
article['slugline'] = article.get('slugline') or ''
article['source'] = article.get('source') or ''
article['dateline_city'] = (article.get('dateline', {}).get('located', {}).get('city') or '').upper()


def generate_published_slugline_story_by_desk(item, **kwargs):
"""
Expand Down
1 change: 1 addition & 0 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,4 @@ def env(variable, fallback_value=None):
is_testing = os.environ.get('SUPERDESK_TESTING', '').lower() == 'true'
ELASTICSEARCH_FORCE_REFRESH = is_testing
ELASTICSEARCH_AUTO_AGGREGATIONS = False
CUSTOM_TEMPLATE_PATH = [os.path.join(ABS_PATH, 'templates')]
3 changes: 3 additions & 0 deletions server/templates/skeds_body_html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for item in items %}
<p>{{item.dateline_city}} {{item.source}} - {{item.abstract|striptags}} ({{item.slugline}}) {{item.anpa_take_key}} {{item.versioncreated | format_datetime('Australia/Sydney', '%H:%S')}}</p></br>
{% endfor %}

0 comments on commit 6978b9a

Please sign in to comment.