How to sort table in columns using Django? - django

I have some tables in html like this:
...
<th>
<div class="d-flex align-items-center">
<p class="fw-normal size-12 text-label mb-0 d-inline-block"></p>
<i class="fas fa-arrow-down ms-2 text-gray-dark size-12"></i>
</div>
</th>
...
I want to sort them using an arrow, but I have to use Django here. I didn't find much materials online. Any suggestion?

make sure you have create every column header as a link, example :
<th>Address</th>

Related

Remove payment_address payment_method from checkout/checkout page Opencart 3.x

hi i need to remove payment_address payment_method from checkout/checkout page Opencart 3.x.
i donot want extension, please some body help on this.
Theoretically, you can activate a COD payment method and then simply hide this step with basic CSS and a bit of JS to open the final step in the default checkout.
But Opencart heavily relies on Payment_address. Payment Address has several fields that are required like country, zone and often postcode.
Removing the payment_address will break the whole system. What you can do is via simple HTML and CSS, populate the fields with default values and then hide with CSS.
for example in catalog/view/theme/default/template/checkout/payment_address.twig
...html
<div class="form-group required">
<label class="col-sm-2 control-label" for="input-payment-firstname">{{ entry_firstname }}</label>
<div class="col-sm-10">
<input type="text" name="firstname" value="<MY_DEFAULT_FIRST_NAME>" placeholder="{{ entry_firstname }}" id="input-payment-firstname" class="form-control" />
</div>
</div>
...
do this for all the fields.
then in catalog/view/theme/default/template/checkout/checkout.twig do style="display:none'
<div class="panel panel-default" style="display:none">
<div class="panel-heading">
<h4 class="panel-title">{{ text_checkout_account }}</h4>
</div>
<div class="panel-collapse collapse" id="collapse-payment-address">
<div class="panel-body"></div>
</div>
</div>
{% else %}
<div class="panel panel-default" style="display:none">
<div class="panel-heading">
<h4 class="panel-title">{{ text_checkout_payment_address }}</h4>
</div>
<div class="panel-collapse collapse" id="collapse-payment-address">
<div class="panel-body"></div>
</div>
</div>
this will just hide the payment_address block but it will still be there.
and now you need to skip the payment address step by calling the Continue button via JavaScript
so in the same file catalog/view/theme/default/template/checkout/checkout.twig
after line 165
$('a[href=\'#collapse-payment-address\']').trigger('click');
//add this code to trigger continue button:
$('#button-payment-address').trigger('click');
You might need to wrap the trigger click action with setTimeout becuase you might trigger the click before the form is actually loaded.
I would also advise to do this in a CUSTOM theme folder, and not in the default opencart theme. this way you can do the modifications without touching the core file.

Foundation align column right when using flex grid (not xy grid)

