def test_tags(self): """docstring for test_tags""" # self._load_data() resources = Resource.objects(tags='red') # print [(i.title, i.tags) for i in Resource.objects] # print 'red resources: ', resources self.assertEqual(len(resources), 3) # 6 tags contain blue OR red resources = Resource.objects(tags__in=['blue', 'red']) self.assertEqual(len(resources), 6) # 2 tags contain blue AND red resources = Resource.objects(tags__all=['blue', 'red']) self.assertEqual(len(resources), 2)
def fix_urls(request): for resource in Resource.objects(uri__startswith='http://new.gramp'): resource.uri = resource.uri.replace('//new.', '//www.') resource.save() messages.success(request, 'URLs have been fixed.') return HttpResponseRedirect(reverse('cab'))
def fix_urls(request): for resource in Resource.objects(uri__startswith="http://new.gramp"): resource.uri = resource.uri.replace("//new.", "//www.") resource.save() messages.success(request, "URLs have been fixed.") return HttpResponseRedirect(reverse("cab"))
def test_curations(self): """docstring for test_curations""" acct = Account.objects.get(name="Derek Hoy") print acct, acct.id print list(Resource.objects(curations__owner=acct)) curations = Curation.objects(owner=acct).order_by('-item_metadata__last_modified') for c in curations: print c.owner, c.item_metadata.last_modified, c.resource
def test_curations(self): """docstring for test_curations""" acct = Account.objects.get(name="Derek Hoy") print acct, acct.id print list(Resource.objects(curations__owner=acct)) curations = Curation.objects(owner=acct).order_by('-item_metadata__last_modified') for c in curations: print c.owner, c.item_metadata.last_modified, c.resource.title