Due: Thursday April 23, 11pm
Submission: Submit it to this CrowdGrader assignment
You need to add a delete button to each row of the products table displayed in lecture_form, and you have to allow the table to be sorted according to product price. The details follow below.
First, make sure you have the most recent py4web:
cd py4web
git checkout master
git pull
The starter code is in the homework 3 branch of the lecture form, which you can get into an app called hw3 as follows:
cd apps
git clone https://luca_de_alfaro@bitbucket.org/luca_de_alfaro/lecture_form.git hw3
cd hw3
git checkout homework3
The index controller (at path /index
) displays a table of products. On each row of the table, there is already an "Edit" button. You need to add a "Delete" button, complete with a delete icon, that:
/index
.The effect is that when you press the button, the deletion will happen, and the the table will be redisplayed minus the row you have deleted.
The button URL needs to be signed, because it carries out an action that has an effect; you can look in the button_implementation at how to create a signer, and sign a URL. How to delete records in a database is documented in the PyDAL - database abstraction layer documentation (it is a good idea for you to become familiar with this documentation).
Your next task is to allow the table to be sorted by cost. The behavior needs to be as follows:
To obtain this behavior, you should use the following URLs:
/index
displays the unsorted products/index?sort=asc
displays the products sorted in ascending order/index?sort=desc
displays the products sorted in descending orderTo sort the products, you should use the orderby construct of PyDAL.