]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
9 years agodocs: Update readthedocs URLs
Stephen Finucane [Mon, 29 Aug 2016 23:35:41 +0000 (00:35 +0100)] 
docs: Update readthedocs URLs

'readthedocs.io' is preferred to 'readthedocs.org'. Update all relevant
links.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agodocs: Document SELinux issues
Stephen Finucane [Mon, 29 Aug 2016 23:35:40 +0000 (00:35 +0100)] 
docs: Document SELinux issues

Initial Docker setup caused me some heartache on Fedora. Briefly
document the issues encountered to help other users.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
9 years agodocs: Make Docker the recommended install method
Stephen Finucane [Mon, 29 Aug 2016 23:35:39 +0000 (00:35 +0100)] 
docs: Make Docker the recommended install method

Docker is faster, lighter and "hipper" than Vagrant. Promote this
method over the Vagrant approach.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
9 years agodocker: Move 'docker' directory to 'tools'
Stephen Finucane [Mon, 29 Aug 2016 23:35:38 +0000 (00:35 +0100)] 
docker: Move 'docker' directory to 'tools'

...like the Vagrant scripts (which have been renamed also).

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Acked-by: Daniel Axtens <dja@axtens.net>
9 years agodocs: Add a paragraph about the django admin console
Florian Fainelli [Tue, 30 Aug 2016 01:12:15 +0000 (18:12 -0700)] 
docs: Add a paragraph about the django admin console

Provide a few hints about how to get initial access to the django admin
console as well as a few essential configuration hints regarding
projects and sites setup.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agopwclient: Unhardcode prints to ~/.pwclientrc
Florian Fainelli [Tue, 30 Aug 2016 01:12:14 +0000 (18:12 -0700)] 
pwclient: Unhardcode prints to ~/.pwclientrc

Even though the default location is ~/.pwclientrc, we can change it, so
use CONFIG_FILE wherever we can to make the prints match the actual file
location.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agotox: Disable F405
Stephen Finucane [Sat, 13 Aug 2016 22:43:04 +0000 (23:43 +0100)] 
tox: Disable F405

Recent versions of tox throw a lot of errors when using star-imports.
While these warnings are generally justified, the settings files
require this. Since 'noqa'-ing the offending lines would be rather
arduous, simply disable the warning instead.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agotrivial: Resolve PEP8 isues
Stephen Finucane [Sun, 21 Aug 2016 16:27:28 +0000 (17:27 +0100)] 
trivial: Resolve PEP8 isues

These were introduced with recent commits.

Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoEnable tox tests in Docker
Daniel Axtens [Tue, 9 Aug 2016 04:55:24 +0000 (14:55 +1000)] 
Enable tox tests in Docker

Update the entrypoint script to allow you to do --tox and
--quick-tox in the same way as --test and --quick-test.
Update the readme appropriately.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoPass more environment variables through to tox
Daniel Axtens [Tue, 9 Aug 2016 04:55:22 +0000 (14:55 +1000)] 
Pass more environment variables through to tox

In order to get tox tests working, we want db host, db port, home,
and xauthority.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoDon't import the REST framework if it is disabled
Daniel Axtens [Tue, 9 Aug 2016 04:55:21 +0000 (14:55 +1000)] 
Don't import the REST framework if it is disabled

In the disabled case, also stub out the APITestCase class.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agosettings: only enable the REST framework for Django 1.7+
Daniel Axtens [Tue, 9 Aug 2016 04:55:20 +0000 (14:55 +1000)] 
settings: only enable the REST framework for Django 1.7+

This helps with tox tests for Django 1.6

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoConvert RunSQL migration commands from list to strings
Daniel Axtens [Tue, 9 Aug 2016 04:55:19 +0000 (14:55 +1000)] 
Convert RunSQL migration commands from list to strings

The ability to use a list was added in Django 1.8 - compare

https://docs.djangoproject.com/en/1.7/ref/migration-operations/#runsql
https://docs.djangoproject.com/en/1.8/ref/migration-operations/#runsql

We don't need a list as we run only 1 SQL command. So convert to
strings. This helps unbreak Django 1.7.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoAdd Docker IP to whitelist for django-debug-toolbar
Daniel Axtens [Tue, 9 Aug 2016 04:38:45 +0000 (14:38 +1000)] 
Add Docker IP to whitelist for django-debug-toolbar

Yay for debugging with Docker.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoAllow use of Docker for development
Daniel Axtens [Tue, 9 Aug 2016 04:27:40 +0000 (14:27 +1000)] 
Allow use of Docker for development

This makes it possible to use Docker and docker-compose for development
as an alternative to Vagrant.

I quite liked vagrant a couple of years ago, but currently:

 * Trying to install VirtualBox on Ubuntu wants me to disable
   Secure Boot, and I don't want to do that.

 * Trying to use the libvirt plugin for vagrant requires I pick
   from a very small set of possible images, and requires that I
   install the upstream vagrant rather than the vagrant shipped
   with Ubuntu 16.04

 * I find docker containers faster to work with and more transparent.

So I've done the work to make docker work for Patchwork development.
This doesn't break or in any way interfere with using Vagrant, it just
provides an alternative.

It includes support for headless selenium tests using Chromium.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoPut test db host and port into env variables
Daniel Axtens [Tue, 9 Aug 2016 04:27:39 +0000 (14:27 +1000)] 
Put test db host and port into env variables

This is preparation for a Docker-based dev environment.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoIgnore *~ and #*# files.
Daniel Axtens [Tue, 9 Aug 2016 04:27:38 +0000 (14:27 +1000)] 
Ignore *~ and #*# files.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoFix test_login in test_user_browser.py
Daniel Axtens [Tue, 9 Aug 2016 04:27:37 +0000 (14:27 +1000)] 
Fix test_login in test_user_browser.py

It tried to use the pbkdf2 hash as the password. Use the username instead, as that
is what create_user sets.

Then it compared the test user username to testuser, rather than the username, which
is dynamically generated. Compare to the generated username.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agoFix failure to start with uninitalised database
Daniel Axtens [Tue, 9 Aug 2016 04:27:36 +0000 (14:27 +1000)] 
Fix failure to start with uninitalised database

An OptionalModelChoiceField will attempt to query the database to get choices
in its __init__ method. This fails if the database hasn't been initialised
yet. So, put that in a try/catch block. This lets things work through the
migration and loading of data from fixtures.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephenfinucane@hotmail.com>
9 years agosettings: Add PASSWORD_HASHER
Stephen Finucane [Wed, 13 Jul 2016 22:25:25 +0000 (23:25 +0100)] 
settings: Add PASSWORD_HASHER

This improves run time by a few seconds, and is worth having.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Tested-by: Andy Doan <andy.doan@linaro.org>
9 years agosettings: Regroup sections per upstream docs
Stephen Finucane [Wed, 13 Jul 2016 22:25:24 +0000 (23:25 +0100)] 
settings: Regroup sections per upstream docs

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agodocs: Alter heading of development install guide
Stephen Finucane [Wed, 13 Jul 2016 09:41:00 +0000 (10:41 +0100)] 
docs: Alter heading of development install guide

Divide the document into a Vagrant-based install section, and a manual
install section (+ footnotes).

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoxmlrpc: Don't load all Patches into memory
Stephen Finucane [Wed, 13 Jul 2016 09:57:29 +0000 (10:57 +0100)] 
xmlrpc: Don't load all Patches into memory

The way that reverse indexing of patches was implemented is broken.
At present, it will retrieve all patches in memory and return the
length from that data, then the slicing operation will then happen
without querying the DB and slice the results cached from the len()
evaluation. This is memory intensive, particularly for larger
instances.

Take advantage of Django's lazy loading to avoid this.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Suggested-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Address nits in 'utils'
Stephen Finucane [Fri, 15 Jul 2016 13:45:08 +0000 (14:45 +0100)] 
tests: Address nits in 'utils'

