From: Jeremy Kerr Date: Mon, 8 Sep 2008 03:07:25 +0000 (+1000) Subject: Make pwclient visible thorugh site, and add .pwclientrc infrastructure X-Git-Url: https://git.ozlabs.org/?p=patchwork;a=commitdiff_plain;h=90d53c717d5d704da284cfa3b1484c11bd6c0bb1 Make pwclient visible thorugh site, and add .pwclientrc infrastructure Signed-off-by: Jeremy Kerr --- diff --git a/apps/patchwork/requestcontext.py b/apps/patchwork/requestcontext.py index e9a2675..c1440dd 100644 --- a/apps/patchwork/requestcontext.py +++ b/apps/patchwork/requestcontext.py @@ -20,6 +20,7 @@ from django.template import RequestContext from django.utils.html import escape from django.contrib.sites.models import Site +from django.conf import settings from patchwork.filters import Filters from patchwork.models import Bundle, Project @@ -67,6 +68,7 @@ class PatchworkRequestContext(RequestContext): self.update({ 'project': self.project, 'site': Site.objects.get_current(), + 'settings': settings, 'other_projects': len(self.projects) > 1 }) diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py index 20de7b8..f7c942a 100644 --- a/apps/patchwork/urls.py +++ b/apps/patchwork/urls.py @@ -58,6 +58,7 @@ urlpatterns = patterns('', if settings.ENABLE_XMLRPC: urlpatterns += patterns('', + (r'^pwclient.py/$', 'patchwork.views.pwclient'), (r'^project/(?P[^/]+)/pwclientrc/$', 'patchwork.views.pwclientrc'), ) diff --git a/apps/patchwork/views/base.py b/apps/patchwork/views/base.py index 8697ab4..b49b221 100644 --- a/apps/patchwork/views/base.py +++ b/apps/patchwork/views/base.py @@ -30,6 +30,7 @@ import django.core.urlresolvers from patchwork.requestcontext import PatchworkRequestContext from django.core import serializers from django.template.loader import render_to_string +from django.conf import settings def projects(request): context = PatchworkRequestContext(request) @@ -66,6 +67,13 @@ def pwclientrc(request, project_id): response.write(render_to_string('patchwork/pwclientrc', context)) return response +def pwclient(request): + context = PatchworkRequestContext(request) + response = HttpResponse(mimetype = "text/x-python") + response['Content-Disposition'] = 'attachment; filename=pwclient.py' + response.write(render_to_string('patchwork/pwclient.py', context)) + return response + def submitter_complete(request): search = request.GET.get('q', '') response = HttpResponse(mimetype = "text/plain") @@ -75,7 +83,12 @@ def submitter_complete(request): json_serializer.serialize(queryset, ensure_ascii=False, stream=response) return response -help_pages = {'': 'index.html', 'about/': 'about.html'} +help_pages = {'': 'index.html', + 'about/': 'about.html', + } + +if settings.ENABLE_XMLRPC: + help_pages['pwclient/'] = 'pwclient.html' def help(request, path): context = PatchworkRequestContext(request) diff --git a/templates/patchwork/help/pwclient.html b/templates/patchwork/help/pwclient.html new file mode 100644 index 0000000..efce79c --- /dev/null +++ b/templates/patchwork/help/pwclient.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} + +{% block title %}Command-line client{% endblock %} +{% block heading %} - Command-line client{% endblock %} + +{% block body %} + +

pwclient is the command-line client for patchwork. Currently, +it provides access to some read-only features of patchwork, such as downloading +and applying patches.

+ +

To use pwclient, you will need:

+
    +
  • The pwclient.py + program (11kB, python script)
  • +
  • (optional) a .pwclientrc file in your home directory.
  • +
+ +

You can create your own .pwclientrc file. Each +patchwork project +provides a sample linked from the 'project info' page.

+ +{% endblock %} diff --git a/templates/patchwork/project.html b/templates/patchwork/project.html index f29540c..49ceb57 100644 --- a/templates/patchwork/project.html +++ b/templates/patchwork/project.html @@ -28,5 +28,12 @@ {{n_patches}} (+ {{n_archived_patches}} archived) + +{% if settings.ENABLE_XMLRPC %} +

Sample patchwork +client configuration for this project: .pwclientrc.

+{% endif %} {% endblock %} diff --git a/templates/patchwork/pwclient.py b/templates/patchwork/pwclient.py new file mode 120000 index 0000000..c196eb3 --- /dev/null +++ b/templates/patchwork/pwclient.py @@ -0,0 +1 @@ +../../apps/patchwork/bin/pwclient.py \ No newline at end of file diff --git a/templates/patchwork/pwclientrc b/templates/patchwork/pwclientrc index d7c1c32..7aaf346 100644 --- a/templates/patchwork/pwclientrc +++ b/templates/patchwork/pwclientrc @@ -6,8 +6,10 @@ [base] url: http://{{site.domain}}{% url django_xmlrpc.views.handle_xmlrpc %} project: {{ project.linkname }} +{% comment %} {% if user.is_authenticated %} [auth] user: {{ user.username }} password: {% endif %} +{% endcomment %}