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
|
self.upstream_version = upstream_version
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownLatestVersion(BaseCommonException):
|
||||||
|
"""
|
||||||
|
It is not possible to determine what is the latest upstream version.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class NPMException(BaseCommonException):
|
class NPMException(BaseCommonException):
|
||||||
"""Base exception for the NPM registry client"""
|
"""Base exception for the NPM registry client"""
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from json import dumps
|
|||||||
|
|
||||||
import sh
|
import sh
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.template import Context, Library
|
from django.template import Context, Library
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.utils.encoding import force_text
|
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 = Context(context.flatten())
|
||||||
new_context.update(Context(template_context))
|
new_context.update(Context(template_context))
|
||||||
return get_template(template_name).render(new_context.flatten())
|
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
|
from common.compat import dict_type, dictionary_type
|
||||||
import mayan
|
import mayan
|
||||||
|
|
||||||
from .exceptions import NotLatestVersion
|
from .exceptions import NotLatestVersion, UnknownLatestVersion
|
||||||
from .literals import DJANGO_SQLITE_BACKEND, MAYAN_PYPI_NAME, PYPI_URL
|
from .literals import DJANGO_SQLITE_BACKEND, MAYAN_PYPI_NAME, PYPI_URL
|
||||||
from .settings import setting_temporary_directory
|
from .settings import setting_temporary_directory
|
||||||
|
|
||||||
@@ -33,11 +33,11 @@ def check_for_sqlite():
|
|||||||
def check_version():
|
def check_version():
|
||||||
pypi = xmlrpc_client.ServerProxy(PYPI_URL)
|
pypi = xmlrpc_client.ServerProxy(PYPI_URL)
|
||||||
versions = pypi.package_releases(MAYAN_PYPI_NAME)
|
versions = pypi.package_releases(MAYAN_PYPI_NAME)
|
||||||
|
if not versions:
|
||||||
|
raise UnknownLatestVersion
|
||||||
|
else:
|
||||||
if versions[0] != mayan.__version__:
|
if versions[0] != mayan.__version__:
|
||||||
raise NotLatestVersion(upstream_version=versions[0])
|
raise NotLatestVersion(upstream_version=versions[0])
|
||||||
else:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python
|
# 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 acls.models import AccessControlList
|
||||||
|
|
||||||
from .exceptions import NotLatestVersion
|
from .exceptions import NotLatestVersion, UnknownLatestVersion
|
||||||
from .forms import (
|
from .forms import (
|
||||||
LicenseForm, LocaleProfileForm, LocaleProfileForm_view,
|
LicenseForm, LocaleProfileForm, LocaleProfileForm_view,
|
||||||
PackagesLicensesForm, UserForm, UserForm_view
|
PackagesLicensesForm, UserForm, UserForm_view
|
||||||
@@ -49,6 +49,11 @@ class CheckVersionView(SimpleView):
|
|||||||
'The version you are using is outdated. The latest version '
|
'The version you are using is outdated. The latest version '
|
||||||
'is %s'
|
'is %s'
|
||||||
) % exception.upstream_version
|
) % exception.upstream_version
|
||||||
|
except UnknownLatestVersion as exception:
|
||||||
|
message = _(
|
||||||
|
'It is not possible to determine the latest version '
|
||||||
|
'available.'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
message = _('Your version is up-to-date.')
|
message = _('Your version is up-to-date.')
|
||||||
|
|
||||||
@@ -145,7 +150,10 @@ class FaviconRedirectView(RedirectView):
|
|||||||
return static('appearance/images/favicon.ico')
|
return static('appearance/images/favicon.ico')
|
||||||
|
|
||||||
|
|
||||||
class HomeView(TemplateView):
|
class HomeView(SimpleView):
|
||||||
|
extra_context = {
|
||||||
|
'title': _('Dashboard'),
|
||||||
|
}
|
||||||
template_name = 'appearance/home.html'
|
template_name = 'appearance/home.html'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user