Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic/Normal User not able to delete own wiki page #2013

Closed
4 tasks
sagarpreet-chadha opened this issue Jan 16, 2018 · 6 comments
Closed
4 tasks

Basic/Normal User not able to delete own wiki page #2013

sagarpreet-chadha opened this issue Jan 16, 2018 · 6 comments
Labels
enhancement explains that the issue is to improve upon one of our existing features first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute HTML Ruby
Milestone

Comments

@sagarpreet-chadha
Copy link
Contributor

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

The Problem

When normal/basic user deletes the wiki page created by him/her , the login screen is shown .

Solution

The delete button on wiki page links to /notes/delete/ .

<a href='/notes/delete/<%= node.id %>' class='btn btn-default btn-sm' data-confirm='Are you sure?'>

However the if condition in notes#delete method is incorrect here .
We need to change if condition in line :
if current_user.uid == @node.uid && @node.type == 'note' || current_user.role == 'admin' || current_user.role == 'moderator'

to :
if current_user && (current_user.uid == @node.uid || current_user.role == "moderator" || current_user.role == "admin")

Feel free to ask any doubt regarding the issue ! Thank you !

Steps to Fix

  • claim this issue with a comment here, below, and ask any clarifying questions you need
  • set up a repository locally following the README instructions, and make sure that all tests pass
  • try to fix the issue following the steps above, but even before you're done, you can:
    commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/wiki/developers) or go to the chatroom if you have questions, and take a look at our first-timers landing page for more information!

@sagarpreet-chadha sagarpreet-chadha changed the title Normal User not able to delete own wiki page Basic/Normal User not able to delete own wiki page Jan 16, 2018
@ankitbhardwaj78
Copy link
Contributor

ankitbhardwaj78 commented Jan 16, 2018 via email

@jywarren
Copy link
Member

Hi, I'd like to request one more condition -- if any other authors have contributed to a wiki page, we will need to disable the ability to delete your own page, because you might delete someone else's contributions.

So we'll need a check to be sure @node.authors.uniq.length == 1 -- that is, that there is only a single author who's contributed so far.

Can we add this condition to the controller and if it's not met, return a message that You cannot delete a wiki page once someone else has begun to contribute to it.?

Thank you!!!

plots2/app/models/node.rb

Lines 216 to 218 in 3df8567

def authors
revisions.collect(&:author).uniq
end

@jywarren
Copy link
Member

And yes, @ankitbhardwaj78 if this extra condition seems feasible for you, we'd love to! @sagarpreet-chadha would you be able to help @ankitbhardwaj78 with this extra condition? Thanks!

@jywarren jywarren added enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute first-timers-only They need to be well-formatted using the First-timers_Issue_Template. Ruby HTML labels Jan 16, 2018
@sagarpreet-chadha
Copy link
Contributor Author

Yes @jywarren , i would love to help ! Thanks 😄 .

@jywarren jywarren added this to the Rich Wikis milestone Jan 17, 2018
@ankitbhardwaj78
Copy link
Contributor

I will do this.. @jywarren

@ankitbhardwaj78
Copy link
Contributor

@jywarren and @sagarpreet-chadha please take a review i have made changes #2030

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement explains that the issue is to improve upon one of our existing features first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute HTML Ruby
Projects
None yet
Development

No branches or pull requests

3 participants