Don't error out if it is not possible to check for the latest current version.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -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"""
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user