Exemplo n.º 1
0
    def post(self, slug=None):
        form = ElementForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))
        data['categories'] = self.request.arguments.get('categories')[0]

        get_bucket = [
            b for b in MyAdminBucket.get('element').data or []
            if b['slug'] != data['slug']
        ]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('element', data=get_bucket)
        b1.add_index("slug_bin", data['slug'])
        b1.add_index("type_bin", data['type'])
        b1.add_index("cube_bin", data['cube'])
        b1.store()

        self.redirect('/admin/element')
Exemplo n.º 2
0
    def post(self, slug=None):
        form = CubeForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))
        data['sql'] = data.get('sql').replace("\n", "").replace("\r", "")
        data['sql'] = data.get('sql').replace("\t", " ")

        get_bucket = [b for b in MyAdminBucket.get('cube').data or []
                      if b['slug'] != data['slug']]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('cube', data=get_bucket)
        b1.add_index("slug_bin", data['slug'])
        b1.add_index("connection_bin", data['connection'])
        b1.store()

        Queue(connection=Redis()).enqueue_call(
            func='bin.mining.run',
            args=(slug,)
        )

        self.redirect('/admin/cube')
Exemplo n.º 3
0
    def post(self, slug=None):
        form = DashboardForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))

        get_bucket = [
            b for b in MyAdminBucket.get('dashboard').data or []
            if b['slug'] != data['slug']
        ]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('dashboard', data=get_bucket)
        """
        for k in data:
            b1.add_index("{}_bin".format(k), data[k])
        """
        b1.store()

        self.redirect('/admin/dashboard')
Exemplo n.º 4
0
    def post(self, slug=None):
        form = CubeForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))
        data['sql'] = data.get('sql').replace("\n", "").replace("\r", "")
        data['sql'] = data.get('sql').replace("\t", " ")

        get_bucket = [
            b for b in MyAdminBucket.get('cube').data or []
            if b['slug'] != data['slug']
        ]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('cube', data=get_bucket)
        b1.add_index("slug_bin", data['slug'])
        b1.add_index("connection_bin", data['connection'])
        b1.store()

        Queue(connection=Redis()).enqueue_call(func='bin.mining.run',
                                               args=(slug, ))

        self.redirect('/admin/cube')
Exemplo n.º 5
0
    def transform(self, data):
        sets = etree.Element('set')

        set_spec = etree.SubElement(sets, 'setSpec')
        set_spec.text = slugfy(data)
        
        set_name = etree.SubElement(sets, 'setName')
        set_name.text = data

        return sets
Exemplo n.º 6
0
    def transform(self, item):
        xml, data = item
        header = etree.SubElement(xml, 'header')
        if data.get('deleted'):
            header.attrib['status'] = 'deleted'

        identifier = etree.SubElement(header, 'identifier')
        identifier.text = data.get('identifier')

        datestamp = etree.SubElement(header, 'datestamp')
        date = data.get('datestamp')
        datestamp.text = date.strftime('%Y-%m-%d')

        set_spec = etree.SubElement(header, 'setSpec')
        set_spec.text = slugfy(data.get('publisher', ''))

        return (xml, data)
Exemplo n.º 7
0
    def post(self, slug=None):
        form = ConnectionForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))

        get_bucket = MyAdminBucket.get('connection').data or []
        get_bucket = [b for b in get_bucket if b['slug'] != data['slug']]

        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('connection', data=get_bucket)
        b1.store()

        self.redirect('/admin/connection')
Exemplo n.º 8
0
    def post(self, slug=None):
        form = ConnectionForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))

        get_bucket = MyAdminBucket.get('connection').data or []
        get_bucket = [b for b in get_bucket if b['slug'] != data['slug']]

        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('connection', data=get_bucket)
        b1.store()

        self.redirect('/admin/connection')
Exemplo n.º 9
0
    def post(self, slug=None):
        form = ElementForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))
        data['categories'] = self.request.arguments.get('categories')[0]

        get_bucket = [b for b in MyAdminBucket.get('element').data or []
                      if b['slug'] != data['slug']]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('element', data=get_bucket)
        b1.add_index("slug_bin", data['slug'])
        b1.add_index("type_bin", data['type'])
        b1.add_index("cube_bin", data['cube'])
        b1.store()

        self.redirect('/admin/element')
Exemplo n.º 10
0
    def post(self, slug=None):
        form = DashboardForm(self.request.arguments)
        if not form.validate():
            self.set_status(400)
            self.write(form.errors)

        data = form.data
        data['slug'] = slugfy(data.get('name'))

        get_bucket = [b for b in MyAdminBucket.get('dashboard').data or []
                      if b['slug'] != data['slug']]
        if get_bucket is None:
            get_bucket = []
        get_bucket.append(data)

        b1 = MyAdminBucket.new('dashboard', data=get_bucket)
        """
        for k in data:
            b1.add_index("{}_bin".format(k), data[k])
        """
        b1.store()

        self.redirect('/admin/dashboard')
Exemplo n.º 11
0
 def test_used_accents(self):
     self.assertEquals(u"testando-se-e-slugfy",
                       slugfy(u"Testando sé é slugfy"))
Exemplo n.º 12
0
 def test_generate_simples(self):
     self.assertEquals(u"testamdo-slugfy", slugfy(u"Testamdo slugfy"))