| from types import StringTypes |
| from django.contrib.auth import authenticate |
| from core.models import Image |
| if isinstance(filter, StringTypes) and filter.isdigit(): |
| if isinstance(filter, int): |
| images = Image.objects.filter(id=filter) |
| elif isinstance(filter, StringTypes): |
| images = Image.objects.filter(name=filter) |
| elif isinstance(filter, dict): |
| images = Image.objects.filter(**filter) |
| def add_image(auth, fields={}): |
| def delete_image(auth, filter={}): |
| def get_images(auth, filter={}): |
| user = authenticate(username=auth.get('username'), |
| password=auth.get('password')) |
| images = _get_images(filter) |