def select(request): print '** select %s' % request if not request.user.is_authenticated(): raise Http404() print '** foo' if request.method == "POST": print '** bar' print '*** urls %s' % request.POST.get('id', '[]') urls = simplejson.loads(request.POST.get('id', '[]')) ids = dict(Record.objects.filter(source__in=urls, manager='dummy').values_list('source', 'id')) result = [] for url in urls: print '*** url %s' % url id = ids.get(url) if id: print '** baz' result.append(id) else: print '** qux' record = _dummy_record("blah", url) print '*** record = %s' % record result.append(record.id) r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)
def nix_select_record(request): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": nix = NasaImageExchange() urls = simplejson.loads(request.POST.get('id', '[]')) # find records that already have been created for the given URLs ids = dict(Record.objects.filter(source__in=urls, manager='nasaimageexchange').values_list('source', 'id')) result = [] for url in urls: id = ids.get(url) if id: result.append(id) else: record = nix.create_record(url) result.append(record.id) # rewrite request and submit to regular selection code r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)
def select(request): print '** select %s' % request if not request.user.is_authenticated(): raise Http404() print '** foo' if request.method == "POST": print '** bar' print '*** urls %s' % request.POST.get('id', '[]') urls = simplejson.loads(request.POST.get('id', '[]')) ids = dict( Record.objects.filter(source__in=urls, manager='dummy').values_list('source', 'id')) result = [] for url in urls: print '*** url %s' % url id = ids.get(url) if id: print '** baz' result.append(id) else: print '** qux' record = _dummy_record("blah", url) print '*** record = %s' % record result.append(record.id) r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)
def nix_select_record(request): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": nix = NasaImageExchange() urls = simplejson.loads(request.POST.get('id', '[]')) # find records that already have been created for the given URLs ids = dict( Record.objects.filter(source__in=urls, manager='nasaimageexchange').values_list( 'source', 'id')) result = [] for url in urls: id = ids.get(url) if id: result.append(id) else: record = nix.create_record(url) result.append(record.id) # rewrite request and submit to regular selection code r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)
def select(self, request): if not request.user.is_authenticated(): raise Http404() if request.method in "POST": # TODO: maybe drop the unused given-records portion of this postid = request.POST.get('id', '[]') imagesjs = json.loads(postid.strip("[]")) images = [self.searcher.getImage(imagesjs)] urlmap = {} for i in images: urlmap[i.record.get_absolute_url() if isinstance(i, ResultRecord) else i.url]=i urls = urlmap.keys() ids = dict(Record.objects.filter(source__in=urls, manager='unitedsearch').values_list('source', 'id')) result = [] for url in urls: id = ids.get(url) if id: result.append(id) else: i = urlmap[url].identifier record = self.record(i) result.append(record.id) r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r ans = select_record(request) return ans
def select(request, id, name): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": shared = SharedSearch(id) remote_ids = simplejson.loads(request.POST.get('id', '[]')) # find records that already have been created for the given URLs ids = dict( Record.objects.filter(source__in=remote_ids, manager=shared.get_source_id()).values_list( 'source', 'id')) result = [] for remote_id in remote_ids: id = ids.get(remote_id) if id: result.append(id) else: record = shared.create_record(remote_id) result.append(record.id) # rewrite request and submit to regular selection code r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r from rooibos.ui.views import select_record return select_record(request)
def select(self, request): if not request.user.is_authenticated(): raise Http404() if request.method in "POST": # TODO: maybe drop the unused given-records portion of this postid = request.POST.get('id', '[]') imagesjs = json.loads(postid.strip("[]")) images = [self.searcher.getImage(imagesjs)] urlmap = {} for i in images: urlmap[i.record.get_absolute_url( ) if isinstance(i, ResultRecord) else i.url] = i urls = urlmap.keys() ids = dict( Record.objects.filter(source__in=urls, manager='unitedsearch').values_list( 'source', 'id')) result = [] for url in urls: id = ids.get(url) if id: result.append(id) else: i = urlmap[url].identifier record = self.record(i) result.append(record.id) r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r ans = select_record(request) return ans
def flickr_select_record(request): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": f = FlickrSearch() remote_ids = simplejson.loads(request.POST.get('id', '[]')) # find records that already have been created for the given URLs ids = dict(Record.objects.filter(source__in=remote_ids, manager='flickr').values_list('source', 'id')) result = [] for remote_id in remote_ids: id = ids.get(remote_id) if id: result.append(id) else: record = f.create_record(remote_id) result.append(record.id) # rewrite request and submit to regular selection code r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)
def select(request, id, name): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": shared = SharedSearch(id) remote_ids = json.loads(request.POST.get('id', '[]')) # find records that already have been created for the given URLs ids = dict(Record.objects.filter( source__in=remote_ids, manager=shared.get_source_id()).values_list('source', 'id')) result = [] for remote_id in remote_ids: id = ids.get(remote_id) if id: result.append(id) else: record = shared.create_record(remote_id) result.append(record.id) # rewrite request and submit to regular selection code r = request.POST.copy() r['id'] = json.dumps(result) request.POST = r from rooibos.ui.views import select_record return select_record(request)
def select(self, request): if not request.user.is_authenticated(): raise Http404() if request.method == "POST": # TODO: maybe drop the unused given-records portion of this imagesjs = simplejson.loads(request.POST.get('id', '[]')) images = map(self.searcher.getImage, imagesjs) urlmap = dict([(i.record.get_absolute_url() if isinstance(i, ResultRecord) else i.url, i) for i in images]) urls = urlmap.keys() # map of relevant source URLs to record IDs that already exist ids = dict(Record.objects.filter(source__in=urls, manager='unitedsearch').values_list('source', 'id')) result = [] for url in urls: id = ids.get(url) if id: result.append(id) else: i = urlmap[url].identifier record = self.record(i) result.append(record.id) r = request.POST.copy() r['id'] = simplejson.dumps(result) request.POST = r return select_record(request)