def test_settings_default_to_not_connected(self): response = self.app.get(reverse("canto:settings"), user=self.user) self.assertContains(response, "You are not connected") self.assertContains( response, escape( get_canto_client().get_oauth_url( _get_oauth_state(self.user), response.request.url ) ), )
def get(self, request, **kwargs): try: start = int(request.GET.get("start", 0)) except ValueError: start = 0 results = get_canto_client().get_search_results( kwargs["query"], start, self.paginate_by, settings.CANTO_FILTER_SCHEMES ) return JsonResponse(results)
def dispatch(self, request, *args, **kwargs): self.canto_settings = _get_canto_settings() self.canto_client = get_canto_client(self.canto_settings) return super().dispatch(request, *args, **kwargs)
def get(self, request, **kwargs): results = get_canto_client().get_tree() return JsonResponse(results)
def canto_binary_view(request, url): # double slashed may be stripped by the web server if url.startswith('https:/') and not url.startswith('https://'): url = 'https://' + url[len('https:/'):] public_url = get_canto_client().get_public_url_for_binary(url) return HttpResponseRedirect(public_url)