The newest route allows just Post needs

Carry out the same modification with the SQL report while the ahead of, upcoming replace the past printing() function to demonstrate the item ID and also the worth of over :

Nothing of the things that might have been designated once the complete therefore, the worth of done for each items is 0 , meaning that untrue . To allow pages to change that it worth and you can mark points as complete, you will incorporate a unique approach to the latest document.

Brand new carry out() examine means takes an id disagreement-this is the ID of item we need to mark as completed. Into the form, your open a databases connection, you then fool around with an upgrade SQL declaration to set the importance of your own complete column to one on the product to be marked once the done.

You utilize the newest ? placeholder on perform() approach and you can solution an effective tuple containing the fresh new ID in order to safely enter analysis for the database. Then chances are you to go the order and you will personal the relationship and you may reroute towards the index webpage.

Shortly after adding a path to draw points because finished, you need other approach to undo this and you can come back the brand new item to a low-accomplished condition.

It station is a lot like the new /do/ channel, in addition to undo() view setting is precisely like the latest carry out() mode except that you put the worth of completed to 0 unlike step 1 .

At this point you you desire a button in order to mark to-do facts since the done otherwise uncompleted according to state of the thing, discover brand new index.html template file:

In this getting loop, you use a line-thanks to CSS really worth to your text message-design possessions should your item is actually designated just like the accomplished, that you learn about property value goods[‘done’] . Then you make use of the Jinja sentence structure set-to declare one or two details, Hyperlink and you may Option . In the event the item isn’t noted since completed new switch commonly have the value Carry out plus the Hyperlink have a tendency to lead on /do/ channel, whenever the thing is actually marked because accomplished, the option are certain to get a value of Undo and can point to /undo/ . Once, you use both of these variables in the an input form you to definitely submits the proper demand with respect to the state of your item.

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

You can now mark affairs since the accomplished on directory webpage . After that you can truly add the ability to revise so you’re able to-perform situations.

Step three – Editing So you’re able to-Create Circumstances

In this action, you’ll create a different page for editing facts you can transform brand new contents of each goods and you may assign factors to additional listings.

You will put another type of /edit/ path to the file, which will bring a unique revise.html code where a person can transform established issues. Additionally, you will upgrade the brand new list.html document to incorporate a modify option to each goods.

Inside the new check mode, you use the newest id argument so you can bring the newest ID of one’s to-manage goods we would like to revise, the latest ID of the checklist it is part of, the value of this new done column, the content of your goods, additionally the checklist title playing with a beneficial SQL Subscribe . You save this info in the todo variable. Then you definitely rating most of the in order to-manage listings regarding databases and you can cut her or him regarding listings variable.

If for example the request was a consistent Score consult, the problem in the event the request.strategy == ‘POST’ cannot focus on, therefore the app does the past offer_template() means, passageway one another todo and you can listings to help you a change.html document.

When the however, a questionnaire are submitted, the issue request.strategy == ‘POST’ will get real , then you definitely pull the content therefore the listing identity the user submitted. In the event the zero posts are registered, you flash the message Blogs is needed! and you may redirect into exact same modify webpage. Otherwise, you get this new ID of number an individual recorded; this enables an individual to maneuver an inside-manage item in one record to some other. Upcoming, you utilize an update SQL statement to put the message away from new so you’re able to-manage product for the the blogs the user filed. You will do a similar to the record ID. In the end, you commit the changes and you will intimate the partnership, and you will redirect the consumer to your directory webpage.

Deixe um comentário

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