<div class="row align-middle">
<div class="small-4 columns">
<div></div>
</div>
<div class="small-4 columns">
<div></div>
</div>
<div class="small-4 columns">
<div>I want to be on the right edge of the parent .row</div>
</div>
</div>
I have the above.
I want the div that's in the third .columns div to be aligned to the right (so that it would look the same as if I put text-align: center on the third .columns div).
I know a way to do so - by putting another .row div inside that column and giving that .row another class of align-right and putting then another .columns inside of that row - but this would result in an unnecessary amount of HTML and I assume Foundation must have provided me a way (another CSS class that I can't find in the docs) of achieving my goal without further HTML than is above.
How do I do this? Or do I have to put another row and column inside that third column?
.columns doesn't have display: flex so I can't put align-right on the column - won't work. Or are .columns meant to have display:flex and I'm just experiencing a bug or otherwise an issue I've possibly created somewhere?
Thanks
if you are using the 6.5 version of foundation, then the following replacements in code would do what you expect
<div class="grid-x">
<div class="small-4 cell">
<div></div>
</div>
<div class="small-4 cell">
<div></div>
</div>
<div class="small-4 cell">
<div>I want to be on the right edge of the parent .row</div>
</div>
</div>
But if you really don't want to use the grid-xy classes, then you can keep your code and use instead foundation 5.5. I hope this helps!

How to get a row and select a specific td in cypress?

I have a table with 6 columns and variable rows. Now i want cypress to test the delete button. so i create a testitem in my table in the test before and want my program to delete this testitem.
How can i search in a table in column 2, filter the row and click on the button in column 6 with cypress?
I read the docu and guide on cypress.io but i have not find any solutions.
<div class="row">
<div class="top-buffer"></div>
<div class="panel panel-primary">
<div class="panel-heading panel-head">Article</div>
<div class="panel-body">
<div class="btn-group">
<a asp-action="Edit" asp-route-id="#Guid.Empty" class="btn btn-primary"><i class="" glyphicon glyphicon-plus"></i>NEW</a>
</div>
<div class="top-buffer"></div>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
</thead>
<tbody>
#foreach (var att in Model)
{
<tr>
<td>#Html.DisplayFor(modelItem => att.1)</td>
<td>#Html.DisplayFor(modelItem => att.2)</td>
<td>#Html.DisplayFor(modelItem => att.3)</td>
<td>#Html.DisplayFor(modelItem => att.4)</td>
<td>#Html.DisplayFor(modelItem => att.5)</td>
<td>
<a asp-action="Edit" asp-route-id="#att.Id" class="btn btn-info"><i class="glyphicon glyphicon-pencil"></i>EDIT</a>
<a asp-action="DeleteCategory" asp-route-id="#att.Id" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i>DELETE</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
The code you show is ASP.Net source which gets compiled on the server, so the HTML in the browser (the HTML your test needs to work with) will be different.
i.e #foreach (var att in Model) gives you a row for each item in Model and #Html.DisplayFor(modelItem => att.2) will be translated into some concrete content for column 2.
Therefore, it would be easier to answer if you run the app in a browser and copy and paste that HTML from the console.
Since you want to search on column 2, that can go two ways.
If the content in column 2 is very unique, e.g names that do not appear in other columns, you can target it just by looking for the text
cy.contains('td', 'text-to-search-for') // gives you the cell
.parent() // gives you the row
.within($tr => { // filters just that row
.get('td a') // finds the buttons cell of that row
.contains('DELETE') // finds the delete button
.click()
OR
cy.contains('td', 'text-to-search-for') // gives you the cell
.siblings() // gives you all the other cells in the row
.contains('a', 'DELETE') // finds the delete button
.click()
If text you want to search for can appear in columns other than column 2, it becomes more difficult, but chances are the above will suffice.
The other thing to note, if your test scenario always uses the same data, e.g from a fixture file, you can target specific row numbers but that's a fragile test which will need re-writing if the structure of the page changes.
Your Html only had one row, so clicking that button should be easy if that is the case..
cy.get('.btn').click
I am betting that will cause problem later, because you will probably have more rows.
cy.get('table').find('tr').eq(ROW INDEX).find('td').eq(COLUMN INDEX).find('.btn-danger').click()
Now I don't think this is the best way to do this. I would suggest you add some classes to your code so you can easier get to your elements. For example add a class to the delete button that is class="delete-item" so you can use that in a selector
cy.get('table').find('tr').eq(ROW INDEX).find('td').eq(COLUMN INDEX).find('.delete-item').click()
I am not 100% sure about this answer because I did not try it.

Multiple bootstrap collapse in a page

I'm using bootstrap collapse but I've a problem. The first collapse I insert work fine but when I repaste it at the bottom of the page they are interfering. The second open the first one. I think I must name them differently or doing something like this but I don't know how to do. This is my code:
<a data-toggle="collapse" href="https://www.blogger.com/blogger.g?blogID=2271780003550934014#demo">Hello</a>
<br />
<div class="collapse" id="demo" style="text-align: left;">
Hello
</div>
What should I do ?

Display element in form using Zurb Foundation

I'm using the CSS Framework Foundation and when I write the following code:
<div class="row">
<div class="two mobile-one columns"><label for="invoiceterm-summary" class="right inline">Become late <span class="required">*</span></label></div>
<div class="ten mobile-three columns"><input class="one" id="invoiceterm-late" name="invoiceterm[late]" type="text" value=""> days after invoice sent</div>
</div>
​
I get this :
But I want to display the text "days after invoice sent" like this:
You should place all of these elements into a single:
<div class="row">
<div class="twelve mobile-four columns"></div>
</div>
Otherwise it is behaving correctly, stacking the columns as the screen size is reduced.
I had to remove the display: block property from the css definition of the input[type="text"] on the foundation.css file