Simplify object creation through creation of the 'objects.create'
shortcut. In addition, remove an unncessary 'save' call.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Ignore multiple cover letters
Russell Currey [Fri, 15 Jul 2016 06:29:10 +0000 (16:29 +1000)] 
parsemail: Ignore multiple cover letters

If multiple cover letters are found, parsemail dies with a
MultipleObjectsReturned exception.  This is particularly problematic in
the middle of a parsearchive run, so just ignore multiple cover letters.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agouwsgi: Add python plugin
Russell Currey [Fri, 15 Jul 2016 05:42:09 +0000 (15:42 +1000)] 
uwsgi: Add python plugin

Given the documentation suggests using Ubuntu, and any Debian derivative
requires manually specifying plugins in uwsgi, add the python27 plugin to
the example uwsgi settings file.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agodocs/deployment: Fix systemctl commands
Russell Currey [Fri, 15 Jul 2016 04:46:28 +0000 (14:46 +1000)] 
docs/deployment: Fix systemctl commands

systemctl takes the name of the operation before the name of the service
so that you can do multiple things at once, i.e. "systemctl status nginx
postgresql".  Fix the ordering of the arguments.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agotests: Don't create model objects unless necessary
Stephen Finucane [Thu, 30 Jun 2016 17:30:27 +0000 (18:30 +0100)] 
tests: Don't create model objects unless necessary

Creating model objects when not required introduces unnecessary
overhead and delays the tests. Avoid this by only creating new objects
when one isn't provided for us already.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Remove 'default_states' fixture requirement
Stephen Finucane [Thu, 30 Jun 2016 17:30:26 +0000 (18:30 +0100)] 
tests: Remove 'default_states' fixture requirement

The 'default_states' fixture is used in many tests. However, the
'default_states' are merely suggestions for various States, and the
names themselves have no meaning from a patchwork perspective. In
addition, these fixtures significantly increase run time of the tests.

Resolve this by creating new State objects on demand, rather than
using versions provided by the fixture.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Remove 'defaults' class
Stephen Finucane [Thu, 30 Jun 2016 17:30:25 +0000 (18:30 +0100)] 
tests: Remove 'defaults' class

This is no longer needed and can be removed.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_rest_api'
Stephen Finucane [Thu, 30 Jun 2016 17:30:24 +0000 (18:30 +0100)] 
tests: Clean up 'test_rest_api'

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Move 'create_check' to utils
Stephen Finucane [Thu, 30 Jun 2016 17:30:23 +0000 (18:30 +0100)] 
tests: Move 'create_check' to utils

This is also useful for the REST API tests.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Rework and rename 'test_patchparser'
Stephen Finucane [Tue, 21 Jun 2016 21:20:10 +0000 (22:20 +0100)] 
tests: Rework and rename 'test_patchparser'

* Move some functions and variables from 'tests.utils', where they are
  only used in this file
* Rename and regroup some tests to make more sense
* Rename to 'test_parser', as this parses more than patches now

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_patchparser'
Stephen Finucane [Tue, 21 Jun 2016 20:45:06 +0000 (21:45 +0100)] 
tests: Clean up 'test_patchparser'

* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase
* Rename some functions to make more sense

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_xmlrpc'
Stephen Finucane [Tue, 21 Jun 2016 17:19:14 +0000 (18:19 +0100)] 
tests: Clean up 'test_xmlrpc'

* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_user_browser'
Stephen Finucane [Tue, 21 Jun 2016 17:16:28 +0000 (18:16 +0100)] 
tests: Clean up 'test_user_browser'

* Don't use hardcode routes: use the reverse function instead

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_user'
Stephen Finucane [Mon, 20 Jun 2016 10:43:32 +0000 (11:43 +0100)] 
tests: Clean up 'test_user'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Minimize duplication of code
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line
* Use underscore_case, rather than camelCase

This includes one trivial, albeit necessary, removal of an import from
'test_user_browser'.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_updates'
Stephen Finucane [Tue, 21 Jun 2016 17:04:56 +0000 (18:04 +0100)] 
tests: Clean up 'test_updates'

* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase
* Be consistent in how 'Patch.objects.get()' is called

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_tags'
Stephen Finucane [Tue, 21 Jun 2016 14:23:25 +0000 (15:23 +0100)] 
tests: Clean up 'test_tags'

* Make use of 'create_' helper functions
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Rename 'test_person'
Stephen Finucane [Tue, 21 Jun 2016 13:46:07 +0000 (14:46 +0100)] 
tests: Rename 'test_person'

Reflect the purpose of these tests - validation of the autocomplete
feature - in the filename.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_person'
Stephen Finucane [Tue, 21 Jun 2016 10:13:41 +0000 (11:13 +0100)] 
tests: Clean up 'test_person'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_notifications'
Stephen Finucane [Tue, 21 Jun 2016 08:20:42 +0000 (09:20 +0100)] 
tests: Clean up 'test_notifications'

* Make use of 'create_' helper functions
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_mboxviews'
Stephen Finucane [Mon, 20 Jun 2016 16:02:49 +0000 (17:02 +0100)] 
tests: Clean up 'test_mboxviews'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase
* Rename and regroup some tests to make more sense

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_mail_settings'
Stephen Finucane [Mon, 20 Jun 2016 15:11:44 +0000 (16:11 +0100)] 
tests: Clean up 'test_mail_settings'

* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase
* Don't use class level variables when not required

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_list'
Stephen Finucane [Mon, 20 Jun 2016 14:39:14 +0000 (15:39 +0100)] 
tests: Clean up 'test_list'

* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase
* Don't use list comprehension without generating a list: use a for
  loop instead

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_filters'
Stephen Finucane [Mon, 20 Jun 2016 14:26:02 +0000 (15:26 +0100)] 
tests: Clean up 'test_filters'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_expiry'
Stephen Finucane [Mon, 20 Jun 2016 14:19:40 +0000 (15:19 +0100)] 
tests: Clean up 'test_expiry'

* Make use of 'create_' helper functions
* Include every import on its own line
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_encodings'
Stephen Finucane [Mon, 20 Jun 2016 14:07:50 +0000 (15:07 +0100)] 
tests: Clean up 'test_encodings'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_detail'
Stephen Finucane [Mon, 20 Jun 2016 13:48:50 +0000 (14:48 +0100)] 
tests: Clean up 'test_detail'

* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_confirm'
Stephen Finucane [Mon, 20 Jun 2016 13:47:24 +0000 (14:47 +0100)] 
tests: Clean up 'test_confirm'

* Make use of 'create_' helper functions
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_checks'
Stephen Finucane [Mon, 20 Jun 2016 13:05:16 +0000 (14:05 +0100)] 
tests: Clean up 'test_checks'

* Make use of 'create_' helper
* Remove unneeded 'XXX.objects.delete()' calls (all objects are deleted
  on teardown of each test)
* Include every import on its own line

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Clean up 'test_bundles'
Stephen Finucane [Sun, 19 Jun 2016 19:42:57 +0000 (20:42 +0100)] 
tests: Clean up 'test_bundles'

* Don't use hardcode routes: use the reverse function instead
* Make use of 'create_' helper functions
* Minimize duplication of code
* Use underscore_case, rather than camelCase

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Add additional 'create_' helpers
Stephen Finucane [Mon, 20 Jun 2016 12:19:21 +0000 (13:19 +0100)] 
tests: Add additional 'create_' helpers

Add some additional object creation helpers, as a way to help
eventually remove the 'default' class.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Remove use of global value
Stephen Finucane [Sun, 19 Jun 2016 20:14:22 +0000 (21:14 +0100)] 
tests: Remove use of global value

This isn't needed, so remove it.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotests: Remove 'find_in_context'
Stephen Finucane [Sun, 19 Jun 2016 19:36:14 +0000 (20:36 +0100)] 
tests: Remove 'find_in_context'

The aformentioned function handled both dicts and lists in a request's
context field. Seeing as only dicts are ever returned, this is not
necessary.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agotemplates: Display '[owner]/[context]' for checks
Stephen Finucane [Fri, 24 Jun 2016 16:28:16 +0000 (17:28 +0100)] 
templates: Display '[owner]/[context]' for checks

This is useful for highlighting ownership of a check.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agomodels: Don't group checks with different owners
Stephen Finucane [Fri, 24 Jun 2016 16:28:15 +0000 (17:28 +0100)] 
models: Don't group checks with different owners

This prevents CIs from overriding the results of another CI by using
the same context.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agomodels: Return QuerySet from 'Patch.checks'
Stephen Finucane [Fri, 24 Jun 2016 16:28:14 +0000 (17:28 +0100)] 
models: Return QuerySet from 'Patch.checks'

Previously this returned a list. However, a QuerySet is more flexible
and is required to provide a generic check endpoint at some point in
the future.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agomodels: Return string from 'combined_check_status'
Stephen Finucane [Fri, 24 Jun 2016 16:28:13 +0000 (17:28 +0100)] 
models: Return string from 'combined_check_status'

Previously the 'combined_check_status' function returned the checks
enum integer for the status field. However, the string representation
is more meaningful and is the only representation seen by users at
moment. Change this function so it returns, for example, 'success'
instead of '1'.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agomodels: Use non-null slugs for 'Check.name'
Stephen Finucane [Fri, 24 Jun 2016 16:28:12 +0000 (17:28 +0100)] 
models: Use non-null slugs for 'Check.name'

The schema for 'Check' defines 'Check.name' as a 'CharField'. This is
less than ideal as names with spaces and special characters can't be
represented cleanly in URLs etc. We should use 'SlugField' instead.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Closes: #33
9 years agotests: Don't save multiple projects
Stephen Finucane [Tue, 28 Jun 2016 09:14:44 +0000 (10:14 +0100)] 
tests: Don't save multiple projects

There were issues introduced in the rebase of 'ee15585' that resulted
in two projects being saved with the same ID for one test, leading to
a test failure. Resolve this.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Allow projects to be retrieved by linkname
Andy Doan [Thu, 16 Jun 2016 21:13:25 +0000 (16:13 -0500)] 
REST: Allow projects to be retrieved by linkname

Building a user-friendly CLI becomes difficult when project-ids are
required. It also makes it almost impossible to work with the current
format of the .pwclientrc file.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST API: expose patch.checks
Andy Doan [Thu, 16 Jun 2016 21:13:24 +0000 (16:13 -0500)] 
REST API: expose patch.checks

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Patch.mbox_url
Andy Doan [Thu, 16 Jun 2016 21:13:23 +0000 (16:13 -0500)] 
REST: Add Patch.mbox_url

Provide a URL to the raw patch.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Patch Checks to the API
Andy Doan [Thu, 16 Jun 2016 21:13:22 +0000 (16:13 -0500)] 
REST: Add Patch Checks to the API

This exports patch checks via the REST API.

The drf-nested-routers package is used to handle the fact Checks are
nested under a Patch.

Security Constraints:
 * Anyone (logged in or not) can read all objects.
 * No one can update/delete objects.
 * Project maintainers and patch owners may create objects.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Patches to the API
Andy Doan [Thu, 16 Jun 2016 21:13:21 +0000 (16:13 -0500)] 
REST: Add Patches to the API

This exposes patches via the REST API.

Security Constraints:
 * Anyone (logged in or not) can read all objects.
 * No one can create/delete objects.
 * Project maintainers are allowed to update (ie "patch"
   attributes)

NOTE: Patch.save was overridden incorrectly and had to be
fixed to work with DRF.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Persons to the API
Andy Doan [Thu, 16 Jun 2016 21:13:20 +0000 (16:13 -0500)] 
REST: Add Persons to the API

This exports person objects via the REST API.

Security Constraints:
 * The API is read-only to authenticated users

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Users to the API
Andy Doan [Thu, 16 Jun 2016 21:13:19 +0000 (16:13 -0500)] 
REST: Add Users to the API

