Example #1
0
    def view(self, request, **kwargs):
        """Perform read CRUD action"""

        def cb_sendback(result):
            self.sendback(request, result)

        UsersGroup.view().addCallback(cb_sendback)

        return server.NOT_DONE_YET
Example #2
0
    def update(self, request, **kwargs):
        """Perform update CRUD action"""

        def cb_sendback(result):
            self.sendback(request, result)

        UsersGroup.update(eval(kwargs.get('data')[0])).addCallback(cb_sendback)

        return server.NOT_DONE_YET
Example #3
0
    def create(data):
        """Creates a new Federacion object and a Users Group for its comite"""

        from application.model.UsersGroup import UsersGroup

        ugroup=UsersGroup()
        ugroup.name=unicode(data.get('group_name')[0].decode('utf8'))
        ugroup.description=unicode(data.get('group_desc')[0].decode('utf8'))
        ugroup.active=True

        Federacion.store.add(ugroup)
        Federacion.store.commit()

        federacion=Federacion()
        federacion.name=unicode(data.get('name')[0].decode('utf8'))
        federacion.comite_id=ugroup.id
        federacion.store.add(federacion)
        federacion.store.commit()
        return defer.succeed({'success' : True})
Example #4
0
    def get_schema_model(self, request, **kwargs):
        """Return the schema model UsersGroup architecture."""
        model_schema, model_view=UsersGroup.get_model_info()
        if model_schema==None:
            return json.dumps({
                "success" : False,
                "error" : "Unable to fetch a schema for model users_group"
            })

        return json.dumps({
            "success" : True,
            "model" : model_schema,
            "view" : model_view
        })
Example #5
0
 def cb_check(check):
     if not check:
         UsersGroup.destroy(kwargs.get('data')).addCallback(cb_sendback)
     else:
         return json.dumps({'success' : False, 'message' : 'No puede eliminar al comité de la Federación Local'})