コード例 #1
0
ファイル: rol.py プロジェクト: jorgeramirez/LPM
    def post(self, *args, **kw):
        """ Crea un nuevo rol plantilla o con contexto"""
        pp = None
        ctx = ""
        if kw["id_proyecto"]:
            ctx = "id_proyecto"
            pp = PoseePermiso('crear rol', id_proyecto=int(kw["id_proyecto"]))
        elif kw["id_fase"]:
            ctx = "id_fase"
            pp = PoseePermiso('crear rol', id_fase=int(kw["id_fase"]))
        elif kw["id_tipo_item"]:
            ctx = "id_tipo_item"
            pp = PoseePermiso('crear rol',
                              id_tipo_item=int(kw["id_tipo_item"]))
        else:
            pp = PoseePermiso('crear rol')

        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(self.action)

        #en caso de exito
        ok_url = u""
        #url que redirige al new y rellena los parametros que ya ingreso
        error_url = u"/rolesplantilla/new/"

        if ctx == "id_proyecto":
            ok_url = "/proyectos/%s/edit" % kw[ctx]
            error_url += "proyecto?{ctx}={val}".format(ctx=ctx, val=kw[ctx])
        elif ctx == "id_fase":
            ok_url = "/fases/%s/edit" % kw[ctx]
            error_url += "fase?{ctx}={val}".format(ctx=ctx, val=kw[ctx])
        elif ctx == "id_tipo_item":
            ok_url = "/tipositems/%s/edit" % kw[ctx]
            error_url += "ti?{ctx}={val}".format(ctx=ctx, val=kw[ctx])
        else:
            tipo = unicode(kw["tipo"].lower())
            ok_url = "/rolesplantilla/"
            if tipo.find(u"proyecto") >= 0:
                error_url += "proyecto?"
            elif tipo.find(u"fase") >= 0:
                error_url += "fase?"
            else:
                error_url += "ti?"

        #agregamos los parametros que ya ingreso el usuario.
        nombre = kw.get("nombre_rol", None).encode("utf-8")
        nombre_q = urllib.quote(nombre)
        desc = kw.get("descripcion", None).encode("utf-8")
        desc_q = urllib.quote(desc)
        params = "&nombre_rol=" + nombre_q + "&descripcion=" + desc_q
        error_url += params

        if not (kw.has_key("permisos") and kw["permisos"]):
            flash("Debe seleccionar al menos un permiso", 'warning')
            redirect(error_url)
        else:
            Rol.crear_rol(**kw)
            flash(u"El Rol se ha creado correctamente")
            redirect(ok_url)
コード例 #2
0
    def post(self, *args, **kw):
        """ Crea un nuevo rol plantilla o con contexto"""
        id_proyecto = UrlParser.parse_id(request.url, "proyectos")
        url_action = self.action % id_proyecto
        pp = PoseePermiso('crear rol', id_proyecto=id_proyecto)
        kw["id_proyecto"] = id_proyecto
        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(url_action)

        #url que redirige al new y rellena los parametros que ya ingreso
        error_url = url_action + "new"

        #agregamos los parametros que ya ingreso el usuario.
        nombre = kw.get("nombre_rol", None).encode("utf-8")
        nombre_q = urllib.quote(nombre)
        desc = kw.get("descripcion", None).encode("utf-8")
        desc_q = urllib.quote(desc)
        params = "?nombre_rol=" + nombre_q + "&descripcion=" + desc_q
        error_url += params

        if not (kw.has_key("permisos") and kw["permisos"]):
            flash("Debe seleccionar al menos un permiso", 'warning')
            redirect(error_url)
        else:
            Rol.crear_rol(**kw)
            flash(u"El Rol se ha creado correctamente")
            redirect(url_action)