This exports user objects via the REST API.

Security Constraints:
 * The API is read-only to authenticated users

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoREST: Add Projects to the API
Andy Doan [Thu, 16 Jun 2016 21:13:18 +0000 (16:13 -0500)] 
REST: Add Projects to the API

This exports projects via the REST API.

Security Constraints:
 * Anyone (logged in or not) can read all objects.
 * No one can create/delete objects.
 * Project maintainers are allowed to update (ie "patch"
   attributes)

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Inspired-by: Damien Lespiau <damien.lespiau@intel.com>
9 years agoREST: Add base configuration hooks for a REST API
Andy Doan [Thu, 16 Jun 2016 21:13:17 +0000 (16:13 -0500)] 
REST: Add base configuration hooks for a REST API

This adds the ability to expose a REST API based on the Django REST
framework project. Since this project isn't packaged in most current
distributions, we ensure that its both installed and enabled before
trying to use it.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Inspired-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agodocs: Add prototype API specification
Stephen Finucane [Thu, 16 Jun 2016 21:13:16 +0000 (16:13 -0500)] 
docs: Add prototype API specification

Add specification for a REST API. It documents a number of endpoints
for the following objects/models:

* Projects
* People
* Patches
* Checks

The specification is provided in OpenAPI format [1]. This specification
can be used to automatically generate REST client libraries and to
validate the implemented API.

The API is currently read-only. It is expected that this will expanded
upon as the API grows.

[1] https://openapis.org/specification

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Signed-off-by: Andy Doan <andy.doan@linaro.org>
9 years agopost-receive: Use correct default installation path
Sven Eckelmann [Fri, 6 May 2016 12:36:06 +0000 (14:36 +0200)] 
post-receive: Use correct default installation path

The documentation recommends to use /opt/patchwork instead of
/srv/patchwork since version 1.1. This change should be reflected in the
PWDIR variable of the post-receive hook.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agopatchwork/templates: Fix path to delete button image
Sven Eckelmann [Fri, 6 May 2016 12:36:05 +0000 (14:36 +0200)] 
patchwork/templates: Fix path to delete button image

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agopost-receive.hook: rename detection
Jan Remmet [Tue, 19 Apr 2016 08:21:23 +0000 (10:21 +0200)] 
post-receive.hook: rename detection

patches which descripes renamed files show different hashes with git
show and pwclient. Use git show -C (Detect copies as well as renames.)

Signed-off-by: Jan Remmet <j.remmet@phytec.de>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoparsemail: Fix typo
Eric Engestrom [Mon, 2 May 2016 09:08:32 +0000 (10:08 +0100)] 
parsemail: Fix typo

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agopwclient: Fix typos
Eric Engestrom [Mon, 2 May 2016 09:08:31 +0000 (10:08 +0100)] 
pwclient: Fix typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agotests: Fix spelling mistakes and typos
Eric Engestrom [Mon, 2 May 2016 09:08:30 +0000 (10:08 +0100)] 
tests: Fix spelling mistakes and typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agotemplates: Fix spelling mistakes and typos
Eric Engestrom [Mon, 2 May 2016 09:08:29 +0000 (10:08 +0100)] 
templates: Fix spelling mistakes and typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agosql: Fix spelling mistakes and typos
Eric Engestrom [Mon, 2 May 2016 09:08:28 +0000 (10:08 +0100)] 
sql: Fix spelling mistakes and typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agodocs: Fix spelling mistakes and typos
Eric Engestrom [Mon, 2 May 2016 09:08:27 +0000 (10:08 +0100)] 
docs: Fix spelling mistakes and typos

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoparsearchive: Show breakdown of parsed mails
Stephen Finucane [Fri, 8 Apr 2016 17:13:27 +0000 (18:13 +0100)] 
parsearchive: Show breakdown of parsed mails

Since the parse_mail function now returns a single object, it is
easy to keep stats for the number and type of different mails parsed.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Always update Person.email
Stephen Finucane [Fri, 25 Mar 2016 15:42:04 +0000 (15:42 +0000)] 
parsemail: Always update Person.email

