예제 #1
0
 def delete_item(self, user):
     # Revisar si el usuario que realiza la actualización tiene credenciales de administrador
     # o si es el dueño de la membresia
     error, resp = self.get_role(self.id_grupo, user)
     if self.id_usuario is not user:
         if int(resp) is not 1 and int(resp) is not 2:
             return True, [
                 403, {
                     'message':
                     'No cuenta con los permisos para realizar esta acción',
                     'action': 'Realice otra consulta'
                 }
             ]
     s.delete(self)
     try:
         s.commit()
     except IntegrityError:
         s.rollback()
         s.flush()
         resp = [
             409, {
                 'errores': {
                     'message':
                     'La membresia no se puede eliminar',
                     'action':
                     'Elimine los elementos relacionados e intente de nuevo'
                 }
             }
         ]
         return True, resp
     resp = [200, {'message': 'La membresia se elimino correctamente'}]
     return False, resp
예제 #2
0
def empty_basket(user):
    standard_basket = get_standard_basket(user)
    for item in standard_basket:
        s.delete(item)
    generic_basket = get_generic_basket(user)
    for item in generic_basket:
        s.delete(item)
    s.commit()
    return {'success': True}, 200, {'ContentType': 'application/json'}
예제 #3
0
 def delete_item(self):
     s.delete(self)
     try:
         s.commit()
     except IntegrityError:
         s.rollback()
         s.flush()
         resp = [409, {'errores': {'message': 'La relacion no se puede eliminar',
                                   'action': 'Elimine los elementos relacionados e intente de nuevo'}}]
         return True, resp
     resp = [200, {'message': 'La relacion se elimino correctamente'}]
     return False, resp
예제 #4
0
 def delete_item(self, user):
     for miembro in self.membresia:
         if miembro.id_usuario is user:
             error, resp = miembro.get_role(self.id_grupo, user)
             if int(resp) is not 1 and int(resp) is not 2:
                 return True, [403, {'message': 'No cuenta con los permisos para realizar esta acción',
                                     'action': 'Realice otra consulta'}]
             s.delete(self)
             s.commit()
             resp = [200, {'message': 'El grupo se elimino correctamente'}]
             return False, resp
     return True, [403, {'message': 'No cuenta con los permisos para realizar esta acción',
                         'action': 'Realice otra consulta'}]
예제 #5
0
def empty_basket_by_user_id(basket):
    for item in basket:
        s.delete(item)
    s.commit()
    return {'success': True}, 200, {'ContentType': 'application/json'}
예제 #6
0
 def delete_item(self):
     s.delete(self)
     s.commit()
     return {'success': True}, 200, {'ContentType': 'application/json'}