Online store on Steemit blockchain| Step nineteen | Edit and delete buttons.

in Steem Alliancelast year

Hello, friends!

Step 19.jpg

Today we will make two very important buttons for those who will publish their courses. Since the administrator can edit the data through his panel, but the users themselves cannot edit their content. Today we will make two buttons for them. They will appear in the product card itself and will be visible only to those who published this course.

As always, let's start by putting our paths in the urls file.
There will be two ways. The first is content editing and the second is content deletion.
Also, do not forget to register the import of views.

Screenshot_43.png

Now let's write two classes for the view.
The first one will be with our content update.
It is worth noting that the link to the html template is specified as it was during creation. That is, they have the same pattern.
You will also need to import UpdateView.

Screenshot_44.png

Now we create a content removal class.

Where we specify a separate html template with confirmation of deletion.

We also import the standard django DeleteView function.

Screenshot_45.png

Now we need to create an html template where a person will confirm the desire to remove content.

Screenshot_46.png

As always, import the base template. And also specify the content area.
Since we do not need the substitution of values, we also set the CSFR token. And also create the confirmation button itself.

Screenshot_47.png

Now we need to create buttons that will be responsible for editing and deleting content. Which in turn will access urls and then through views to the database. And do your job.

Screenshot_48.png

We also indicate that these buttons belong only to the author. Thus, we block access to the rest. A little lower I will show how the creator of the button displays and how it looks like for a simple user.

Screenshot_49.png

Now we can look at the buttons from the point of view of the creator of this course.

Screenshot_50.png


As we see our buttons are displayed. Now it's worth to go through me and see what they offer us.

Edit button.

Screenshot_52.png

Offers to edit and save our content.

Delete button. Prompts us to confirm the removal of content.

Screenshot_53.png


If you look from the side of an ordinary user, then we will not see these buttons.

Screenshot_51.png

Great!

Thanks for supporting the project.

@rme , @rex-sumon , @shy-fox , @hungry-griffin, @pennsif

The project is being created in partnership with @steemit-market.

Above may be wrong. Since I wrote the code from memory and then corrected it. But git will have no errors.

Link to the git.

steem blockchain.jpg

You can get acquainted with the project here.

You can find all parts of the projects by the tag: #storeonsteemit

To be continued...

Sincerely, your HardPhotographer

Sort:  

Thank you for your contribution to the community. Keep on sharing quality original posts and please read our how-to posts which have been pinned in the community.

Rating : 8/10

have a nice day!

48C10B14-B874-4772-B918-787C13ED437B.png

Fine. Thank you.

Online store in Steemit blockchain | Step nineteen | Edit and delete buttons.

hello, good point, it gives me a pleasure that you are a programmer, I am also learning to be a programmer, I am currently studying computer science, pass for the fourth semester...

Hello. Cool. I am an amateur. The fourth course is good. It means you have more knowledge.

Hello, yes, great because I am still in the middle of my studies.
to become a future Engineer.

higher education will help in life. It will help a lot.

Hi. Try to use the formatting in the text for the code. So that people can copy it and use it. Nothing is clear from the screenshots and nothing is visible. Everything is blurry.

Hello. For this I have a link to the github.

Exactly. I saw it now. I didn't notice it right away. But it still seems to me that the screenshots are very blurry and then what do they matter?

I tried to paste the code into the post but it turns out to be a rather long post. And I can't point to certain things. It seems to me. I will finish this online store in this format, but I will think about the format over the next posts.
Thank you for your feedback. I will definitely take this into account and think about how it can be fixed.

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 62500.50
ETH 2936.24
USDT 1.00
SBD 3.59