Merge "Fixed issue with error message"

This commit is contained in:
Jenkins 2014-04-23 09:01:56 +00:00 committed by Gerrit Code Review
commit 18600631cb
3 changed files with 12 additions and 5 deletions

View File

@ -16,6 +16,7 @@ from django import forms
from django.core.files import uploadedfile
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.conf import settings
from horizon.forms import SelfHandlingForm
from horizon import exceptions
from horizon import messages
@ -24,8 +25,11 @@ from muranodashboard.environments import api
LOG = logging.getLogger(__name__)
MAX_FILE_SIZE_SPEC = (5 * 1024 * 1024, '5', _('MB'))
try:
MAX_FILE_SIZE_MB = int(getattr(settings, 'MAX_FILE_SIZE_MB', 5))
except ValueError:
LOG.warning("MAX_FILE_SIZE_MB parameter has the incorrect value.")
MAX_FILE_SIZE_MB = 5
def split_post_data(post):
@ -52,10 +56,10 @@ class UploadPackageForm(SelfHandlingForm):
def clean_package(self):
package = self.cleaned_data.get('package')
if package:
max_size, size_in_units, unit_spec = MAX_FILE_SIZE_SPEC
if package.size > max_size:
max_size_in_bytes = MAX_FILE_SIZE_MB << 20
if package.size > max_size_in_bytes:
msg = _('It is restricted to upload files larger than '
'{0}{1}.'.format(size_in_units, unit_spec))
'{0} MB.').format(MAX_FILE_SIZE_MB)
LOG.error(msg)
raise forms.ValidationError(msg)
return package

View File

@ -94,6 +94,8 @@ STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
MAX_FILE_SIZE_MB = 5
less_binary = os.path.join(BIN_DIR, 'less', 'lessc')
COMPRESS_PRECOMPILERS = (
('text/less', (less_binary + ' {infile} {outfile}')),

View File

@ -191,6 +191,7 @@ LOGGING['loggers']['muranoclient'] = {'handlers': ['murano-file'], 'level': 'ERR
#MURANO_API_URL = "http://localhost:8082"
#if murano-api set up with ssl uncomment next strings
#MURANO_API_INSECURE = True
MAX_FILE_SIZE_MB = 5
#END_MURANO_DASHBOARD
EOF
sed -ne "/$PATTERN/r $TMPFILE" -e 1x -e '2,${x;p}' -e '${x;p}' -i $INFILE