diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..be0ed64 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 8144efe..1a43a09 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/editor_backend/editor_backend/views.py b/editor_backend/editor_backend/views.py index 8f9c716..167058a 100644 --- a/editor_backend/editor_backend/views.py +++ b/editor_backend/editor_backend/views.py @@ -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) @@ -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) @@ -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': '

Error

The article resource is offline. Please try again later

'}) if r.status_code == 404: raise Http404