Add ids to table cells, and rename selectors using hyphen delimited strings to clean up and improve readability of patch-list.html. Also, create a partial template errors.html for errors that render with form submission.These changes make the code healthier, ready for change, and overall more readable.
No user-visible change should be noticed. Signed-off-by: Raxel Gutierrez <ra...@google.com> --- htdocs/css/style.css | 16 ++-- htdocs/js/bundle.js | 12 +-- .../patchwork/partials/patch-list.html | 84 +++++++++---------- patchwork/templates/patchwork/submission.html | 6 +- patchwork/tests/views/test_bundles.py | 20 ++--- patchwork/tests/views/test_patch.py | 6 +- patchwork/views/__init__.py | 4 +- patchwork/views/bundle.py | 2 +- 8 files changed, 75 insertions(+), 75 deletions(-) diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 9156aa6e..4ad503da 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -134,25 +134,25 @@ table.pw-list > thead { background-color: white; } -a.colinactive, a.colactive { +a.col-inactive, a.col-active { color: black; text-decoration: none; } -a.colinactive:hover { +a.col-inactive:hover { color: red; } div.filters { } -div.patchforms { +div.patch-forms { margin-top: 1em; } /* list order manipulation */ -table.patchlist tr.draghover { +table.patch-list tr.draghover { background: #e8e8e8 !important; } @@ -228,7 +228,7 @@ table.patch-meta tr th, table.patch-meta tr td { } /* checks forms */ -/* TODO(stephenfin): Merge this with 'div.patchform' rules */ +/* TODO(stephenfin): Merge this with 'div.patch-form' rules */ .checks { border: 1px solid gray; margin: 0.5em 1em; @@ -406,7 +406,7 @@ table.bundlelist td } /* forms that appear for a patch */ -div.patchform { +div.patch-form { border: thin solid #080808; padding-left: 0.6em; padding-right: 0.6em; @@ -414,7 +414,7 @@ div.patchform { margin: 0.5em 5em 0.5em 10px; } -div.patchform h3 { +div.patch-form h3 { margin-top: 0em; margin-left: -0.6em; margin-right: -0.6em; @@ -424,7 +424,7 @@ div.patchform h3 { font-size: 100%; } -div.patchform ul { +div.patch-form ul { list-style-type: none; padding-left: 0.2em; margin-top: 0em; diff --git a/htdocs/js/bundle.js b/htdocs/js/bundle.js index c969d0be..2a721d0d 100644 --- a/htdocs/js/bundle.js +++ b/htdocs/js/bundle.js @@ -6,8 +6,8 @@ function order_button_click(node) { var rows, form; - form = $("#reorderform"); - rows = $("#patchlist").get(0).tBodies[0].rows; + form = $("#reorder-form"); + rows = $("#patch-list").get(0).tBodies[0].rows; if (rows.length < 1) return; @@ -35,18 +35,18 @@ function order_button_click(node) $("#reorder\\-cancel").css("display", "inline"); /* show help text */ - $("#reorderhelp").text('Drag & drop rows to reorder'); + $("#reorder-help").text('Drag & drop rows to reorder'); /* enable drag & drop on the patches list */ - $("#patchlist").tableDnD({ + $("#patch-list").tableDnD({ onDragClass: 'dragging', onDragStart: function() { dragging = true; }, onDrop: function() { dragging = false; } }); /* replace zebra striping with hover */ - $("#patchlist tbody tr").css("background", "inherit"); - $("#patchlist tbody tr").hover(drag_hover_in, drag_hover_out); + $("#patch-list tbody tr").css("background", "inherit"); + $("#patch-list tbody tr").hover(drag_hover_in, drag_hover_out); } editing_order = !editing_order; diff --git a/patchwork/templates/patchwork/partials/patch-list.html b/patchwork/templates/patchwork/partials/patch-list.html index 02d6dff8..80ae6908 100644 --- a/patchwork/templates/patchwork/partials/patch-list.html +++ b/patchwork/templates/patchwork/partials/patch-list.html @@ -9,14 +9,14 @@ {% include "patchwork/partials/pagination.html" %} {% if order.editable %} -<table class="patchlist"> +<table class="patch-list"> <tr> - <td class="patchlistreorder"> - <form method="post" id="reorderform"> + <td class="patch-list-reorder"> + <form method="post" id="reorder-form"> {% csrf_token %} - <input type="hidden" name="form" value="reorderform"/> + <input type="hidden" name="form" value="reorder-form"/> <input type="hidden" name="order_start" value="0"/> - <span id="reorderhelp"></span> + <span id="reorder-help"></span> <input id="reorder-cancel" type="button" value="Cancel" onClick="order_cancel_click(this)"/> <input id="reorder-change" type="button" value="Change order" @@ -29,7 +29,7 @@ {% if page.paginator.long_page and user.is_authenticated %} <div class="floaty"> - <a title="jump to form" href="#patchforms"> + <a title="jump to form" href="#patch-forms"> <span style="font-size: 120%">▾</span> </a> </div> @@ -52,9 +52,9 @@ $(document).ready(function() { <form method="post"> {% csrf_token %} -<input type="hidden" name="form" value="patchlistform"/> +<input type="hidden" name="form" value="patch-list-form"/> <input type="hidden" name="project" value="{{project.id}}"/> -<table id="patchlist" class="table table-hover table-extra-condensed table-striped pw-list" +<table id="patch-list" class="table table-hover table-extra-condensed table-striped pw-list" data-toggle="checkboxes" data-range="true"> <thead> <tr> @@ -72,23 +72,23 @@ $(document).ready(function() { <th> {% if order.name == "name" %} - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> <span class="glyphicon glyphicon-chevron-{{ order.updown }}"></span> </a> - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> Patch </a> {% else %} {% if not order.editable %} - <a class="colinactive" href="{% listurl order="name" %}">Patch</a> + <a class="col-inactive" href="{% listurl order="name" %}">Patch</a> {% else %} - <span class="colinactive">Patch</span> + <span class="col-inactive">Patch</span> {% endif %} {% endif %} </th> <th> - <span class="colinactive">Series</span> + <span class="col-inactive">Series</span> </th> <th> @@ -101,70 +101,70 @@ $(document).ready(function() { <th> {% if order.name == "date" %} - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> <span class="glyphicon glyphicon-chevron-{{ order.updown }}"></span> </a> - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> Date </a> {% else %} {% if not order.editable %} - <a class="colinactive" href="{% listurl order="date" %}">Date</a> + <a class="col-inactive" href="{% listurl order="date" %}">Date</a> {% else %} - <span class="colinactive">Date</span> + <span class="col-inactive">Date</span> {% endif %} {% endif %} </th> <th> {% if order.name == "submitter" %} - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> <span class="glyphicon glyphicon-chevron-{{ order.updown }}"></span> </a> - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> Submitter </a> {% else %} {% if not order.editable %} - <a class="colinactive" href="{% listurl order="submitter" %}"> + <a class="col-inactive" href="{% listurl order="submitter" %}"> Submitter </a> {% else %} - <span class="colinactive">Submitter</span> + <span class="col-inactive">Submitter</span> {% endif %} {% endif %} </th> <th> {% if order.name == "delegate" %} - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> <span class="glyphicon glyphicon-chevron-{{ order.updown }}"></span> </a> - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> Delegate </a> {% else %} {% if not order.editable %} - <a class="colinactive" href="{% listurl order="delegate" %}">Delegate</a> + <a class="col-inactive" href="{% listurl order="delegate" %}">Delegate</a> {% else %} - <span class="colinactive">Delegate</span> + <span class="col-inactive">Delegate</span> {% endif %} {% endif %} </th> <th> {% if order.name == "state" %} - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> <span class="glyphicon glyphicon-chevron-{{ order.updown }}"></span> </a> - <a class="colactive" href="{% listurl order=order.reversed_name %}"> + <a class="col-active" href="{% listurl order=order.reversed_name %}"> State </a> {% else %} {% if not order.editable %} - <a class="colinactive" href="{% listurl order="state" %}">State</a> + <a class="col-inactive" href="{% listurl order="state" %}">State</a> {% else %} - <span class="colinactive">State</span> + <span class="col-inactive">State</span> {% endif %} {% endif %} </th> @@ -174,9 +174,9 @@ $(document).ready(function() { <tbody> {% for patch in page.object_list %} - <tr id="patch_row:{{patch.id}}"> + <tr id="patch-row:{{patch.id}}"> {% if user.is_authenticated %} - <td style="text-align: center;"> + <td id="select-patch:{{patch.id}}" style="text-align: center;"> <input type="checkbox" name="patch_id:{{patch.id}}"/> </td> {% endif %} @@ -188,24 +188,24 @@ $(document).ready(function() { </button> </td> {% endif %} - <td> + <td id="patch-name:{{patch.id}}"> <a href="{% url 'patch-detail' project_id=project.linkname msgid=patch.url_msgid %}"> {{ patch.name|default:"[no subject]"|truncatechars:100 }} </a> </td> - <td> + <td id="patch-series:{{patch.id}}"> {% if patch.series %} <a href="?series={{patch.series.id}}"> {{ patch.series|truncatechars:100 }} </a> {% endif %} </td> - <td class="text-nowrap">{{ patch|patch_tags }}</td> - <td class="text-nowrap">{{ patch|patch_checks }}</td> - <td class="text-nowrap">{{ patch.date|date:"Y-m-d" }}</td> - <td>{{ patch.submitter|personify:project }}</td> - <td>{{ patch.delegate.username }}</td> - <td>{{ patch.state }}</td> + <td id="patch-tags:{{patch.id}}" class="text-nowrap">{{ patch|patch_tags }}</td> + <td id="patch-checks:{{patch.id}}" class="text-nowrap">{{ patch|patch_checks }}</td> + <td id="patch-date:{{patch.id}}" class="text-nowrap">{{ patch.date|date:"Y-m-d" }}</td> + <td id="patch-submitter:{{patch.id}}">{{ patch.submitter|personify:project }}</td> + <td id="patch-delegate:{{patch.id}}">{{ patch.delegate.username }}</td> + <td id="patch-state:{{patch.id}}">{{ patch.state }}</td> </tr> {% empty %} <tr> @@ -218,10 +218,10 @@ $(document).ready(function() { {% if page.paginator.count %} {% include "patchwork/partials/pagination.html" %} -<div class="patchforms" id="patchforms"> +<div class="patch-forms" id="patch-forms"> {% if patchform %} - <div class="patchform patchform-properties"> + <div class="patch-form patch-form-properties"> <h3>Properties</h3> <table class="form"> <tr> @@ -257,7 +257,7 @@ $(document).ready(function() { {% endif %} {% if user.is_authenticated %} - <div class="patchform patchform-bundle"> + <div class="patch-form patch-form-bundle"> <h3>Bundling</h3> <table class="form"> <tr> diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 2238e82e..b617d366 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -135,9 +135,9 @@ {% endif %} </table> -<div class="patchforms"> +<div class="patch-forms"> {% if patchform %} - <div class="patchform patchform-properties"> + <div class="patch-form patch-form-properties"> <h3>Patch Properties</h3> <form method="post"> {% csrf_token %} @@ -175,7 +175,7 @@ {% endif %} {% if createbundleform %} - <div class="patchform patchform-bundle"> + <div class="patch-form patch-form-bundle"> <h3>Bundling</h3> <table class="form"> <tr> diff --git a/patchwork/tests/views/test_bundles.py b/patchwork/tests/views/test_bundles.py index 6a744093..e265eb69 100644 --- a/patchwork/tests/views/test_bundles.py +++ b/patchwork/tests/views/test_bundles.py @@ -353,7 +353,7 @@ class BundleCreateFromListTest(BundleTestBase): def test_create_empty_bundle(self): newbundlename = 'testbundle-new' - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'bundle_name': newbundlename, 'action': 'Create', 'project': self.project.id} @@ -369,7 +369,7 @@ class BundleCreateFromListTest(BundleTestBase): newbundlename = 'testbundle-new' patch = self.patches[0] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'bundle_name': newbundlename, 'action': 'Create', 'project': self.project.id, @@ -393,7 +393,7 @@ class BundleCreateFromListTest(BundleTestBase): n_bundles = Bundle.objects.count() - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'bundle_name': '', 'action': 'Create', 'project': self.project.id, @@ -414,7 +414,7 @@ class BundleCreateFromListTest(BundleTestBase): newbundlename = 'testbundle-dup' patch = self.patches[0] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'bundle_name': newbundlename, 'action': 'Create', 'project': self.project.id, @@ -489,7 +489,7 @@ class BundleAddFromListTest(BundleTestBase): def test_add_to_empty_bundle(self): patch = self.patches[0] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'action': 'Add', 'project': self.project.id, 'bundle_id': self.bundle.id, @@ -509,7 +509,7 @@ class BundleAddFromListTest(BundleTestBase): def test_add_to_non_empty_bundle(self): self.bundle.append_patch(self.patches[0]) patch = self.patches[1] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'action': 'Add', 'project': self.project.id, 'bundle_id': self.bundle.id, @@ -538,7 +538,7 @@ class BundleAddFromListTest(BundleTestBase): count = self.bundle.patches.count() patch = self.patches[0] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'action': 'Add', 'project': self.project.id, 'bundle_id': self.bundle.id, @@ -559,7 +559,7 @@ class BundleAddFromListTest(BundleTestBase): count = self.bundle.patches.count() patch = self.patches[0] - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'action': 'Add', 'project': self.project.id, 'bundle_id': self.bundle.id, @@ -650,7 +650,7 @@ class BundleInitialOrderTest(BundleTestBase): newbundlename = 'testbundle-new' # need to define our querystring explicity to enforce ordering - params = {'form': 'patchlistform', + params = {'form': 'patch-list-form', 'bundle_name': newbundlename, 'action': 'Create', 'project': self.project.id, @@ -704,7 +704,7 @@ class BundleReorderTest(BundleTestBase): patch=self.patches[start]).patch slice_ids = neworder_ids[start:end] - params = {'form': 'reorderform', + params = {'form': 'reorder-form', 'order_start': firstpatch.id, 'neworder': slice_ids} diff --git a/patchwork/tests/views/test_patch.py b/patchwork/tests/views/test_patch.py index 1a1243cf..22ee0c19 100644 --- a/patchwork/tests/views/test_patch.py +++ b/patchwork/tests/views/test_patch.py @@ -71,7 +71,7 @@ class PatchListOrderingTest(TestCase): date=date) def _extract_patch_ids(self, response): - id_re = re.compile(r'<tr id="patch_row:(\d+)"') + id_re = re.compile(r'<tr id="patch-row:(\d+)"') ids = [int(m.group(1)) for m in id_re.finditer(response.content.decode())] @@ -304,7 +304,7 @@ class PatchViewTest(TestCase): class PatchUpdateTest(TestCase): - properties_form_id = 'patchform-properties' + properties_form_id = 'patch-form-properties' def setUp(self): self.project = create_project() @@ -318,7 +318,7 @@ class PatchUpdateTest(TestCase): self.base_data = { 'action': 'Update', 'project': str(self.project.id), - 'form': 'patchlistform', + 'form': 'patch-list-form', 'archived': '*', 'delegate': '*', 'state': '*' diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 3efe90cd..7700b734 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -221,12 +221,12 @@ def generic_list(request, project, view, view_args=None, filter_settings=None, # we only pass the post data to the MultiplePatchForm if that was # the actual form submitted data_tmp = None - if data and data.get('form', '') == 'patchlistform': + if data and data.get('form', '') == 'patch-list-form': data_tmp = data properties_form = MultiplePatchForm(project, data=data_tmp) - if request.method == 'POST' and data.get('form') == 'patchlistform': + if request.method == 'POST' and data.get('form') == 'patch-list-form': action = data.get('action', '').lower() # special case: the user may have hit enter in the 'create bundle' diff --git a/patchwork/views/bundle.py b/patchwork/views/bundle.py index 3e227f4c..977d2301 100644 --- a/patchwork/views/bundle.py +++ b/patchwork/views/bundle.py @@ -106,7 +106,7 @@ def bundle_detail(request, username, bundlename): form = BundleForm(instance=bundle) if (request.method == 'POST' and - request.POST.get('form') == 'reorderform'): + request.POST.get('form') == 'reorder-form'): order = get_object_or_404( BundlePatch, bundle=bundle, -- 2.33.0.rc2.250.ged5fa647cd-goog _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork