Brand new route accepts just Post demands

Perform the same modification to your SQL report as just before, next change the last printing() form showing the thing ID while the value of over :

Not one of the things that could have been designated as the completed so that the property value completed for per goods is 0 , which means that false . To allow users to switch it worthy of and you may mark situations once the done, you are going to add a new path to brand new document.

The newest create() evaluate form takes an enthusiastic id dispute-this is basically the ID of your own items we would like to draw while the done. Into the mode, your open a database relationship, then chances are you explore an improve SQL declaration to put the significance of the done line to just one to the items to get noted while the completed.

You use the latest ? placeholder throughout the perform() strategy and citation a good tuple that has the latest ID to help you securely insert study for the databases. Then you certainly commit the transaction and you may romantic the connection and reroute for the directory webpage.

Shortly after incorporating an approach to draw items once the accomplished, need another approach to undo this step and you may return the new item to a non-complete reputation.

This route is a lot like the fresh /do/ route, and the undo() view setting is precisely exactly like new would() mode aside from your set the value of done to 0 in the place of step 1 .

At this point you need an option so you’re able to draw to-perform facts due to the fact accomplished or uncompleted with regards to the state of the object, open brand new list.html template document:

In this to possess loop, you use a line-courtesy CSS worth on text message-decor assets if your item are noted once the finished, which you discover in the property value goods[‘done’] . Then chances are you utilize the Jinja syntax set to state a couple of variables, Website link and Key . If your item isn’t designated as completed the newest button tend to feel the worth Create plus the Website link tend to head toward /do/ channel, of course the object was marked just like the completed, the fresh switch will receive a value of Undo and will part to /undo/ . After, you utilize both of these parameters within the a feedback mode you to definitely submits the best consult with respect to the state of one’s goods.

Are the following route at the end of the fresh new document:

Anyone can mark circumstances just like the done into the directory page . Then you can truly add the capability to edit to help you-perform things.

Step 3 – Editing So you can-Would Circumstances

Inside action, you will create a unique webpage to possess modifying affairs so that you can alter the new items in for every single goods and you may assign what to other lists.

You are going to incorporate a separate /edit/ approach to new file, that can render a different sort of modify.html page in which a user can transform existing products. You will also up-date the brand new index.html file to add a modify option to each and every items.

Within the have a look at function, you employ the latest id dispute to fetch this new ID of your to-carry out goods we should modify, datingranking.net/de/strapon-dating-de/ the newest ID of one’s listing it belongs to, the worth of brand new complete column, the content of item, together with checklist identity having fun with a good SQL Signup . It can save you this info on todo adjustable. Then you get every to help you-would listing regarding database and you will save your self them on directories varying.

If your demand is a regular Rating request, the problem if consult.approach == ‘POST’ does not work with, therefore the app performs the final bring_template() setting, passageway one another todo and you can lists to an edit.html document.

When the but not, a questionnaire is actually filed, the matter request.means == ‘POST’ will get real , then you definitely extract the content as well as the number label an individual filed. If no articles is submitted, you flash the message Articles is needed! and you will reroute into the exact same edit page. If not, you bring the newest ID of your own checklist the consumer registered; this enables the consumer to go an inside-do item from one record to a different. Up coming, you employ an improve SQL declaration to create the content from new so you’re able to-perform product towards the fresh new posts the consumer recorded. You are doing a similar on the record ID. Eventually, you commit the alterations and you may personal the connection, and you can reroute the user towards the directory web page.

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *