Beispiel #1
0
    def post(self):
        idaux = -1
        accion = self.request.get('accion')
        if accion == "I":
            obj = Pantalla()
        elif accion == "A":
            idObject = int(self.request.get("id"))
            obj = Pantalla.get_by_id(idObject)
        obj.nombre = self.request.get('nombre')
        obj.titulo = self.request.get('titulo')
        obj.url = self.request.get('url')
        obj.orden = int(self.request.get('orden'))
        if self.request.get('padre'):
            idaux = int(self.request.get('padre'))
            obj.padre = Pantalla.get_by_id(idaux)
        if self.request.get('visible') == "true":
            obj.visible = True
        else:
            obj.visible = False
        if self.request.get('admin') == "true":
            obj.admin = True
        else:
            obj.admin = False
        key = obj.put()
        
        newObj = obj
        if self.request.get('padre'):
            newObj.padre.id = idaux
        newObj.id = key.id()

        self.response.out.write(json.dumps({ "obj" : utilGen.to_dict(newObj), "msj" : 1 }))
Beispiel #2
0
    def execute(self):
        method = self.request.method
        user = self.values['user']
        self.values['tab'] = '/admin'

        if not user or user.rol != 'admin':
            self.forbidden()
            return
        if method == 'GET':
            query = Cliente.all()
            arr = query.fetch(10000)
            if self.request.get('cons'):
                output = {}
                for obj in arr:
                    output[obj.key().id()] = utilGen.to_dict(obj)

                self.response.out.write(json.dumps(output))
            else:
                self.values["cols"] = 7
                self.values["arr"] = arr

                self.render("templates/module/admin/admin-clientes.html")
        elif method == 'POST':
            accion = self.request.get('accion')
            if accion == "I":
                obj = Cliente()
            elif accion == "A":
                idObject = int(self.request.get("id"))
                obj = Cliente.get_by_id(idObject)
            obj.nombre = self.request.get('nombre')
            obj.nFiscal = self.request.get('nFiscal')
            if self.request.get('nota'):
                obj.nota = self.request.get('nota')

            key = obj.put()

            newObj = obj
            newObj.id = key.id()

            self.response.out.write(
                json.dumps({
                    "obj": utilGen.to_dict(newObj),
                    "msj": 1
                }))
    def get(self):
        query = Mensaje.all()
        arr = query.fetch(10000)

        output = {}

        for obj in arr:
            output[obj.key().id()] = utilGen.to_dict(obj)
        
        self.response.out.write(json.dumps(output))
Beispiel #4
0
    def get(self):
        comentarios_query = Comentario.all().order('-date')
        comentarios_query.filter("author =", users.get_current_user())
        comentarios = comentarios_query.fetch(10000)

        output = {}
        for comentario in comentarios:
            comentario.desde = utilGen.tiempo(comentario.date)
            output[comentario.key().id()] = utilGen.to_dict(comentario)

        self.response.out.write(json.dumps(output))
Beispiel #5
0
 def get(self):
     if users.get_current_user() and users.is_current_user_admin():
         query = Pantalla.all()
         query.order("orden")
         arr = query.fetch(1000)
         
         output = []
         for obj in arr:
             output.append(utilGen.to_dict(obj))
         
         self.context["cols"] = 7
         self.context["arr"] = output
         
         self.render(__file__)
     else:
         self.redirect(self.context['config']['urlRoot'])
Beispiel #6
0
    def post(self):
        accion = self.request.get('accion')
        if accion == "I":
            obj = Cliente()
        elif accion == "A":
            idObject = int(self.request.get("id"))
            obj = Cliente.get_by_id(idObject)
        obj.nombre = self.request.get('nombre')
        obj.nFiscal = self.request.get('nFiscal')
        if self.request.get('nota'):
            obj.nota = self.request.get('nota')
        
        key = obj.put()
        
        newObj = obj
        newObj.id = key.id()

        self.response.out.write(json.dumps({ "obj" : utilGen.to_dict(newObj), "msj" : 1 }))
    def post(self):
        accion = self.request.get('accion')
        if accion == "I":
            obj = TipoMensaje()
        elif accion == "A":
            idObject = int(self.request.get("id"))
            obj = TipoMensaje.get_by_id(idObject)

        obj.cod = self.request.get('cod')
        obj.tipo = self.request.get('tipo')

        key = obj.put()

        newObj = obj
        newObj.id = key.id()

        self.response.out.write(
            json.dumps({
                "obj": utilGen.to_dict(newObj),
                "msj": 1
            }))
    def post(self):
        idaux = -1
        accion = self.request.get('accion')
        if accion == "I":
            obj = Mensaje()
        elif accion == "A":
            idObject = int(self.request.get("id"))
            obj = Mensaje.get_by_id(idObject)
            
        obj.cod = self.request.get('cod')
        obj.msj = self.request.get('msj')
        if self.request.get('lTipo'):
            idaux = int(self.request.get('lTipo'))
            obj.lTipo = TipoMensaje.get_by_id(idaux)
        key = obj.put()
        
        newObj = obj
        if self.request.get('lTipo'):
            newObj.lTipo.id = idaux
        newObj.id = key.id()

        self.response.out.write(json.dumps({ "obj" : utilGen.to_dict(newObj), "msj" : 1 }))
Beispiel #9
0
    def execute(self):
        method = self.request.method
        user = self.values['user']
        self.values['tab'] = '/admin'

        if not user or user.rol != 'admin':
            self.forbidden()
            return
        if method == 'GET':
            query = model.Pantalla.all()
            query.order("orden")
            arr = query.fetch(10000)
            if self.request.get('cons'):
                output = {}
                for obj in arr:
                    output[obj.key().id()] = utilGen.to_dict(obj)
                self.response.out.write(json.dumps(output))
            else:
                output = []
                for obj in arr:
                    output.append(utilGen.to_dict(obj))

                self.values["cols"] = 7
                self.values["arr"] = output

                self.render("templates/module/admin/admin-menu.html")
        elif method == 'POST':
            idaux = -1
            accion = self.request.get('accion')
            if accion == "I":
                obj = model.Pantalla()
            elif accion == "A":
                idObject = int(self.request.get("id"))
                obj = model.Pantalla.get_by_id(idObject)
            obj.nombre = self.request.get('nombre')
            obj.titulo = self.request.get('titulo')
            obj.url = self.request.get('url')
            obj.orden = int(self.request.get('orden'))
            if self.request.get('padre'):
                idaux = int(self.request.get('padre'))
                obj.padre = model.Pantalla.get_by_id(idaux)
            if self.request.get('visible') == "true":
                obj.visible = True
            else:
                obj.visible = False
            if self.request.get('admin') == "true":
                obj.admin = True
            else:
                obj.admin = False
            key = obj.put()

            newObj = obj
            if self.request.get('padre'):
                newObj.padre.id = idaux
            newObj.id = key.id()

            self.response.out.write(
                json.dumps({
                    "obj": utilGen.to_dict(newObj),
                    "msj": 1
                }))