Patches applied using pwclient will always use the first name that has
been seen for a particular email address. While this is usually fine,
ot actually causes issues for people changing name without changing
email addresses or people changing the capitalization of their name.
Resolve this by always updating the Person object when we receive a
new submission or comment.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Closes: #24
9 years agoparsemail: Handle cover letters sent in reply
Stephen Finucane [Thu, 28 Jan 2016 12:15:55 +0000 (12:15 +0000)] 
parsemail: Handle cover letters sent in reply

Some people send cover letters (and therefore series) as replies to
existing series. Apply a second set of heuristics to cover this case:

* The message contains a '[0/n]' marker tag in the subject
* The message is not the root message, but the subject is unique, i.e.
  it is not a reply to a cover letter already stored in Patchwork

It is theoretically possible that the message could be a reply to a
cover letter that's been missed, but such occurences should be rare
and only get rarer the longer an instance is running.

Note that there is a third case which is not yet covered: a cover
letter with the same name but a different number of patches. This
will have to wait until series support is fully implemented.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Add cover letter parsing
Stephen Finucane [Sun, 6 Mar 2016 01:48:11 +0000 (01:48 +0000)] 
parsemail: Add cover letter parsing

Add support for both cover letters and comments on cover letters. This
works using the following heuristics:

* The message contains a '[0/n]' marker tag in the subject
* The message is the root message

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Be consistent in variable naming
Stephen Finucane [Sun, 6 Mar 2016 01:41:08 +0000 (01:41 +0000)] 
parsemail: Be consistent in variable naming

Don't refer to a variable using different names in different
locations unless there's a good reason to do so.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Use consistent 'find_' format
Stephen Finucane [Sun, 6 Mar 2016 01:29:13 +0000 (01:29 +0000)] 
parsemail: Use consistent 'find_' format

Most of the functions in the parsemail file work by taking a Mail
object, extracting the data they require, and formatting this data to
the expected format. This is not applied across the board, however.
Fix this oversight.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Restructure 'parse_content'
Stephen Finucane [Sat, 5 Mar 2016 22:50:51 +0000 (22:50 +0000)] 
parsemail: Restructure 'parse_content'

The 'parse_content' function is designed, as the title suggests, to
parse the content of an email. It should not be used to build objects
or similar. Move this functionality out of the function, updating the
unit tests as necessary.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Flatten 'try_decode' method
Stephen Finucane [Sat, 5 Mar 2016 17:07:36 +0000 (17:07 +0000)] 
parsemail: Flatten 'try_decode' method

This function is small, is only called once and isn't unit tested. Save
a few lines and some cognitive effort by folding it in where it's used.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agoparsemail: Extract building the list of mail references
Damien Lespiau [Sun, 25 May 2014 17:41:49 +0000 (18:41 +0100)] 
parsemail: Extract building the list of mail references

We'll need to figure out whether the mail we are parsing is the root of
the thread to automatically build series, and we'll need the list of
references for that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoparsemail: Parse series markers e.g. "1/12"
Damien Lespiau [Sat, 24 May 2014 17:49:39 +0000 (18:49 +0100)] 
parsemail: Parse series markers e.g. "1/12"

This can be used to identify cover letters, patches part of series,
length of series, etc.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoparsemail: Extract prefixes from subject
Damien Lespiau [Thu, 22 May 2014 17:03:13 +0000 (18:03 +0100)] 
parsemail: Extract prefixes from subject

The patch is a preparation step towards understanding series. It will be
handy to parse those prefixes, looking for 'x/n' to retrieve the order
of a patch in a series.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoviews: Integrate cover letter support
Stephen Finucane [Fri, 4 Mar 2016 15:24:00 +0000 (15:24 +0000)] 
views: Integrate cover letter support

