def setUp(self): super(LocationTestCase, self).setUp() # OSes for os in ["win", "osx", "linux"]: OS.objects.create(name=os) # locations self.locations = {} for p in self.products: self.locations[p.name] = [] for os in OS.objects.all(): path = "/%s/location.%s.bin" % (p.name, os) loc = Location(product=p, os=os, path=path) loc.save() self.locations[p.name].append(loc)
def setUp(self): super(LocationTestCase, self).setUp() # OSes for os in ['win', 'osx', 'linux']: OS.objects.create(name=os) # locations self.locations = {} for p in self.products: self.locations[p.name] = [] for os in OS.objects.all(): path = '/%s/location.%s.bin' % (p.name, os) loc = Location(product=p, os=os, path=path) loc.save() self.locations[p.name].append(loc)
errno=101) try: product = Product.objects.get(name=prodname) os = OS.objects.get(name=osname) except (Product.DoesNotExist, OS.DoesNotExist), e: return xml.error(e) # do not make duplicates dupes = Location.objects.filter(product=product, os=os).count() if dupes: return xml.error('The specified location already exists.', errno=104) try: location = Location(product=product, os=os, path=path) location.save(force_insert=True) except Exception, e: return xml.error(e) locations = Location.objects.filter(pk=location.pk) # success: return the single new location to the user xml.prepare_locations(product, locations) return xml.render() @require_POST @csrf_exempt @is_staff_or_basicauth(HTTP_AUTH_REALM) def location_delete(request): """Remove a location from the DB""" xml = XMLRenderer()
errno=101) try: product = Product.objects.get(name=prodname) os = OS.objects.get(name=osname) except (Product.DoesNotExist, OS.DoesNotExist), e: return xml.error(e) # do not make duplicates dupes = Location.objects.filter(product=product, os=os).count() if dupes: return xml.error('The specified location already exists.', errno=104) try: location = Location(product=product, os=os, path=path) location.save(force_insert=True) except Exception, e: return xml.error(e) locations = Location.objects.filter(pk=location.pk) # success: return the single new location to the user xml.prepare_locations(product, locations) return xml.render() @require_POST @csrf_exempt @has_perm_or_basicauth("mirror.modify_location", HTTP_AUTH_REALM) def location_modify(request): xml = XMLRenderer()