]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/base.py
views: Replace 'mimetype' with 'content_type'
[patchwork] / apps / patchwork / views / base.py
index 634e383084817afe6403dda31378dad0e60c4017..6d7dd13a67db3e6735ce08c9262a58fbd5e48701 100644 (file)
@@ -43,18 +43,18 @@ def pwclientrc(request, project_id):
     project = get_object_or_404(Project, linkname = project_id)
     context = PatchworkRequestContext(request)
     context.project = project
-    if request.is_secure():
+    if settings.FORCE_HTTPS_LINKS or request.is_secure():
         context['scheme'] = 'https'
     else:
         context['scheme'] = 'http'
-    response = HttpResponse(mimetype = "text/plain")
+    response = HttpResponse(content_type = "text/plain")
     response['Content-Disposition'] = 'attachment; filename=.pwclientrc'
     response.write(render_to_string('patchwork/pwclientrc', context))
     return response
 
 def pwclient(request):
     context = PatchworkRequestContext(request)
-    response = HttpResponse(mimetype = "text/x-python")
+    response = HttpResponse(content_type = "text/x-python")
     response['Content-Disposition'] = 'attachment; filename=pwclient'
     response.write(render_to_string('patchwork/pwclient', context))
     return response
@@ -86,12 +86,25 @@ def confirm(request, key):
 
 def submitter_complete(request):
     search = request.GET.get('q', '')
-    response = HttpResponse(mimetype = "text/plain")
-    if len(search) > 3:
-        queryset = Person.objects.filter(Q(name__icontains = search) |
-                                         Q(email__icontains = search))
-        json_serializer = serializers.get_serializer("json")()
-        json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
+    limit = request.GET.get('l', None)
+    response = HttpResponse(content_type = "text/plain")
+
+    if len(search) <= 3:
+        return response
+
+    queryset = Person.objects.filter(Q(name__icontains = search) |
+                                     Q(email__icontains = search))
+    if limit is not None:
+        try:
+            limit = int(limit)
+        except ValueError:
+            limit = None
+
+    if limit is not None and limit > 0:
+            queryset = queryset[:limit]
+
+    json_serializer = serializers.get_serializer("json")()
+    json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
     return response
 
 help_pages = {'':           'index.html',