diff --git a/mayan/apps/common/exceptions.py b/mayan/apps/common/exceptions.py index a007bad142..66987fcad7 100644 --- a/mayan/apps/common/exceptions.py +++ b/mayan/apps/common/exceptions.py @@ -16,6 +16,12 @@ class NotLatestVersion(BaseCommonException): self.upstream_version = upstream_version +class UnknownLatestVersion(BaseCommonException): + """ + It is not possible to determine what is the latest upstream version. + """ + + class NPMException(BaseCommonException): """Base exception for the NPM registry client""" diff --git a/mayan/apps/common/templatetags/common_tags.py b/mayan/apps/common/templatetags/common_tags.py index b76df75a97..0ea471ed13 100644 --- a/mayan/apps/common/templatetags/common_tags.py +++ b/mayan/apps/common/templatetags/common_tags.py @@ -4,7 +4,6 @@ from json import dumps import sh -from django.conf import settings from django.template import Context, Library from django.template.loader import get_template from django.utils.encoding import force_text @@ -84,4 +83,3 @@ def render_subtemplate(context, template_name, template_context): new_context = Context(context.flatten()) new_context.update(Context(template_context)) return get_template(template_name).render(new_context.flatten()) - diff --git a/mayan/apps/common/utils.py b/mayan/apps/common/utils.py index 2e41073b48..e33ed6c68e 100644 --- a/mayan/apps/common/utils.py +++ b/mayan/apps/common/utils.py @@ -19,7 +19,7 @@ from django.utils.six.moves import reduce as reduce_function, xmlrpc_client from common.compat import dict_type, dictionary_type import mayan -from .exceptions import NotLatestVersion +from .exceptions import NotLatestVersion, UnknownLatestVersion from .literals import DJANGO_SQLITE_BACKEND, MAYAN_PYPI_NAME, PYPI_URL from .settings import setting_temporary_directory @@ -33,11 +33,11 @@ def check_for_sqlite(): def check_version(): pypi = xmlrpc_client.ServerProxy(PYPI_URL) versions = pypi.package_releases(MAYAN_PYPI_NAME) - - if versions[0] != mayan.__version__: - raise NotLatestVersion(upstream_version=versions[0]) + if not versions: + raise UnknownLatestVersion else: - return True + if versions[0] != mayan.__version__: + raise NotLatestVersion(upstream_version=versions[0]) # http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index 14bec19514..05b1bef0bb 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -16,7 +16,7 @@ from django.views.generic import RedirectView, TemplateView from acls.models import AccessControlList -from .exceptions import NotLatestVersion +from .exceptions import NotLatestVersion, UnknownLatestVersion from .forms import ( LicenseForm, LocaleProfileForm, LocaleProfileForm_view, PackagesLicensesForm, UserForm, UserForm_view @@ -49,6 +49,11 @@ class CheckVersionView(SimpleView): 'The version you are using is outdated. The latest version ' 'is %s' ) % exception.upstream_version + except UnknownLatestVersion as exception: + message = _( + 'It is not possible to determine the latest version ' + 'available.' + ) else: message = _('Your version is up-to-date.') @@ -145,7 +150,10 @@ class FaviconRedirectView(RedirectView): return static('appearance/images/favicon.ico') -class HomeView(TemplateView): +class HomeView(SimpleView): + extra_context = { + 'title': _('Dashboard'), + } template_name = 'appearance/home.html'