There isn't really any need to list cover letters right now, seeing as
they're really only valuable in the context of series. However, if
someone requests a cover letter by ID then this should be displayed.
To this effect, add a new "covers" endpoint that can display the basic
elements of the cover letter. This includes redirects from/to the
"patches" endpoint.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
9 years agopep8: Resolve issues in settings file
Stephen Finucane [Fri, 8 Apr 2016 15:25:07 +0000 (16:25 +0100)] 
pep8: Resolve issues in settings file

Introduced in '2822854'.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agotests: Fix issue with user profile page test
Stephen Finucane [Fri, 8 Apr 2016 13:35:00 +0000 (14:35 +0100)] 
tests: Fix issue with user profile page test

The title of the user profile page was changed in 'b3d1917', but the
test wasn't updated to reflect this. Fix this.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agosettings: Remove hard coded login url value
Michael Wood [Thu, 12 Nov 2015 18:30:36 +0000 (18:30 +0000)] 
settings: Remove hard coded login url value

Use the url name for the login page rather than a hard coded value
this means that if you have patchwork in a prefix it will redirect
to the correct location without any additional configuration.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agomodels: Add Cover Letter support
Stephen Finucane [Fri, 25 Mar 2016 17:29:30 +0000 (17:29 +0000)] 
models: Add Cover Letter support

Cover letters contain useful information that should not be discarded.
Store them.

This is a prerequisite of series support.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agomodels: Split Patch into two models
Stephen Finucane [Fri, 25 Mar 2016 17:29:29 +0000 (17:29 +0000)] 
models: Split Patch into two models

There are a lot of similarities between cover letters and patches: so
many, in fact, that it would be helpful to occasionally treat them as
the same thing. Achieve this by extracting out the fields that would be
shared between a Patch and a hypothetical cover letter into a "sub
model". This allows us to do cool stuff like assigning comments to both
patches and cover letters or listing both patches and cover letters on
the main screen in a natural way.

The migrations for this are really the only complicated part. There are
three, broken up into schema and data migrations per Django customs,
and they works as follows:

* Rename the 'Patch' model to 'Submission', then create a subclass
  called 'Patch' that includes duplicates of the patch-specific fields
  of Submission (with changed names to prevent conflicts). Rename
  non-patch specific references to the renamed 'Submission' model
  as necessary.
* Duplicate the contents of the patch-specific fields from 'Submission'
  to 'Patch'
* Remove the patch-specific fields from 'Submission', renaming the
  'Patch' model to take their place. Update the patch-specific
  references to point the new 'Patch' model, rather than 'Submission'.

This comes at the cost of an additional JOIN per item on the main
screen, but this seems a small price to pay for the additional
functionality gained. To minimise this, however, caching will be added.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Signed-off-by: Andy Doan <andy.doan@linaro.org>
9 years agoutils: Rework how notifications are selected
Stephen Finucane [Fri, 25 Mar 2016 17:29:28 +0000 (17:29 +0000)] 
utils: Rework how notifications are selected

The current method of filtering valid patches from invalid ones is
effective, but incompatible with forthcoming rework that splits
the 'Patch' model into two models. Rework this, removing the
soon-to-be non-existant 'User.patch' reference.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoparsearchive: Fix default value of verbosity argument
Stephen Finucane [Fri, 1 Apr 2016 12:54:57 +0000 (13:54 +0100)] 
parsearchive: Fix default value of verbosity argument

With the current parsearchive.py, the default value for the verbosity
argument does not exist in the VERBOSITY_LEVELS dict, so we get:

  Traceback (most recent call last):
    File "./patchwork/bin/parsemail.py", line 569, in <module>
      sys.exit(main(sys.argv))
    File "./patchwork/bin/parsemail.py", line 555, in main
      logging.basicConfig(level=VERBOSITY_LEVELS[args['verbosity']])
  KeyError: 20

This change uses an actual key instead.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
9 years agoui: Add user bundle link into the dropdown menu
Stephen Finucane [Wed, 30 Mar 2016 18:03:53 +0000 (19:03 +0100)] 
ui: Add user bundle link into the dropdown menu

Since the link to TODOs (reviews pending) can already be seen there,
it makes sense to link to bundles also.

A divider is added to logically group these elements.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>