summaryrefslogtreecommitdiff
path: root/patchwork/forms.py
Commit message (Collapse)AuthorAge
* forms: Use a captcha on the registration form.add-captchaChristopher Baines2021-02-27
| | | | This should help avoid spam registration requests.
* templates: Use form.as_table in registration template.Christopher Baines2021-02-27
| | | | | This should make changes to the registration form easier. I'm particularly thinking about adding in the Django simple math captcha.
* forms: Remove LoginFormStephen Finucane2020-04-23
| | | | | | This should have been removed in commit f1e089f773. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Don't attempt to evaluate State at startupStephen Finucane2019-08-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As was designed, starting the interpreter would cause the State model and its entries to be evaluated. This was an issue if, for example, the model had been modified and you were attempting to apply the migration. Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) ... File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1199, in _set_queryset self.widget.choices = self.choices File "/home/patchwork/patchwork/patchwork/forms.py", line 157, in _get_choices super(OptionalModelChoiceField, self)._get_choices()) File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py", line 1143, in __len__ return (len(self.queryset) + (1 if self.field.empty_label is not None else 0)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 232, in __len__ self._fetch_all() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1118, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 53, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 899, in execute_sql raise original_exception django.db.utils.OperationalError: (1054, "Unknown column 'patchwork_state.slug' in 'field list'") Resolve this by moving the evaluation into '__init__', meaning it will only occur when a new form is created. Signed-off-by: Stephen Finucane <stephen@that.guru>
* trivial: Use implicit string concatenationStephen Finucane2018-10-26
| | | | | | | | | | | While pycodestyle's W504 ("line break after binary operator") error was recently disabled, it did highlight a number of areas where explicit string concatenation was being used despite it not be necessary. Fix these while we're aware of them. [1] http://pycodestyle.pycqa.org/en/latest/intro.html#error-codes Signed-off-by: Stephen Finucane <stephen@that.guru>
* Update license headerStephen Finucane2018-09-19
| | | | | | | | | | | | | The FSF has a new address since 2005 that hasn't been noted in any file except the COPYING file. Rather than fix these, simply remove the headers in favour of a SPDX license header. IANAL but the combination of the header and the COPYING file in source should resolve this issue. Note that copyright notices are retained. Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #210 Reviewed-by: Veronika Kabatova <vkabatov@redhat.com>
* 'mpe mode': click to copy patch IDsDaniel Axtens2017-04-15
| | | | | | | | | | | | | If 'Show Patch IDs' is turned on in settings, add an extra column to the patch list, with buttons showing the patch IDs. The buttons copy the patch IDs to the clipboard. JavaScript inspired by https://github.com/Triforcey/clip-j and many many StackOverflow answers. Suggested-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Stephen Finucane <stephen@that.guru>
* forms: 'False' != FalseStephen Finucane2016-12-23
| | | | | | | | | Forms cast boolean values to strings, and attempting to coerce using the 'bool' function does not correctly return them to true boolean values. Correct this by doing a string comparison instead. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 0abde97aa ("forms: Use TypedChoiceField")
* forms: Trivial reshuffling of fileStephen Finucane2016-12-18
| | | | | | Group all "optional" fields. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Use TypedChoiceFieldStephen Finucane2016-12-18
| | | | | | This resolves a TODO. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Remove duplicationStephen Finucane2016-12-18
| | | | | | | DelegateField and OptionalDelegateField were basically duplicates of other fields. Make use of parameters and remove them. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Remove unused args in formsStephen Finucane2016-12-18
| | | | | | | | There were a couple of forms that offered configurabilty, but this configurability wasn't used anywhere. Simplify things and remove any related code. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Tighten validation on BundleFormStephen Finucane2016-11-19
| | | | | | | The 'name' field of 'Bundle' cannot be blank, so update the form to reflect this. Signed-off-by: Stephen Finucane <stephen@that.guru>
* models: Remove 'UserProfile.primary_project'Stephen Finucane2016-10-10
| | | | | | | This field was unused and has been for a long time (pre-0.9.0). Signed-off-by: Stephen Finucane <stephen@that.guru> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
* Revert "Allow assigning of any user as delegate"Stephen Finucane2016-10-08
| | | | | | | | | This reverts commit e0fd7cd91a5fbe0a0077c46bea870ccd09c8920d. This change does not scale with a larger number of lists, and clearly needs more work. Revert until such a time as this is carried out. Signed-off-by: Stephen Finucane <stephen@that.guru>
* trivial: Don't use non-Pythonic namesStephen Finucane2016-09-25
| | | | | Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com> Reviewed-by: Daniel Axtens <dja@axtens.net>
* Fix failure to start with uninitalised databaseDaniel Axtens2016-08-20
| | | | | | | | | | | 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>
* models: Split Patch into two modelsStephen Finucane2016-04-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* pep8: Resolve some issues with lambda functionsStephen Finucane2016-02-05
| | | | Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* Allow assigning of any user as delegateStephen Finucane2016-01-25
| | | | | | | | | | | | | | | Currently, Patchwork only allows to delegate patches to developers who are registered as "maintainers" of the project in Patchwork or set up as autodelegate "targets". This is a bit annoying as "maintainers" in the Patchwork sense have the power to change the state of *any* patch. Allow delegation of patches to developers who are not the submitter of the patch in question, a maintainer of the project or an autodelegate "target". This request is documented here: https://lists.ozlabs.org/pipermail/patchwork/2015-July/001351.html Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* forms: Allow the delegate field to keep its current valueLaurent Pinchart2016-01-19
| | | | | | | | | | | | | | When a patch is delegated at parse time (either through the X-Patchwork-Hint mail header or through delegation rules), the delegate might not be in the list of project maintainers. Add the current delegate to the list of acceptable values for the delegate field to allow the current value to be kept when editing the patch. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Acked-by: Stephen Finucane <stephen.finucane@intel.com>
* pep8: Manually resolve remaining issuesStephen Finucane2015-12-03
| | | | | | | | | | | | | | | | The 'autopep8' tool can't do everything, and it is necessary to resolve some final issues. Most of these issues fall under the following categories: E501 line too long E241 multiple spaces after ',' F401 'module' imported but unused F841 local variable 'name' is assigned to but never used It is also necessary to insert '# noqa' comments to hide some F403 errors ('unable to detect undefined names') where 'import *' is useful. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* pep8: Autoresolve most PEP8 issuesStephen Finucane2015-12-03
| | | | | | ...using the 'autopep8' tool. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* trivial: Reorder importsStephen Finucane2015-12-03
| | | | | | | | Imports are easier to read if they are grouped by type (standard library, third party, application) and organised alphabetically. Make it so. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* py3: Add required 'future' importsStephen Finucane2015-12-03
| | | | | | | | | | These are quite limited as patchwork only supports Python 2.6+. As such, only the 'print_function' and 'absolute_import' statements are required. Found using 'modernize' Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
* Move to a more recent django project structureJeremy Kerr2015-05-27
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>