summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/views
Commit message (Collapse)AuthorAgeFilesLines
* Move to a more recent django project structureJeremy Kerr2015-05-278-1493/+0
| | | | | | | | | | This change updates patchwor to the newer project struture: we've moved the actual application out of the apps/ directory, and the patchwork-specific templates to under the patchwork application. This gives us the manage.py script in the top-level now. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: Replace 'mimetype' with 'content_type'Stephen Finucane2015-05-033-6/+6
| | | | | | | | | | | | | | Passing 'mimetype' to 'HttpResponse' is deprecated in 1.6 and removed in Django 1.7. Among other things, this causes some unit tests to fail when using Django 1.7. Its replacement - 'content_type' - is available in Django 1.5+. This can be seen here: https://docs.djangoproject.com/en/1.5/ref/request-response/#django.http.HttpResponse.__init__ This is therefore a like-for-like replacement. Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Resolve removed 'AUTH_PROFILE_MODULE' settingStephen Finucane2015-05-032-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'AUTH_PROFILE_MODULE' setting, and the 'get_profile()' method on the 'User' model are removed in Django 1.7. This causes errors when using Patchwork with Django 1.7+. There are three changes necessary: * Replace profile model's 'ForeignKey' with a 'OneToOneField' * Remove all 'get_profile()' calls * Delete 'AUTH_PROFILE_MODULE' settings from 'settings.py' These changes are discussed here: http://deathofagremmie.com/2014/05/24/retiring-get-profile-and-auth-profile-module/ Django 1.6 also introduces two other notable changes: * The 'XViewMiddleware' module has been moved * A new test runner has been introduced It is not possible to fix these issues without breaking compatibility with Django 1.5. As a result they have been ignored and must be resolved in a future release. Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* xmlrpc: support filtering by 'archived'Brian Norris2015-03-221-0/+1
| | | | | Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* xmlrpc: include UNIX mbox 'From ' header in patch_get_mbox()Brian Norris2015-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This function is misleadingly named 'mbox'; the contents do not begin with a proper 'From xxx <date>' separator line. (Notably, the mbox format does not have an authoritative standard, but at least this basic 'separator' construct is noted in http://tools.ietf.org/html/rfc4155.) The Message.as_string() function takes an optional [unixfrom] boolean argument. Let's use it, like we do everywhere else (including in the web interface 'mbox' link). Among other things, this means that we can straightforwardly concatenate the output of patch_get_mbox(), and more tools can use this output as-is. Example header: >From patchwork Fri Nov 21 18:24:29 2014 ... Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* xmlrpc: add 'archived' status to patch summaryBrian Norris2015-03-221-0/+1
| | | | | | | This will now show up in 'pwclient info'. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/xmlrpc: fix xmlrpc delegate filteringJohannes Berg2015-03-221-0/+3
| | | | | | | | | | | | Trying to use pwclient list -d 'johannes@sipsolutions.net' doesn't result in any patches listed - it seems that the filter is constructed wrongly on the xmlrpc server side (going by how the submitter filter is done.) Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: fix patch_to_mbox() for postscriptAndreas Bießmann2014-07-241-5/+2
| | | | | | | | | Before we changed the comment 'some comment\n---\n some/file | 1 +' to 'some comment\n\n---\nsome/file | 1 +\n'. Now we pass this comment unchanged. Signed-off-by: Andreas Bießmann <andreas@biessmann.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/generic_list: reduce number of queries in list renderingJeremy Kerr2014-05-081-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we do two database queries per patch on a list view; one to retrieve the submitter, and one for the state. This patch adds a .select_related to fetch for the submitter and state, and a .defer() to prevent loading large amounts of text data from the patch content and headers. This gives a significant reduction in the work per request. For a paginated list view (ie 100 patches per page): before after User 1344 ms 228 ms System 170 ms 25 ms Total 1514 ms 253 ms Elapsed 1605 ms 274 ms Context switch (vol) 4206 40 Context switch (invol) 326 75 SQL queries 212 15 Longest query 13 ms 5 ms Total query time 121 ms 20 ms Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/xmlrpc: request.raw_post_data has been deprecatedJeremy Kerr2014-05-071-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Defer Person creation/linkage until registration is confirmedJeremy Kerr2014-04-221-0/+8
| | | | | | | | We currently create Person objects when a registration is submitted, not when it is confirmed. This can lead to stale Person objects for unconfirmed registrations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/order: Apply default ordering as secondaryJeremy Kerr2014-04-211-1/+1
| | | | | | | | | | If we're ordering by a certain non-default field, then the ordering of patches with that same field will be arbitrary. This change applies the default as a secondary ordering, so we're not left with an arbitrary sub-order. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add a config option to FORCE_HTTPS_LINKSKonstantin Ryabitsev2013-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | In situations where SSL is terminated at the load-balancer, we cannot rely on guessing the scheme based on whether patchwork itself was accessed via http or https, since the last-leg is always going to be done over http. Unfortunately, wrongly using http:// URLs results in unusable .pwclientrc files, since xmlrpc does not handle http->https redirects and instead displays a traceback. This change introduces a FORCE_HTTPS_LINKS option, which forces pwclientrc links to always return "https" regardless of how the project itself is accessed. It appears that the http/https check is currently only used for generating pwclientrc -- a lot of other places seem to hardcode "http://" and rely on the server to transparently upgrade the connection. This is not a secure approach (it allows for MITM and SSL-Strip attacks) and therefore all places currently hardcoding http://{{site.domain}} and similar should be switched to using the "sheme" variable, the same as done for generating pwclientrc files. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/base: Implement limit for submitter autocompletionJeremy Kerr2013-10-131-5/+18
| | | | | | | Add a limit parameter to the completion view, and pass a limit of 20 results in the javascript. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/base: Include email addresses in submitter autocomplete searchJeremy Kerr2013-10-131-1/+3
| | | | | | | | Currently, we only search names, which is a problem for Person objects with only an email address set. This change includes the email addresses in the search. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Don't use total_seconds for python < 2.7Konstantin Ryabitsev2013-06-161-2/+2
| | | | | | | | | | The total_seconds function was added to datetime in python-2.7. For compatibility with previous versions of python, use its suggested equivalent (except drop microseconds, since we don't care about them in this context). Signed-off-by: Konstantin Ryabitsev <mricon@kernel.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/mbox: Use Date: header from original messageJeremy Kerr2013-06-101-2/+4
| | | | | | | | | | | Since we use UTC for internal date storage, we lose the timestamp info from the original patch submissions. This means that the mbox views (which are typically passed through to SCM commit logs) lose the timezone information. This change uses the Date header from the original message, if possible. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: Move mbox handling from models to viewsJeremy Kerr2013-06-104-5/+92
| | | | | | | | Mbox generation is related to views, not the models themselves. This change creates a patch_to_mbox function in the views/ directory, which the actual view handlers use instead of Patch.mbox(). Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* bundles: Don't display 'Change order' button on public bundle viewJeremy Kerr2013-04-211-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* bundles: Remove separate public bundle viewsJeremy Kerr2013-04-201-50/+63
| | | | | | | | | | | | Having two views for bundles (public and non-public) can cause confusion when bundle owners want to share a URL; it's not obvious that the private URL isn't shareable. This change removes the private URLs, and puts all bundles under the /bundle/<username>/<bundlename>/ URL space. For non-public bundles, this will just 404 for non-owners. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* forms: Only pass post data to multiplepatchform if that was what was submittedJeremy Kerr2012-12-301-1/+8
| | | | | | | | | | | | | When updating bundles, we get a spurious error message in the MultiplePatchForm; it's performing validation on the blank form data. This change only passes the post data to the MuliplePatchForm if we detect (through data['form']) that it was the MultiplePatchForm that was submitted. This fixes the current testsuite failure. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* tests/bundle: Add bundle update tests, fix missing action behaviourJeremy Kerr2012-12-301-0/+3
| | | | | | | Add a couple of tests for the bundle update views. This exposes a problem with no action is specified, so fix this too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/bundle: Allow downloading public bundle as mboxSimo Sorce2012-12-301-5/+13
| | | | | | | | | | | Downloading single patches anonymously is allowed, we may as well allow downloading public bundles as mboxes. This patch also changes the file name to be bundle-<id>-<name>.mbox so that the file name is unique even if bundle names are reused. Signed-off-by: Simo Sorce <idra@samba.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* xmlrpc: Avoid trying to marshall None for people with no nameDoug Anderson2012-12-301-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a person sent patches with no real name, they may have None for their name. In this case just use their email address as their name. The previous pwclient error that would show up looks like: $ pwclient list -w anonymous@example.com Traceback (most recent call last): File ".../pwclient", line 631, in <module> main() File ".../pwclient", line 570, in main action_list(rpc, filt, submitter_str, delegate_str, series_str) File ".../pwclient", line 316, in action_list ids = person_ids_by_name(rpc, submitter_str) File ".../pwclient", line 241, in person_ids_by_name people = rpc.person_list(name, 0) File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__ return self.__send(self.__name, args) File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request verbose=self.__verbose File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request return self.parse_response(response) File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response return u.close() File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close raise Fault(**self._stack[0]) xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:cannot marshal None unless allow_none is enabled"> Signed-off-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Merge branch 'notifications'Jeremy Kerr2011-09-193-13/+220
|\
| * Add email opt-out systemJeremy Kerr2011-04-143-3/+131
| | | | | | | | | | | | | | | | | | | | | | We're going to start generating emails on patchwork updates, so firstly allow people to opt-out of all patchwork communications. We do this with a 'mail settings' interface, allowing non-registered users to set preferences on their email address. Logged-in users can do this through the user profile view. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
| * registration: use EmailConfimation rather than separate registration appJeremy Kerr2011-04-142-1/+54
| | | | | | | | | | | | | | | | | | | | Since we have infrastructure for email confirmations, we no longer need the separate registration app. Requires a migration script, which will delete all inactive users, including those newly added and pending confirmation. Use carefully. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
| * Use generic email confirmation objectJeremy Kerr2011-04-142-11/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | Rather than having a UserPerson-specific confirmation, add an EmailConfirmation object to allow multiple types of confirmations (eg, opt-out requests in future). To do this, we use a view (patchwork.views.confirm) that will call the type-specific view with the confirmation object. Also, add tests to check that the User/Person linkage system works. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* | xmlrpc: do slice before patch_to_dictJeremy Kerr2011-07-181-1/+1
|/ | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* models: Project.is_editable to check whether a user has edit rightsGuilherme Salgado2011-04-141-2/+1
| | | | | | | This is to replace the couple of places where we duplicate this same check. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: Refactor generic_list() to make it less complicatedGuilherme Salgado2011-04-141-17/+56
| | | | | | | | | 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>
* Remove a bunch of unused variablesGuilherme Salgado2011-03-304-5/+3
| | | | | Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Use the 'in' operator instead of dict.has_key(), which has been deprecatedGuilherme Salgado2011-03-302-3/+3
| | | | | Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Replace tab characters with spaces on .py filesGuilherme Salgado2011-03-301-2/+2
| | | | | Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Remove unused importsGuilherme Salgado2011-03-156-32/+9
| | | | | | | | | 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>
* views: use id__in = get_patch_ids() to get the modified patch setJeremy Kerr2011-03-091-7/+1
| | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Remove unused templates and some code for processing themGuilherme Salgado2011-03-081-17/+0
| | | | | | | | These seem to be what was used in the past to archive/unarchive and delete patches. Signed-off-by: Guilherme Salgado <guilherme.salgado@linaro.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Replace tab in indentation with spaceDirk Wallenstein2011-02-112-12/+12
| | | | | Signed-off-by: Dirk Wallenstein <halsmit@t-online.de> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/patch: remove unused codeJeremy Kerr2010-09-021-52/+0
| | | | | | | The number of times I've edited this code and wondered why nothing changes... Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/user: don't refer to request.POST for non-POST requestsJeremy Kerr2010-08-111-1/+2
| | | | | | | We're ending up wth form errors due to using request.POST, which is empty. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: implement CSRF protectionJeremy Kerr2010-08-101-0/+2
| | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views/bundle/public: Lookup on userJeremy Kerr2010-07-191-1/+2
| | | | | | | | | | | 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>
* views: Use request scheme in sample pwclientrc file.Jeremy Kerr2010-03-191-0/+4
| | | | | | Adapt the pwclientrc file to suit the current scheme in use. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pwclient,xmlrpc: Specify project for patch hash lookupsJeremy Kerr2009-10-221-0/+10
| | | | | | | | | | | | 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. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* xmlrpc: Remove duplicated "name" fieldAbhishek Kulkarni2009-08-151-1/+0
| | | | | | | | Remove duplicated "name" field from the list of allowed fields for a patch list filter in the XML RPC interface. Signed-off-by: Abhishek Kulkarni <adkulkar@umail.iu.edu> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* views: separate project views into separate fileJeremy Kerr2009-04-052-14/+39
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Fix non-ascii character encodings on xmlrpc interfaceMauro Carvalho Chehab2009-02-151-6/+6
| | | | | | | | | | The current xmlrpc interface dies when trying to retrieve patches that contain non-ascii characters. This change uses unicode() rather than str(). Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Bundle reordering supportJeremy Kerr2009-02-082-8/+27
| | | | | | | | Bundles can now be reordered and saved. Add dependency on jquery in INSTALL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* [views] Allow Order class to be user-editableJeremy Kerr2009-02-081-3/+5
| | | | | | | This can be enabled with the editable_order parameter to generic_list Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Use 'from' import for urlresolversJeremy Kerr2009-01-071-3/+2
| | | | | | | Some python installs can't seem to find the fully-qualified module, so use the 'from'-style import instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>