forked from getpatchwork/patchwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
views: Move and refactor patch-forms
Move patch forms in patch-list and detail page to a new template file patch-forms.html and move them to the top of the patch-list page to improve their discoverability. Refactor forms.py, __init__.py, patch.py, and test_bundles.py files so that the shared bundle form in patch-forms.html works for both the patch-list and patch-detail pages. In particular, the changes normalize the behavior of the error and update messages of the patch forms and updates tests to reflect the changes. Overall, these changes make patch forms ready for change and more synchronized in their behavior. More specifically: - Previously patch forms changes were separated between the patch-detail and patch-list pages. Thus, desired changes to the patch forms required changes to patch-list.html, submission.html, and forms.py. So, the most important benefit to this change is that forms.py and patch-forms.html become the two places to adjust the forms to handle form validation and functionality as well as UI changes. - Previously the patch forms in patch-list.html handled error and update messages through views in patch.py, whereas the patch forms in submission.html handled the messages with forms.py. Now, with a single patch forms component in patch-forms.html, forms.py is set to handle the messages and handle form validation for both pages. Signed-off-by: Raxel Gutierrez <[email protected]> Signed-off-by: Stephen Finucane <[email protected]> [stephenfin: Address merge conflicts]
- Loading branch information
1 parent
0cea2e4
commit 17726d7
Showing
7 changed files
with
135 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div class="patch-forms" id="patch-forms"> | ||
{% if patch_form %} | ||
<div id="patch-form-properties" class="patch-form"> | ||
<div id="patch-form-state"> | ||
{{ patch_form.state.errors }} | ||
{{ patch_form.state }} | ||
</div> | ||
<div id="patch-form-delegate"> | ||
{{ patch_form.delegate.errors }} | ||
{{ patch_form.delegate }} | ||
</div> | ||
<div id="patch-form-archive"> | ||
{{ patch_form.archived.errors }} | ||
{{ patch_form.archived.label_tag }} {{ patch_form.archived }} | ||
</div> | ||
<button class="patch-form-submit btn btn-primary" name="action" value="update"> | ||
Update | ||
</button> | ||
</div> | ||
{% endif %} | ||
{% if user.is_authenticated %} | ||
<div id="patch-form-bundle" class="patch-form"> | ||
<div id="create-bundle"> | ||
{{ create_bundle_form.name.errors }} | ||
{{ create_bundle_form.name }} | ||
<input class="patch-form-submit btn btn-primary" name="action" value="Create" type="submit"/> | ||
</div> | ||
{% if bundles %} | ||
<div id="add-to-bundle"> | ||
<select class="add-bundle" name="bundle_id"> | ||
<option value="" selected>Add to bundle</option> | ||
{% for bundle in bundles %} | ||
<option value="{{bundle.id}}">{{bundle.name}}</option> | ||
{% endfor %} | ||
</select> | ||
<input class="patch-form-submit btn btn-primary" name="action" value="Add" type="submit"/> | ||
</div> | ||
{% endif %} | ||
{% if bundle %} | ||
<div id="remove-bundle"> | ||
<input type="hidden" name="removed_bundle_id" value="{{bundle.id}}"/> | ||
<button class="patch-form-submit btn btn-primary" name="action" value="Remove"> | ||
Remove from bundle | ||
</button> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.