コード例 #3
0
ファイル: roles_proyecto.py プロジェクト: jorgeramirez/LPM
    def post(self, *args, **kw):
        """ Crea un nuevo rol plantilla o con contexto"""
        id_proyecto = UrlParser.parse_id(request.url, "proyectos")
        url_action = self.action % id_proyecto
        pp = PoseePermiso('crear rol', id_proyecto=id_proyecto)
        kw["id_proyecto"] = id_proyecto
        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(url_action)

        #url que redirige al new y rellena los parametros que ya ingreso
        error_url = url_action + "new"
       
        #agregamos los parametros que ya ingreso el usuario.
        nombre = kw.get("nombre_rol", None).encode("utf-8")
        nombre_q = urllib.quote(nombre)
        desc = kw.get("descripcion", None).encode("utf-8")
        desc_q = urllib.quote(desc)
        params = "?nombre_rol=" + nombre_q + "&descripcion=" + desc_q
        error_url += params
        
        if not (kw.has_key("permisos") and kw["permisos"]):
            flash("Debe seleccionar al menos un permiso", 'warning')
            redirect(error_url)
        else:    
            Rol.crear_rol(**kw)
            flash(u"El Rol se ha creado correctamente")
            redirect(url_action)
コード例 #4
0
ファイル: rol.py プロジェクト: jorgeramirez/LPM
    def post(self, *args, **kw):
        """ Crea un nuevo rol plantilla o con contexto"""
        pp = None
        ctx = ""
        if kw["id_proyecto"]:
            ctx = "id_proyecto"
            pp = PoseePermiso('crear rol', id_proyecto=int(kw["id_proyecto"]))
        elif kw["id_fase"]: 
            ctx = "id_fase"
            pp = PoseePermiso('crear rol', id_fase=int(kw["id_fase"]))
        elif kw["id_tipo_item"]:
            ctx = "id_tipo_item"
            pp = PoseePermiso('crear rol', id_tipo_item=int(kw["id_tipo_item"]))
        else:
            pp = PoseePermiso('crear rol')
        
        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(self.action)

        #en caso de exito
        ok_url = u""
        #url que redirige al new y rellena los parametros que ya ingreso
        error_url = u"/rolesplantilla/new/" 

        if ctx == "id_proyecto":
            ok_url = "/proyectos/%s/edit" % kw[ctx]
            error_url += "proyecto?{ctx}={val}".format(ctx=ctx, val=kw[ctx])
        elif ctx == "id_fase":
            ok_url = "/fases/%s/edit" % kw[ctx]
            error_url += "fase?{ctx}={val}".format(ctx=ctx, val=kw[ctx]) 
        elif ctx == "id_tipo_item":
            ok_url = "/tipositems/%s/edit" % kw[ctx]
            error_url += "ti?{ctx}={val}".format(ctx=ctx, val=kw[ctx]) 
        else:
            tipo = unicode(kw["tipo"].lower())
            ok_url = "/rolesplantilla/"
            if tipo.find(u"proyecto") >= 0:
                error_url += "proyecto?"
            elif tipo.find(u"fase") >= 0:
                error_url += "fase?"
            else:
                error_url += "ti?"
        
        #agregamos los parametros que ya ingreso el usuario.
        nombre = kw.get("nombre_rol", None).encode("utf-8")
        nombre_q = urllib.quote(nombre)
        desc = kw.get("descripcion", None).encode("utf-8")
        desc_q = urllib.quote(desc)
        params = "&nombre_rol=" + nombre_q + "&descripcion=" + desc_q
        error_url += params
        
        if not (kw.has_key("permisos") and kw["permisos"]):
            flash("Debe seleccionar al menos un permiso", 'warning')
            redirect(error_url)
        else:    
            Rol.crear_rol(**kw)
            flash(u"El Rol se ha creado correctamente")
            redirect(ok_url)
コード例 #5
0
ファイル: rol.py プロジェクト: jorgeramirez/LPM
    def post(self, *args, **kw):
        """create a new record"""
        pp = PoseePermiso('crear rol')
        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(self.action)

        if (not kw.has_key('tipo')):
            kw["tipo"] = self.rol_tipo
        Rol.crear_rol(**kw)

        redirect(self.action)
コード例 #6
0
ファイル: rol.py プロジェクト: jorgeramirez/LPM
    def post(self, *args, **kw):
        """create a new record"""
        pp = PoseePermiso('crear rol')
        if not pp.is_met(request.environ):
            flash(pp.message % pp.nombre_permiso, 'warning')
            redirect(self.action)

        if (not kw.has_key('tipo')):
            kw["tipo"] = self.rol_tipo
        Rol.crear_rol(**kw)

        redirect(self.action)