Example #1
0
    def index(self):

        if user.is_admin:
            labels = (
                'First Name',
                'Last Name',
                'Username',
                'Password',
                'Token',
                'Expires',
                'Action',
            )
            content = browse(registrations, labels=labels)
            return page(content, title='Registrations')

        messages = ul(get_errors(fields), Class='wrong')

        form = fields.edit()

        agreements = """
        By registering, I agree to the <dz:site_name> <a
        href="/terms.html">Terms of Use</a> and <a href="/privacy.html">Privacy
        Policy</a>.
        """

        content = load('registration.html')
        return page(
            content.format(fill=locals()),
            css=load('style.css'),
        )
Example #2
0
    def test_runs(self):
        root = os.path.dirname(__file__)
        join = os.path.join

        start = zoom.load(join(root, 'sql/mysql_run_test_start.sql'))
        self.db.runs(start)
        assert 'run_test_table' in self.db.get_tables()

        finish = zoom.load(join(root, 'sql/mysql_run_test_finish.sql'))
        self.db.runs(finish)
        assert 'run_test_table' not in self.db.get_tables()
Example #3
0
    def jqplot_theme(self):
        """jqPlot Theme

        Example showing how to add a theme to a jqPlot chart.
        """

        from random import randint
        from zoom.vis.jqplot import line

        page_title = 'JQPlot Line Chart'

        xaxis_label = 'Month'

        legend = 'North', 'South'
        labels = (
            'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
        )

        data = [(m, randint(1, 100), randint(1, 100)) for m in labels]
        options = dict(axes=dict(xaxis=dict(label=xaxis_label, tickInterval=2)))

        theme = 'chocolate', load('assets/chocolate-line.js')

        visualization = line(data, legend=legend, title='Page Hits',
                             theme=theme, options=options)

        return locals()
Example #4
0
    def jqplot_theme(self):
        """jqPlot Theme

        Example showing how to add a theme to a jqPlot chart.
        """

        from random import randint
        from zoom.vis.jqplot import line

        page_title = 'JQPlot Line Chart'

        xaxis_label = 'Month'

        legend = 'North', 'South'
        labels = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
                  'Sep', 'Oct', 'Nov', 'Dec')

        data = [(m, randint(1, 100), randint(1, 100)) for m in labels]
        options = dict(axes=dict(
            xaxis=dict(label=xaxis_label, tickInterval=2)))

        theme = 'chocolate', load('assets/chocolate-line.js')

        visualization = line(data,
                             legend=legend,
                             title='Page Hits',
                             theme=theme,
                             options=options)

        return locals()
Example #5
0
def get_info_page(request):

    pathname, _ = os.path.split(__file__)

    html = zoom.load(os.path.join(pathname, 'instance.html'))
    css = zoom.load(os.path.join(pathname, 'instance.css'))

    values = dict(request=request,
                  node=platform.node(),
                  date=datetime.datetime.now(),
                  version=zoom.__version__,
                  css=css,
                  elapsed=request.elapsed * 1000)

    content = html.format(**values)

    return content
Example #6
0
def load_document(name, args={}):
    filename = 'docs/{}.md'.format(name)
    feature, messages, body = '', '', ''
    if os.path.exists(filename):
        body = markdown(load(filename).format(**args))
        if BREAKER in body:
            parts = body.split(BREAKER)
            if len(parts) == 3:
                feature, messages, body = parts
            elif len(parts) == 2:
                feature, body = parts
    return feature, messages, body
Example #7
0
def load_document(name, args={}):
    filename = 'docs/{}.md'.format(name)
    feature, messages, body = '', '', ''
    if os.path.exists(filename):
        body = markdown(load(filename).format(**args))
        if BREAKER in body:
            parts = body.split(BREAKER)
            if len(parts) == 3:
                feature, messages, body = parts
            elif len(parts) == 2:
                feature, body = parts
    return feature, messages, body
Example #8
0
    def test_runs_with_blank_lines(self):
        root = os.path.dirname(__file__)
        join = os.path.join
        self.db.run(join(root, 'sql/mysql_run_test_start.sql'))

        cmd = """
        select * from run_test_table where name=%s;
        """
        self.db.runs(cmd, 'pat jones')

        finish = zoom.load(join(root, 'sql/mysql_run_test_finish.sql'))
        self.db.runs(finish)
        assert 'run_test_table' not in self.db.get_tables()
Example #9
0
    def __init__(self, layers=None, **kwargs):
        Leaflet.__init__(self, **kwargs)
        self.actions = ""

        layer_objects = []
        for layer in layers or []:
            if isinstance(layer, ThematicLayer):
                thematic_layer = layer
            else:
                geo = layer['data']
                thematic_layer = ThematicLayer(layers=isfile(geo) and load(geo) or geo)
                thematic_layer.description = layer['title']
                thematic_layer.key = layer.get('key', 'KEY')
            layer_objects.append(thematic_layer)

        layer_objects = filter(bool, layer_objects)
        if layer_objects:
            self.overlays(layer_objects)
            self.actions = self.actions + """var fg = L.featureGroup([%s]); %s.fitBounds(fg.getBounds());""" % (layer_objects[0].ref, self.ref)
Example #10
0
"""
    content images
"""

import io
import os

import zoom
from zoom.buckets import Bucket

css = zoom.load('views/images.css')


class SystemImage(zoom.Record):
    pass


Image = SystemImage


def image_response(name, data):
    """provide an image response based on the file extension"""
    _, ext = os.path.splitext(name.lower())
    if ext == '.png':
        return zoom.response.PNGResponse(data)
    elif ext == '.jpg':
        return zoom.response.JPGResponse(data)
    elif ext == '.gif':
        return zoom.response.GIFResponse(data)