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

Test to ensure admins can edit/update locked pages , closes #397 #1163

Merged
merged 4 commits into from
Jan 4, 2017
Merged

Test to ensure admins can edit/update locked pages , closes #397 #1163

merged 4 commits into from
Jan 4, 2017

Conversation

500swapnil
Copy link
Collaborator

@500swapnil 500swapnil commented Jan 3, 2017

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

  • all tests pass -- rake test:all
  • code is in uniquely-named feature branch, and has been rebased on top of latest master (especially if you've been asked to make additional changes)
  • pull request is descriptively named with #number reference back to original issue
  • if possible, multiple commits squashed if they're smaller changes
  • reviewed/confirmed/tested by another contributor or maintainer
  • schema.rb.example has been updated if any database migrations were added

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software

We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays. Please alert developers on plots-dev@googlegroups.com when your request is ready or if you need assistance.

Thanks!

@500swapnil
Copy link
Collaborator Author

500swapnil commented Jan 3, 2017

I made the changes in the link but cannot understand what test to add in wiki_controller_test.rb to ensure admin isn't redirected. Would like your help with this one! @jywarren

@500swapnil 500swapnil mentioned this pull request Jan 3, 2017
8 tasks
@@ -43,7 +43,7 @@
<ul class="nav nav-tabs">
<li class="active"><a href="#"><span class="hidden-xs"><%= t('wiki.show.view') %></span><span class="visible-xs"><i class="fa fa-file-o"></i></span></a></li>
<% if @node.has_tag('locked') %>
<li><a href="/wiki/locked"><i class="fa fa-lock"></i></a></li>
<li><a href="/wiki/edit/pagetitle"><i class="fa fa-lock"></i></a></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry -- pagetitle will actually have to be <%= @node.edit_path %>?t=<%= Time.now.to_i %> -- i was typing too fast and wasn't clear enough. Make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we should add a conditional -- <% if current_user && (current_user.role == "moderator" || current_user.role == "admin") %> with the "real" link, but if not, go to /wiki/locked -- make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a check. It serves the same purpose. Is it ok?

@500swapnil
Copy link
Collaborator Author

@jywarren I added the check. It redirects if page is locked and user isn't an admin.

<ul class="nav nav-tabs">
<li class="active"><a href="#"><span class="hidden-xs"><%= t('wiki.show.view') %></span><span class="visible-xs"><i class="fa fa-file-o"></i></span></a></li>
<% if @node.has_tag('locked') %>
<li><a href="/wiki/locked"><i class="fa fa-lock"></i></a></li>
<% if @node.has_tag('locked') && current_user && (current_user.role != "moderator" && current_user.role != "admin")%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, actually this doesn't account for if there is no logged-in user... they'd see no lock symbol. So we need to add something like:

        <% if @node.has_tag('locked') && (current_user ? (current_user.role != "moderator" && current_user.role != "admin") : true) %>

This uses the ternary operator, and I think it's correct, but if you can think of a simpler way to write it, I'm open to suggestions!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a better method. Thanks!

@500swapnil
Copy link
Collaborator Author

@jywarren Made the required changes. Please have a look!

@jywarren
Copy link
Member

jywarren commented Jan 4, 2017

Oh, looks good but could you correct the indentation? Thanks, that should be it!

@500swapnil
Copy link
Collaborator Author

500swapnil commented Jan 4, 2017

@jywarren Done!

@jywarren
Copy link
Member

jywarren commented Jan 4, 2017

Great work!

@jywarren jywarren merged commit de61a31 into publiclab:master Jan 4, 2017
@500swapnil 500swapnil deleted the test-admins branch January 5, 2017 03:52
@500swapnil
Copy link
Collaborator Author

@jywarren Thanks! Any other issue you feel I can work with?

@jywarren
Copy link
Member

jywarren commented Jan 5, 2017

Sure -- perhaps you could tackle some from the Geographic features?

#1070

Just be sure to coordinate with Mridul, who's also tackling those.

This one is complex, but there is example code: Placename autocompletion (break me up) like MapKnitter new map form, as done in this interface, which you can view at https://publiclab.org/profile/info/your_username

and it wouldn't overlap with Mridul's work, I think!

@500swapnil
Copy link
Collaborator Author

@jywarren If he's already working with those, perhaps I should work with some other issue?

@jywarren
Copy link
Member

jywarren commented Jan 6, 2017 via email

@500swapnil
Copy link
Collaborator Author

@jywarren I will co-ordinate with Mridul and work on Geographic features.

@jywarren
Copy link
Member

jywarren commented Jan 6, 2017 via email

@500swapnil
Copy link
Collaborator Author

@jywarren But are there any interface oriented issues for now? Until I learn to work on geographic features. I can work on interface or database oriented issues. Thanks a lot!!

@jywarren
Copy link
Member

jywarren commented Jan 6, 2017 via email

@500swapnil
Copy link
Collaborator Author

@jywarren Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants