Jeremy Kerr [Mon, 18 Jul 2011 13:46:08 +0000 (21:46 +0800)]
xmlrpc: do slice before patch_to_dict
Currently, we map patch_to_dict before we slice the results (to only
return max_count patches). This means that we hacve to retrieve all
patches, then throw away most of the results of the map.
This change does the slice on the patches before the map, letting django
do a LIMIT-ed query instead.
Jeremy Kerr [Tue, 19 Apr 2011 05:18:45 +0000 (13:18 +0800)]
settings: Use multiple-DB-style format for default settings
The DATABASE_* settings have been deprecated in django 1.3, replaced by
the multiple-database style format (introduced in 1.2, which patchwork
requires anyway).
This change modifies the default settings.py to use the new format.
forms: Fix MultipleBooleanField.to_python when the field value is missing
If you write a test for, say, the bundle form of a patch list, you'd
still have to specify the 'no change' value to other form (e.g. the
multiple update one) fields using MultipleBooleanField or else it'd
raise a ValueError when field.clean() is called as part of
form._get_errors().
Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
views: Refactor generic_list() to make it less complicated
When a form is submitted it now delegates to separate processing
functions according to the action. Apart from being more readable it's
now a lot easier to add extra forms for processing lists of patches.
Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Use autodiscover and the new way to hook AdminSite into the URLconf.
AdminSite.root() will be removed in Django-1.3 as noted here:
http://docs.djangoproject.com/en/dev/internals/deprecation/
Signed-off-by: Dirk Wallenstein <halsmit@t-online.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
parser: Get rid of some code duplication in parsemail-batch.sh
Change parsemail-bash.sh to uses parsemail.sh (instead of parsemail.py),
as the former sets the required environment variables that were being
set in parsemail-batch.sh.
Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
This is so that we can use static analysis tools like pyflakes to find
undefined names (and other common mistakes we often make) without being
swamped with unused imports warnings.
Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Wed, 9 Mar 2011 05:20:10 +0000 (13:20 +0800)]
views: use id__in = get_patch_ids() to get the modified patch set
Currently, we generic_list processes patches in order of the patch_id:X
parameter, which is arbitrarily decided by the browser.
By using id__in, we get patches sorted by the default Patch model
ordering. This means that the (arbitrary) order of get_patch_ids()
doesn't affect the ordering of patches that we process, and bundles
are created with a reasonable default patch order.
Dirk Wallenstein [Wed, 16 Feb 2011 08:41:30 +0000 (08:41 +0000)]
tests: Support execution of single tests
Django does not use suite() when executing single tests. Importing all
tests directly into __init__.py has the same effect as the replaced
version of suite().
Signed-off-by: Dirk Wallenstein <halsmit@t-online.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Dirk Wallenstein [Wed, 26 Jan 2011 05:12:29 +0000 (05:12 +0000)]
parser: Recognize mail headers for delegate and state
Introduce two new Patchwork mail headers that determine the initial
state and delegate of a patch. They take a state name as displayed in
Patchwork and the email address of the wanted delegate. An example:
Dirk Wallenstein [Sat, 15 Jan 2011 01:16:21 +0000 (01:16 +0000)]
models: Implement __unicode__ in models instead of __str__
According to the Django documentation at [1] it is recommended to
implement __unicode__ and not __str__. Django's model base class
provides a __str__ method that will use the __unicode__ method and
convert to utf-8. Also, every text value returned from the DB through
the model is unicode.
It is now possible to edit Patches and Persons that have values with
non-ASCII characters through the admin interface.
pwclient: fix handling of UTF-8 char in submitter name
This patch fixes following bug in 'list':
---8<---
# pwclient list -p uboot -w andreas.devel | grep New
Traceback (most recent call last):
File "/Users/andreas/bin/pwclient", line 463, in <module>
main()
File "/Users/andreas/bin/pwclient", line 411, in main
action_list(rpc, filt, submitter_str, delegate_str)
File "/Users/andreas/bin/pwclient", line 182, in action_list
(person['name'], person['email'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in
position 32: ordinal not in range(128)
--->8---
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Tue, 10 Aug 2010 04:11:40 +0000 (12:11 +0800)]
views: implement CSRF protection
Since we've got the csrf token present, we may as well check it for
requests.
We're using RequestContext already (via PatchworkRequestContext), so we
just need to switch it on in the settings, and add an exemption on the
xmlrpc interface.
templates: Add CSRF (cross-site request forgery) values to form posts
This is a fairly simple patch, basically it does what the error message
told me to do:
"add In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL."
Signed-off-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Martin Krafft [Sun, 31 Jan 2010 01:32:45 +0000 (02:32 +0100)]
lib/apache2: Add WSGI Handler
Patchwork/Django can be run directly with WSGI, which is bound to be
faster and less complex than FastCGI. This patch provides the necessary
Apache configuration and the WSGI handler, as well as an update to the
docs.
Since python-flup is deprecated and WSGI supersedes FastCGI, it should
be(come) the preferred method. Hence I documented it first.
For the xmlrpc interface to work with WSGI, the HTTP authorization
information needs to be passed to the WSGI handler. This is done by
setting WSGIPassAuthorization On in the apache2 config file snippet.
Martin Krafft [Sun, 31 Jan 2010 02:03:10 +0000 (03:03 +0100)]
docs: Document password-based pgsql login
As an alternative to ident-based authentication for PostgreSQL, one can
use password-based authentication. This patch adds the alternative to
the docs.
Signed-off-by: martin f. krafft <madduck@madduck.net> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Mon, 19 Jul 2010 06:17:35 +0000 (08:17 +0200)]
views/bundle/public: Lookup on user
Currently, the public bundle view is only looking up bundles by their
name. This may return multiple bundles if two users have bundles with
the same name.
This change adds the user to the bundle lookup.
Reported-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Junio C Hamano [Tue, 3 Nov 2009 17:17:06 +0000 (09:17 -0800)]
Adjust postgres "grant all" script to new name of bundle table
Since c105cb0 (Initial bundle reordering support, 2009-01-29), the
patchwork_bundle_patches table and its associated id sequence does not
exist. The script to grant appropriate privileges was not updated when
this change was made, and causes the set-up procedure described in
docs/INSTALL to fail.
This change adjust the script to grant appropriate access rights to
match the change in the DB schema.
Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Jeremy Kerr [Thu, 22 Oct 2009 21:46:46 +0000 (17:46 -0400)]
pwclient,xmlrpc: Specify project for patch hash lookups
We may see the same hash for two patches if one is sent to two lists
tracked by patchwork.
This change adds a new xmlrpc method, patch_get_by_project_hash, which
adds the linkname parameter to the lookup. We need to add a new method
instead of replacing patch_get_by_hash, to avoid breaking existing
pwclient apps.
Thomas Gleixner [Thu, 17 Sep 2009 11:23:09 +0000 (13:23 +0200)]
Add Message-Id to xmlrpc patch_get_mbox headers
While trying to utilize patchwork for my daily workflow I noticed that
the xmlrpc patch_get_mbox function does not add the original message
id to the headers. That forces me to look it up with the browser which
is a major PITA.
Add Message-Id to the headers.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
pwclient works fine viewing utf-8 messages, if you don't try to redirect stdout.
However, if you do things like pwclient view 5063 >/tmp/patch, it fails
due to the weird character handling logic in python:
Traceback (most recent call last):
File "/usr/local/bin/pwclient", line 446, in ?
main()
File "/usr/local/bin/pwclient", line 411, in main
print s
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 249: ordinal not in range(128)
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Eduardo Habkost [Thu, 13 Aug 2009 21:09:17 +0000 (18:09 -0300)]
tests: check some edge cases in bundle reordering tests
While testing BundleReorderTest, I felt like adding more test cases to
check if reordering is touching only the right patches on the bundle.
This increases the number of patches on the test bundle to 5, and
changes the code to do the following tests:
- Reorder all patches
- Reorder only the first 3 patches
- Reorder only the last 3 patches
- Reorder only the middle 3 patches
- On all above tests, check if the 'order' field on the BundlePatch
objects is still consistent
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>