Hello, friends!
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.
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.
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.
Now we need to create an html template where a person will confirm the desire to remove content.
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.
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.
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.
Now we can look at the buttons from the point of view of the creator of this course.
As we see our buttons are displayed. Now it's worth to go through me and see what they offer us.
Edit button.
Offers to edit and save our content.
Delete button. Prompts us to confirm the removal of content.
If you look from the side of an ordinary user, then we will not see these buttons.
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.
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
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!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Fine. Thank you.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello. Cool. I am an amateur. The fourth course is good. It means you have more knowledge.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello, yes, great because I am still in the middle of my studies.
to become a future Engineer.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
higher education will help in life. It will help a lot.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello. For this I have a link to the github.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit