plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Add right to edit a co-authored note if username is tagged using "with:USERNAME"

Open ebarry opened this issue 9 years ago • 5 comments

What happened just before the problem occurred

I'm posting this on behalf of Mimibell who is co-author on a note, and wished to edit it, but the system did not give the account access, although the friendly green announcement said that it did: unnamed

Relevant URLs

Research Note: https://publiclab.org/notes/stevie/09-20-2017/notes-and-reflections-from-hurricane-preparedness-discussion-dinner

PublicLab.org username

Individual account: https://publiclab.org/profile/mimibell

Browser, version, and operating system

ebarry avatar Sep 25 '17 15:09 ebarry

Thanks, @ebarry ! This is great; it's part of this issue which needed to be broken up into individual issues, so I'll link it: https://github.com/publiclab/plots2/issues/761

I'll also copy in the notes for how to solve this, and if you'd like help reformatting this issue I think we could get it in the queue pretty easily:

Steps to fix

give co-authors (as denoted by with:<username>, see code here) right to edit (as in now-closed #606), meaning a node.has_power_tag('with')-based check on edit and update actions on app/controllers/notes_controller.rb

The check happens in edit on this line: https://github.com/publiclab/plots2/blob/master/app/controllers/notes_controller.rb#L152

And in the update action on this line: https://github.com/publiclab/plots2/blob/master/app/controllers/notes_controller.rb#L178

In each case, we can change:

    if current_user.uid == @node.uid || current_user.role == 'admin'

into:

    if current_user.uid == @node.uid || current_user.role == 'admin' || @node.has_tag("with:%{current_user.username}")

That way we allow coauthors to edit the page as well.

jywarren avatar Sep 25 '17 16:09 jywarren

There is actually already a set of tests written for this, here: https://github.com/publiclab/plots2/pull/825/files

So, if this new feature is implemented correctly, it should pass those additional tests -- happy to help folks if any potential solution could be based off those tests!

jywarren avatar Sep 27 '17 15:09 jywarren

Can I work on it??I am a first timer.

ViditChitkara avatar Sep 29 '17 16:09 ViditChitkara

@jywarren Can I work on this issue if it's still available?

Diksha2008 avatar Oct 09 '17 11:10 Diksha2008

Sure, either of you is welcome to do so -- please open a pull request with your changes even before you're done so that you don't overlap work. And I'm happy to help out!

jywarren avatar Oct 09 '17 19:10 jywarren