forked from shaba/openuds
Fixing up things
This commit is contained in:
parent
46af1b57dd
commit
feccd388c4
@ -118,6 +118,7 @@ encoding//src/uds/core/util/__init__.py=utf-8
|
|||||||
encoding//src/uds/core/util/connection.py=utf-8
|
encoding//src/uds/core/util/connection.py=utf-8
|
||||||
encoding//src/uds/core/util/html.py=utf-8
|
encoding//src/uds/core/util/html.py=utf-8
|
||||||
encoding//src/uds/core/util/log.py=utf-8
|
encoding//src/uds/core/util/log.py=utf-8
|
||||||
|
encoding//src/uds/core/util/middleware/__init__.py=utf-8
|
||||||
encoding//src/uds/core/util/modfinder.py=utf-8
|
encoding//src/uds/core/util/modfinder.py=utf-8
|
||||||
encoding//src/uds/core/util/net.py=utf-8
|
encoding//src/uds/core/util/net.py=utf-8
|
||||||
encoding//src/uds/core/util/request.py=utf-8
|
encoding//src/uds/core/util/request.py=utf-8
|
||||||
|
@ -15,7 +15,7 @@ SITE_ROOT = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-1]
|
|||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
MINIFY = False
|
|
||||||
|
|
||||||
ADMINS = (
|
ADMINS = (
|
||||||
# ('Your Name', 'your_email@example.com'),
|
# ('Your Name', 'your_email@example.com'),
|
||||||
@ -118,6 +118,7 @@ STATICFILES_DIRS = (
|
|||||||
STATICFILES_FINDERS = (
|
STATICFILES_FINDERS = (
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
|
'compressor.finders.CompressorFinder',
|
||||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -175,9 +176,22 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'south',
|
'south',
|
||||||
|
'compress',
|
||||||
'uds',
|
'uds',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Compressor settings (for css/js)
|
||||||
|
COMPRESS_ENABLED = True
|
||||||
|
COMPRESS_OUTPUT_DIR = 'cache'
|
||||||
|
COMPRESS_PRECOMPILERS = (
|
||||||
|
('text/coffeescript', 'coffee --compile --stdio'),
|
||||||
|
('text/less', 'lessc {infile} {outfile}'),
|
||||||
|
('text/x-sass', 'sass {infile} {outfile}'),
|
||||||
|
('text/x-scss', 'sass --scss {infile} {outfile}'),
|
||||||
|
('text/stylus', 'stylus < {infile} > {outfile}'),
|
||||||
|
('text/foobar', 'path.to.MyPrecompilerFilter'),
|
||||||
|
)
|
||||||
|
|
||||||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||||
# more details on how to customize your logging configuration.
|
# more details on how to customize your logging configuration.
|
||||||
LOGDIR = SITE_ROOT + '/' + 'log'
|
LOGDIR = SITE_ROOT + '/' + 'log'
|
||||||
|
@ -71,7 +71,7 @@ class DownloadsManager(object):
|
|||||||
@param path: path to file
|
@param path: path to file
|
||||||
@params zip: If download as zip
|
@params zip: If download as zip
|
||||||
'''
|
'''
|
||||||
_id = str(uuid.uuid5(self._namespace, name))
|
_id = uuid.uuid5(self._namespace, str(name))
|
||||||
self._downloadables[_id] = {'name': name, 'comment': comment, 'path': path, 'mime': mime}
|
self._downloadables[_id] = {'name': name, 'comment': comment, 'path': path, 'mime': mime}
|
||||||
|
|
||||||
def getDownloadables(self):
|
def getDownloadables(self):
|
||||||
|
@ -77,12 +77,12 @@ class AutoAttributes(Serializable):
|
|||||||
self.declare(**kwargs)
|
self.declare(**kwargs)
|
||||||
|
|
||||||
def __getattribute__(self, name):
|
def __getattribute__(self, name):
|
||||||
if name.startswith('_') and self.dict.has_key(name[1:]):
|
if name.startswith('_') and name[1:] in self.dict:
|
||||||
return self.dict[name[1:]].getValue()
|
return self.dict[name[1:]].getValue()
|
||||||
return object.__getattribute__(self, name)
|
return object.__getattribute__(self, name)
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
if name.startswith('_') and self.dict.has_key(name[1:]):
|
if name.startswith('_') and name[1:] in self.dict:
|
||||||
self.dict[name[1:]].setValue(value)
|
self.dict[name[1:]].setValue(value)
|
||||||
else:
|
else:
|
||||||
object.__setattr__(self, name, value)
|
object.__setattr__(self, name, value)
|
||||||
@ -102,7 +102,7 @@ class AutoAttributes(Serializable):
|
|||||||
# We keep original data (maybe incomplete)
|
# We keep original data (maybe incomplete)
|
||||||
for pair in data.decode(AutoAttributes.ACODEC).split('\2'):
|
for pair in data.decode(AutoAttributes.ACODEC).split('\2'):
|
||||||
k, v = pair.split('\1')
|
k, v = pair.split('\1')
|
||||||
self.dict[k] = cPickle.loads(v)
|
self.dict[k] = cPickle.loads(str(v))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
str_ = '<AutoAttribute '
|
str_ = '<AutoAttribute '
|
||||||
|
@ -62,7 +62,7 @@ class Cache(object):
|
|||||||
expired = now > c.created + timedelta(seconds=c.validity)
|
expired = now > c.created + timedelta(seconds=c.validity)
|
||||||
if expired:
|
if expired:
|
||||||
return defValue
|
return defValue
|
||||||
val = cPickle.loads(c.value.decode(Cache.CODEC))
|
val = cPickle.loads(c.value.decode(Cache.CODEC).encode('utf-8'))
|
||||||
return val
|
return val
|
||||||
except dbCache.DoesNotExist:
|
except dbCache.DoesNotExist:
|
||||||
logger.debug('key not found')
|
logger.debug('key not found')
|
||||||
|
@ -88,7 +88,7 @@ class Storage(object):
|
|||||||
return self.readData(skey)
|
return self.readData(skey)
|
||||||
|
|
||||||
def getPickle(self, skey):
|
def getPickle(self, skey):
|
||||||
return cPickle.loads(self.readData(skey))
|
return cPickle.loads(self.readData(skey).encode('uft-8'))
|
||||||
|
|
||||||
def remove(self, skey):
|
def remove(self, skey):
|
||||||
try:
|
try:
|
||||||
|
@ -157,4 +157,4 @@ def checkBrowser(user_agent, browser):
|
|||||||
# debug setting in context
|
# debug setting in context
|
||||||
def context(request):
|
def context(request):
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
return {'DEBUG': settings.DEBUG, 'MINIFY': settings.MINIFY}
|
return {'DEBUG': settings.DEBUG}
|
||||||
|
@ -1,3 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Virtual Cable S.L.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -3,27 +3,27 @@
|
|||||||
# Copyright (c) 2013 Virtual Cable S.L.
|
# Copyright (c) 2013 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -31,7 +31,4 @@
|
|||||||
'''
|
'''
|
||||||
import counters
|
import counters
|
||||||
|
|
||||||
|
|
||||||
counters._initializeData()
|
counters._initializeData()
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,32 +3,33 @@
|
|||||||
# Copyright (c) 2013 Virtual Cable S.L.
|
# Copyright (c) 2013 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||||
'''
|
'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import cairo
|
import cairo
|
||||||
@ -45,10 +46,11 @@ CHART_TYPE_LINE, CHART_TYPE_AREA, CHART_TYPE_BAR = xrange(3)
|
|||||||
|
|
||||||
__typeTitles = None
|
__typeTitles = None
|
||||||
|
|
||||||
|
|
||||||
def make(obj, counterType, **kwargs):
|
def make(obj, counterType, **kwargs):
|
||||||
|
|
||||||
width, height = (kwargs.get('width', 800), kwargs.get('height', 600))
|
width, height = (kwargs.get('width', 800), kwargs.get('height', 600))
|
||||||
|
|
||||||
since = kwargs.get('since', None)
|
since = kwargs.get('since', None)
|
||||||
to = kwargs.get('to', None)
|
to = kwargs.get('to', None)
|
||||||
if since is None and to is None:
|
if since is None and to is None:
|
||||||
@ -56,27 +58,27 @@ def make(obj, counterType, **kwargs):
|
|||||||
if interval is not None:
|
if interval is not None:
|
||||||
to = getSqlDatetime()
|
to = getSqlDatetime()
|
||||||
since = to - datetime.timedelta(days=interval)
|
since = to - datetime.timedelta(days=interval)
|
||||||
|
|
||||||
limit = width
|
limit = width
|
||||||
|
|
||||||
dataset1 = tuple((int(time.mktime(x[0].timetuple())), x[1]) for x in counters.getCounters(obj, counterType, since=since, to=to, limit=limit, use_max = kwargs.get('use_max', False)))
|
dataset1 = tuple((int(time.mktime(x[0].timetuple())), x[1]) for x in counters.getCounters(obj, counterType, since=since, to=to, limit=limit, use_max=kwargs.get('use_max', False)))
|
||||||
|
|
||||||
if len(dataset1) == 0:
|
if len(dataset1) == 0:
|
||||||
dataset1 = ( (getSqlDatetime(True)-3600, 0), (getSqlDatetime(True), 0) )
|
dataset1 = ((getSqlDatetime(True) - 3600, 0), (getSqlDatetime(True), 0))
|
||||||
|
|
||||||
firstLast = (dataset1[0][0], getSqlDatetime(True))
|
firstLast = (dataset1[0][0], getSqlDatetime(True))
|
||||||
|
|
||||||
xLabelFormat = '%y-%m-%d'
|
xLabelFormat = '%y-%m-%d'
|
||||||
diffInterval = firstLast[1] - firstLast[0]
|
diffInterval = firstLast[1] - firstLast[0]
|
||||||
if diffInterval <= 60*60*24: # Less than one day
|
if diffInterval <= 60 * 60 * 24: # Less than one day
|
||||||
xLabelFormat = '%H:%M'
|
xLabelFormat = '%H:%M'
|
||||||
elif diffInterval <= 60*60*24*7:
|
elif diffInterval <= 60 * 60 * 24 * 7:
|
||||||
xLabelFormat = '%A'
|
xLabelFormat = '%A'
|
||||||
|
|
||||||
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
||||||
|
|
||||||
dataset = ( ( counters.getCounterTitle(counterType).encode('iso-8859-1', errors='ignore'), dataset1 ),)
|
dataset = ((counters.getCounterTitle(counterType).encode('iso-8859-1', errors='ignore'), dataset1),)
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
'axis': {
|
'axis': {
|
||||||
'x': {
|
'x': {
|
||||||
@ -86,7 +88,7 @@ def make(obj, counterType, **kwargs):
|
|||||||
'y': {
|
'y': {
|
||||||
'tickCount': 4,
|
'tickCount': 4,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'legend': {'hide': True},
|
'legend': {'hide': True},
|
||||||
'background': {
|
'background': {
|
||||||
'chartColor': '#ffeeff',
|
'chartColor': '#ffeeff',
|
||||||
@ -107,15 +109,14 @@ def make(obj, counterType, **kwargs):
|
|||||||
'bottom': 0,
|
'bottom': 0,
|
||||||
},
|
},
|
||||||
'title': 'Sample Chart'
|
'title': 'Sample Chart'
|
||||||
}
|
}
|
||||||
|
|
||||||
chart = pycha.line.LineChart(surface, options)
|
chart = pycha.line.LineChart(surface, options)
|
||||||
chart.addDataset(dataset)
|
chart.addDataset(dataset)
|
||||||
chart.render()
|
chart.render()
|
||||||
|
|
||||||
output = StringIO.StringIO()
|
|
||||||
|
|
||||||
surface.write_to_png(output)
|
|
||||||
|
|
||||||
return output.getvalue()
|
|
||||||
|
|
||||||
|
output = StringIO.StringIO()
|
||||||
|
|
||||||
|
surface.write_to_png(output)
|
||||||
|
|
||||||
|
return output.getvalue()
|
||||||
|
@ -3,27 +3,27 @@
|
|||||||
# Copyright (c) 2013 Virtual Cable S.L.
|
# Copyright (c) 2013 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
@ -40,10 +40,11 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Posible counters, note that not all are used by every posible type
|
# Posible counters, note that not all are used by every posible type
|
||||||
# FIRST_COUNTER_TYPE, LAST_COUNTER_TYPE are just a placeholder for sanity checks
|
# FIRST_COUNTER_TYPE, LAST_COUNTER_TYPE are just a placeholder for sanity checks
|
||||||
(
|
(
|
||||||
CT_LOAD, CT_STORAGE, CT_ASSIGNED, CT_INUSE,
|
CT_LOAD, CT_STORAGE, CT_ASSIGNED, CT_INUSE,
|
||||||
) = xrange(4)
|
) = xrange(4)
|
||||||
|
|
||||||
__caRead = None
|
__caRead = None
|
||||||
@ -52,27 +53,27 @@ __transDict = None
|
|||||||
__typeTitles = None
|
__typeTitles = None
|
||||||
|
|
||||||
|
|
||||||
def addCounter(obj, counterType, counterValue, stamp = None):
|
def addCounter(obj, counterType, counterValue, stamp=None):
|
||||||
'''
|
'''
|
||||||
Adds a counter stat to specified object
|
Adds a counter stat to specified object
|
||||||
|
|
||||||
Although any counter type can be added to any object, there is a relation that must be observed
|
Although any counter type can be added to any object, there is a relation that must be observed
|
||||||
or, otherway, the stats will not be recoverable at all:
|
or, otherway, the stats will not be recoverable at all:
|
||||||
|
|
||||||
|
|
||||||
note: Runtime checks are done so if we try to insert an unssuported stat, this won't be inserted and it will be logged
|
note: Runtime checks are done so if we try to insert an unssuported stat, this won't be inserted and it will be logged
|
||||||
'''
|
'''
|
||||||
if type(obj) not in __caWrite.get(counterType, ()):
|
if type(obj) not in __caWrite.get(counterType, ()):
|
||||||
logger.error('Type {0} does not accepts counter of type {1}',format(type(obj), counterValue))
|
logger.error('Type {0} does not accepts counter of type {1}', format(type(obj), counterValue))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return statsManager().addCounter(__transDict[type(obj)], obj.id, counterType, counterValue, stamp)
|
return statsManager().addCounter(__transDict[type(obj)], obj.id, counterType, counterValue, stamp)
|
||||||
|
|
||||||
|
|
||||||
def getCounters(obj, counterType, **kwargs):
|
def getCounters(obj, counterType, **kwargs):
|
||||||
'''
|
'''
|
||||||
Get counters
|
Get counters
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj: Obj for which to recover stats counters
|
obj: Obj for which to recover stats counters
|
||||||
counterType: type of counter to recover
|
counterType: type of counter to recover
|
||||||
@ -80,81 +81,81 @@ def getCounters(obj, counterType, **kwargs):
|
|||||||
to: (optional, defaults to 'Until end') En date for counter to recover
|
to: (optional, defaults to 'Until end') En date for counter to recover
|
||||||
limit: (optional, defaults to 1000) Number of counter to recover. This is an 'At most' advice. The returned number of value
|
limit: (optional, defaults to 1000) Number of counter to recover. This is an 'At most' advice. The returned number of value
|
||||||
can be lower, or even 1 more than requested due to a division for retrieving object at database
|
can be lower, or even 1 more than requested due to a division for retrieving object at database
|
||||||
all: (optinal), indicates that get all counters for the type of obj passed in, not only for that obj.
|
all: (optinal), indicates that get all counters for the type of obj passed in, not only for that obj.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A generator, that contains pairs of (stamp, value) tuples
|
A generator, that contains pairs of (stamp, value) tuples
|
||||||
'''
|
'''
|
||||||
|
|
||||||
since = kwargs.get('since', NEVER)
|
since = kwargs.get('since', NEVER)
|
||||||
to = kwargs.get('to', datetime.datetime.now())
|
to = kwargs.get('to', datetime.datetime.now())
|
||||||
limit = kwargs.get('limit', 1000)
|
limit = kwargs.get('limit', 1000)
|
||||||
use_max = kwargs.get('use_max', False)
|
use_max = kwargs.get('use_max', False)
|
||||||
|
|
||||||
readFncTbl = __caRead.get(type(obj), None)
|
readFncTbl = __caRead.get(type(obj), None)
|
||||||
|
|
||||||
|
|
||||||
if readFncTbl is None:
|
if readFncTbl is None:
|
||||||
logger.error('Type {0} has no registered stats'.format(type(obj)))
|
logger.error('Type {0} has no registered stats'.format(type(obj)))
|
||||||
return
|
return
|
||||||
|
|
||||||
fnc = readFncTbl.get(counterType, None)
|
fnc = readFncTbl.get(counterType, None)
|
||||||
|
|
||||||
if fnc is None:
|
if fnc is None:
|
||||||
logger.error('Type {0} has no registerd stats of type {1}'.format(type(obj), counterType))
|
logger.error('Type {0} has no registerd stats of type {1}'.format(type(obj), counterType))
|
||||||
return
|
return
|
||||||
|
|
||||||
if kwargs.get('all', None) is not True:
|
if kwargs.get('all', None) is not True:
|
||||||
owner_ids = fnc(obj)
|
owner_ids = fnc(obj)
|
||||||
else:
|
else:
|
||||||
owner_ids = None
|
owner_ids = None
|
||||||
|
|
||||||
|
|
||||||
for i in statsManager().getCounters(__transDict[type(obj)], counterType, owner_ids, since, to, limit, use_max):
|
for i in statsManager().getCounters(__transDict[type(obj)], counterType, owner_ids, since, to, limit, use_max):
|
||||||
val = (datetime.datetime.fromtimestamp(i.stamp), i.value)
|
val = (datetime.datetime.fromtimestamp(i.stamp), i.value)
|
||||||
yield val
|
yield val
|
||||||
|
|
||||||
|
|
||||||
def getCounterTitle(counterType):
|
def getCounterTitle(counterType):
|
||||||
return __typeTitles.get(counterType, '').title()
|
return __typeTitles.get(counterType, '').title()
|
||||||
|
|
||||||
# Data initialization
|
|
||||||
|
# Data initialization
|
||||||
def _initializeData():
|
def _initializeData():
|
||||||
'''
|
'''
|
||||||
Initializes dictionaries.
|
Initializes dictionaries.
|
||||||
|
|
||||||
Hides data from global var space
|
Hides data from global var space
|
||||||
'''
|
'''
|
||||||
from uds.models import Provider, Service, DeployedService
|
from uds.models import Provider, Service, DeployedService
|
||||||
|
|
||||||
global __caWrite
|
global __caWrite
|
||||||
global __caRead
|
global __caRead
|
||||||
global __transDict
|
global __transDict
|
||||||
global __typeTitles
|
global __typeTitles
|
||||||
|
|
||||||
__caWrite = {
|
__caWrite = {
|
||||||
CT_LOAD: (Provider,),
|
CT_LOAD: (Provider,),
|
||||||
CT_STORAGE: (Service,),
|
CT_STORAGE: (Service,),
|
||||||
CT_ASSIGNED: (DeployedService,),
|
CT_ASSIGNED: (DeployedService,),
|
||||||
CT_INUSE: (DeployedService,),
|
CT_INUSE: (DeployedService,),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# OBtain ids from variups type of object to retrieve stats
|
# OBtain ids from variups type of object to retrieve stats
|
||||||
def get_Id(obj):
|
def get_Id(obj):
|
||||||
return obj.id
|
return obj.id
|
||||||
|
|
||||||
def get_P_S_Ids(provider):
|
def get_P_S_Ids(provider):
|
||||||
return (i.id for i in provider.services.all())
|
return (i.id for i in provider.services.all())
|
||||||
|
|
||||||
def get_S_DS_Ids(service):
|
def get_S_DS_Ids(service):
|
||||||
return (i.id for i in service.deployedServices.all())
|
return (i.id for i in service.deployedServices.all())
|
||||||
|
|
||||||
def get_P_S_DS_Ids(provider):
|
def get_P_S_DS_Ids(provider):
|
||||||
res = ()
|
res = ()
|
||||||
for i in provider.services.all():
|
for i in provider.services.all():
|
||||||
res += get_S_DS_Ids(i)
|
res += get_S_DS_Ids(i)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
__caRead = {
|
__caRead = {
|
||||||
Provider: {
|
Provider: {
|
||||||
CT_LOAD: get_Id,
|
CT_LOAD: get_Id,
|
||||||
@ -172,39 +173,37 @@ def _initializeData():
|
|||||||
CT_INUSE: get_Id
|
CT_INUSE: get_Id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _getIds(obj):
|
def _getIds(obj):
|
||||||
to = type(obj)
|
to = type(obj)
|
||||||
|
|
||||||
if to is DeployedService:
|
if to is DeployedService:
|
||||||
return to.id;
|
return to.id
|
||||||
|
|
||||||
if to is Service:
|
if to is Service:
|
||||||
return (i.id for i in obj.userServices.all())
|
return (i.id for i in obj.userServices.all())
|
||||||
|
|
||||||
res = ()
|
res = ()
|
||||||
if to is Provider:
|
if to is Provider:
|
||||||
for i in obj.services.all():
|
for i in obj.services.all():
|
||||||
res += _getIds(i)
|
res += _getIds(i)
|
||||||
return res
|
return res
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
OT_PROVIDER, OT_SERVICE, OT_DEPLOYED = xrange(3)
|
OT_PROVIDER, OT_SERVICE, OT_DEPLOYED = xrange(3)
|
||||||
|
|
||||||
# Dict to convert objects to owner types
|
# Dict to convert objects to owner types
|
||||||
# Dict for translations
|
# Dict for translations
|
||||||
__transDict = {
|
__transDict = {
|
||||||
DeployedService : OT_DEPLOYED,
|
DeployedService: OT_DEPLOYED,
|
||||||
Service : OT_SERVICE,
|
Service: OT_SERVICE,
|
||||||
Provider : OT_PROVIDER
|
Provider: OT_PROVIDER
|
||||||
}
|
}
|
||||||
|
|
||||||
# Titles of types
|
# Titles of types
|
||||||
__typeTitles = {
|
__typeTitles = {
|
||||||
CT_ASSIGNED: _('Assigned'),
|
CT_ASSIGNED: _('Assigned'),
|
||||||
CT_INUSE: _('In use'),
|
CT_INUSE: _('In use'),
|
||||||
CT_LOAD: _('Load'),
|
CT_LOAD: _('Load'),
|
||||||
CT_STORAGE: _('Storage')
|
CT_STORAGE: _('Storage')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load l10n i18n static html5 REST %}{% spaceless %}
|
{% load l10n i18n static compress html5 REST %}{% spaceless %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
{% get_available_languages as LANGUAGES %}
|
{% get_available_languages as LANGUAGES %}
|
||||||
<!DOCTYPE html>{% endspaceless %}
|
<!DOCTYPE html>{% endspaceless %}
|
||||||
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
<link href="{% get_static_prefix %}img/favicon.ico" rel="icon" type="image/x-icon">
|
<link href="{% get_static_prefix %}img/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
|
|
||||||
{% if MINIFY != True %}
|
<!-- minified css from: bootstrap, font-awesome, bootstrap-formhelper, bootstrap-select, bootstrap-switch, datatables, tabletools, tabletools.botstrap, uds CSSs -->
|
||||||
|
{% compress css %}
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
<link href="{% get_static_prefix %}adm/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}adm/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}adm/css/font-awesome.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}adm/css/font-awesome.min.css" rel="stylesheet" media="screen">
|
||||||
@ -26,10 +27,7 @@
|
|||||||
<link href="{% get_static_prefix %}adm/css/tables.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}adm/css/tables.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}adm/css/buttons.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}adm/css/buttons.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}adm/css/uds-admin.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}adm/css/uds-admin.css" rel="stylesheet" media="screen">
|
||||||
{% else %}
|
{% endcompress %}
|
||||||
<!-- minified css from: bootstrap, font-awesome, bootstrap-formhelper, bootstrap-select, bootstrap-switch, datatables, tabletools, tabletools.botstrap, uds CSSs -->
|
|
||||||
<link href="{% get_static_prefix %}adm/css/admin.min.css" rel="stylesheet" media="screen">
|
|
||||||
{% endif %}
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -44,8 +42,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{% url 'uds.web.views.jsCatalog' LANGUAGE_CODE %}"></script>
|
<script src="{% url 'uds.web.views.jsCatalog' LANGUAGE_CODE %}"></script>
|
||||||
|
|
||||||
|
{% compress js %}
|
||||||
<script src="{% get_static_prefix %}adm/js/jquery-2.0.3.min.js"></script>
|
<script src="{% get_static_prefix %}adm/js/jquery-2.0.3.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -62,7 +62,8 @@
|
|||||||
}(window.api = window.api || {}, jQuery));
|
}(window.api = window.api || {}, jQuery));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% if MINIFY != True %}
|
<!-- minified js from: 'jquery.cookie', 'bootstrap.min', 'bootstrap-switch.min', 'bootstrap-select.min', 'jquery.validate.min', 'jquery.blockUI', 'flot',
|
||||||
|
'jquery.dataTables.min', 'TableTools.min', 'Blob', 'FileSaver', 'ZeroClipboard', 'dataTables.bootstrap', 'handlebars-v1.1.2', UDS admin JS's -->
|
||||||
<script src="{% get_static_prefix %}adm/js/jquery.cookie.js"></script>
|
<script src="{% get_static_prefix %}adm/js/jquery.cookie.js"></script>
|
||||||
<script src="{% get_static_prefix %}adm/js/bootstrap.min.js"></script>
|
<script src="{% get_static_prefix %}adm/js/bootstrap.min.js"></script>
|
||||||
<script src="{% get_static_prefix %}adm/js/bootstrap-switch.min.js"></script>
|
<script src="{% get_static_prefix %}adm/js/bootstrap-switch.min.js"></script>
|
||||||
@ -117,12 +118,6 @@
|
|||||||
<script src="{% get_static_prefix %}adm/js/gui-d-servicespools.js"></script>
|
<script src="{% get_static_prefix %}adm/js/gui-d-servicespools.js"></script>
|
||||||
<script src="{% get_static_prefix %}adm/js/gui-d-config.js"></script>
|
<script src="{% get_static_prefix %}adm/js/gui-d-config.js"></script>
|
||||||
|
|
||||||
{% else %}
|
|
||||||
<!-- minified js from: 'jquery.cookie', 'bootstrap.min', 'bootstrap-switch.min', 'bootstrap-select.min', 'jquery.validate.min', 'jquery.blockUI', 'flot',
|
|
||||||
'jquery.dataTables.min', 'TableTools.min', 'Blob', 'FileSaver', 'ZeroClipboard', 'dataTables.bootstrap', 'handlebars-v1.1.2', UDS admin JS's -->
|
|
||||||
<script src="{% get_static_prefix %}adm/js/admin.min.js"></script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
// set default error function
|
// set default error function
|
||||||
@ -132,6 +127,8 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% block js %}{% endblock %}
|
{% block js %}{% endblock %}
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
{% js_template_path 'uds/admin/tmpl' %}
|
{% js_template_path 'uds/admin/tmpl' %}
|
||||||
<!-- preloading of templates -->
|
<!-- preloading of templates -->
|
||||||
<!-- page contents -->
|
<!-- page contents -->
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load l10n i18n static html5 %}{% spaceless %}
|
{% load l10n i18n static html5 compress %}{% spaceless %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
{% get_available_languages as LANGUAGES %}
|
{% get_available_languages as LANGUAGES %}
|
||||||
<!DOCTYPE html>{% endspaceless %}
|
<!DOCTYPE html>{% endspaceless %}
|
||||||
@ -14,13 +14,16 @@
|
|||||||
{% block icon %}<link href="{% get_static_prefix %}img/favicon.png" rel="icon" type="image/x-icon" />{% endblock %}
|
{% block icon %}<link href="{% get_static_prefix %}img/favicon.png" rel="icon" type="image/x-icon" />{% endblock %}
|
||||||
|
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
|
{% compress css %}
|
||||||
<link href="{% get_static_prefix %}css/bootstrap.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}css/font-awesome.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/font-awesome.min.css" rel="stylesheet" media="screen">
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
{% ifbrowser ie<9 %}
|
{% ifbrowser ie<9 %}
|
||||||
<script src="{% get_static_prefix %}/js/respond.min.js"></script>
|
<script src="{% get_static_prefix %}/js/respond.min.js"></script>
|
||||||
{% endifbrowser %}
|
{% endifbrowser %}
|
||||||
|
|
||||||
|
{% compress css %}
|
||||||
<link href="{% get_static_prefix %}css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}css/bootstrap-formhelpers.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap-formhelpers.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}css/bootstrap-select.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap-select.min.css" rel="stylesheet" media="screen">
|
||||||
@ -32,12 +35,16 @@
|
|||||||
<link href="{% get_static_prefix %}css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}css/bootstrap-switch.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/bootstrap-switch.css" rel="stylesheet" media="screen">
|
||||||
<link href="{% get_static_prefix %}css/uds-html5.css" rel="stylesheet" media="screen">
|
<link href="{% get_static_prefix %}css/uds-html5.css" rel="stylesheet" media="screen">
|
||||||
|
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
|
{% compress css %}
|
||||||
{% ifbrowser ie<9 %}
|
{% ifbrowser ie<9 %}
|
||||||
<script src="{% get_static_prefix %}/js/html5shiv.js"></script>
|
<script src="{% get_static_prefix %}/js/html5shiv.js"></script>
|
||||||
{% endifbrowser %}
|
{% endifbrowser %}
|
||||||
|
|
||||||
{% block css %}{% endblock %}
|
{% block css %}{% endblock %}
|
||||||
|
{% endcompress %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -75,6 +82,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="{% url 'uds.web.views.jsCatalog' LANGUAGE_CODE %}"></script>
|
<script src="{% url 'uds.web.views.jsCatalog' LANGUAGE_CODE %}"></script>
|
||||||
|
{% compress js %}
|
||||||
<script src="{% get_static_prefix %}js/jquery-1.10.2.min.js"></script>
|
<script src="{% get_static_prefix %}js/jquery-1.10.2.min.js"></script>
|
||||||
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
<script src="{% get_static_prefix %}js/jquery.cookie.js"></script>
|
||||||
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
<script src="{% get_static_prefix %}js/bootstrap.min.js"></script>
|
||||||
@ -88,5 +96,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% block js %}{% endblock %}
|
{% block js %}{% endblock %}
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -4,32 +4,33 @@
|
|||||||
# Copyright (c) 2012 Virtual Cable S.L.
|
# Copyright (c) 2012 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||||
'''
|
'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
@ -56,11 +57,11 @@ INVALID_REQUEST = 10
|
|||||||
BROWSER_NOT_SUPPORTED = 11
|
BROWSER_NOT_SUPPORTED = 11
|
||||||
|
|
||||||
|
|
||||||
strings = [
|
strings = [
|
||||||
_('Unknown error'),
|
_('Unknown error'),
|
||||||
_('Transport not found'),
|
_('Transport not found'),
|
||||||
_('Service not found'),
|
_('Service not found'),
|
||||||
_('Access denied'),
|
_('Access denied'),
|
||||||
_('Invalid service. The service is not available at this moment. Please, try later'),
|
_('Invalid service. The service is not available at this moment. Please, try later'),
|
||||||
_('Maximum services limit reached. Please, contact administrator'),
|
_('Maximum services limit reached. Please, contact administrator'),
|
||||||
_('You need to enable cookies to let this application work'),
|
_('You need to enable cookies to let this application work'),
|
||||||
@ -77,10 +78,10 @@ def errorString(errorId):
|
|||||||
if errorId < len(strings):
|
if errorId < len(strings):
|
||||||
return strings[errorId]
|
return strings[errorId]
|
||||||
return strings[0]
|
return strings[0]
|
||||||
|
|
||||||
|
|
||||||
def errorView(request, idError):
|
def errorView(request, idError):
|
||||||
return HttpResponseRedirect( reverse('uds.web.views.error', kwargs = { 'idError': scrambleId(request, idError) }) )
|
return HttpResponseRedirect(reverse('uds.web.views.error', kwargs={'idError': scrambleId(request, idError)}))
|
||||||
|
|
||||||
|
|
||||||
def exceptionView(request, exception):
|
def exceptionView(request, exception):
|
||||||
|
@ -4,35 +4,38 @@
|
|||||||
# Copyright (c) 2012 Virtual Cable S.L.
|
# Copyright (c) 2012 Virtual Cable S.L.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright notice,
|
# * Redistributions of source code must retain the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer.
|
# this list of conditions and the following disclaimer.
|
||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||||
'''
|
'''
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import base64, random, string
|
import base64
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -41,6 +44,7 @@ logger = logging.getLogger(__name__)
|
|||||||
SCRAMBLE_SES = 'scrSid'
|
SCRAMBLE_SES = 'scrSid'
|
||||||
SCRAMBLE_LEN = 10
|
SCRAMBLE_LEN = 10
|
||||||
|
|
||||||
|
|
||||||
# Decorator to make easier protect pages
|
# Decorator to make easier protect pages
|
||||||
def transformId(view_func):
|
def transformId(view_func):
|
||||||
'''
|
'''
|
||||||
@ -63,8 +67,9 @@ def transformId(view_func):
|
|||||||
|
|
||||||
def scrambleId(request, id_):
|
def scrambleId(request, id_):
|
||||||
if request.session.get(SCRAMBLE_SES) == None:
|
if request.session.get(SCRAMBLE_SES) == None:
|
||||||
request.session[SCRAMBLE_SES] = ''.join(random.choice(string.letters) for _ in xrange(SCRAMBLE_LEN))
|
request.session[SCRAMBLE_SES] = ''.join(random.choice(string.letters) for _ in xrange(SCRAMBLE_LEN))
|
||||||
return base64.b64encode(str(id_) + request.session.get(SCRAMBLE_SES)).encode('hex')
|
return base64.b64encode(unicode(id_) + request.session.get(SCRAMBLE_SES)).encode('hex')
|
||||||
|
|
||||||
|
|
||||||
def unscrambleId(request, id_):
|
def unscrambleId(request, id_):
|
||||||
idd = base64.b64decode(id_.decode('hex'))
|
idd = base64.b64decode(id_.decode('hex'))
|
||||||
|
Loading…
Reference in New Issue
Block a user