| from types import StringTypes |
| from django.contrib.auth import authenticate |
| from core.models import Node |
| if isinstance(filter, StringTypes) and filter.isdigit(): |
| if isinstance(filter, int): |
| nodes = Node.objects.filter(id=filter) |
| elif isinstance(filter, StringTypes): |
| nodes = Node.objects.filter(name=filter) |
| elif isinstance(filter, dict): |
| nodes = Node.objects.filter(**filter) |
| def add_node(auth, fields={}): |
| def delete_node(auth, filter={}): |
| def update_node(auth, id, fields={}): |
| def get_nodes(auth, filter={}): |
| user = authenticate(username=auth.get('username'), |
| password=auth.get('password')) |
| nodes = _get_nodes(filter) |