Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: python
python:
- 3.4
- 3.5

install:
- pip install pytest pytest-cov pytest-django python-coveralls
- pip install -r requirements.txt

script:
- cd editor_backend
- py.test editor_backend --cov=.

after_success:
coveralls

sudo: false
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Hosting and frontend module for CMS microservice

[![Build Status](https://travis-ci.org/microserv/frontend.svg?branch=master)](https://travis-ci.org/microserv/frontend) [![Coverage Status](https://coveralls.io/repos/github/microserv/frontend/badge.svg?branch=master)](https://coveralls.io/github/microserv/frontend?branch=master)


Begin by reading the [contribution guidelines](https://github.com/microserv/contribution-guidelines)
16 changes: 16 additions & 0 deletions editor_backend/editor_backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def editor(request):
r = requests.get(publisher_url + "/authorize_me", cookies=request.COOKIES)
except ReqConnectionError:
logger.error('Publisher offline when attempting to authorize %s.' % timezone.now())
except TypeError:
logger.error('Cannot retrieve publisher URL from backend communication service.')

if r is None:
return render(request, "editor_page.html", {})

if r is not None and r.url != publisher_url + "/authorize_me":
return HttpResponseRedirect(r.url)
Expand Down Expand Up @@ -85,6 +90,11 @@ def articles(request):
r = requests.get(publisher_url + "/list", cookies=request.COOKIES)
except ReqConnectionError:
logger.error('Publisher offline during article listing at %s.' % timezone.now())
except TypeError:
logger.error('Cannot retrieve publisher URL from backend communication service.')

if r is None:
return render(request, "articles.html", {})

if r is not None and r.url != publisher_url + "/list":
return HttpResponseRedirect(r.url)
Expand Down Expand Up @@ -117,6 +127,12 @@ def article(request, pk=None):
r = requests.get(publisher_url + "/article_json/" + pk)
except ReqConnectionError:
logger.error('Publisher offline during request to fetch article "%s" at %s.' % (pk, timezone.now()))
except TypeError:
logger.error('Cannot retrieve publisher URL from backend communication service.')

if r is None:
return render(request, "article.html",
{'article': '<h1>Error</h1><p>The article resource is offline. Please try again later</p>'})

if r.status_code == 404:
raise Http404
Expand Down