def location_delete(request): """Remove a location from the DB""" xml = XMLRenderer() loc_id = request.POST.get('location_id', None) if not loc_id: return xml.error('location_id is required.', errno=101) try: location = Location.objects.get(pk=loc_id) except Location.DoesNotExist: return xml.error('No location found.', errno=102) except Exception, e: return xml.error(e) try: location.delete() except Exception, e: return xml.error(e) return xml.success('Deleted location: %s' % location) class XMLRenderer(object): """Render API data as XML""" def __init__(self): self.doc = minidom.Document() def toxml(self): return self.doc.toxml(encoding='utf-8')
def location_delete(request): """Remove a location from the DB""" xml = XMLRenderer() loc_id = request.POST.get('location_id', None) if not loc_id: return xml.error('location_id is required.', errno=101) try: location = Location.objects.get(pk=loc_id) except Location.DoesNotExist: return xml.error('No location found.', errno=102) except Exception, e: return xml.error(e) try: location.delete() except Exception, e: return xml.error(e) return xml.success('Deleted location: %s' % location) @require_POST @csrf_exempt @has_perm_or_basicauth("mirror.create_update_alias", HTTP_AUTH_REALM) def create_update_alias(request): """Create or update an alias for a product""" xml = XMLRenderer() try: