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

Preventing self-validation #602

Merged
merged 2 commits into from
May 17, 2015
Merged

Preventing self-validation #602

merged 2 commits into from
May 17, 2015

Conversation

ethan-nelson
Copy link
Collaborator

From #589 and multiple mailing list posts, a pull request to prevent self-validation (save project managers or admins).

From the tasks view, the object task is already populated from a database query and sorted by date. Thus, we take the most recent state log and compare it against the current user. If they match, and the user is not an admin or project manager, we disable the submission button and include a friendly message (see picture below). Else, we let them--namely other people or by self if project manager/admin--have the option to validate the tile.

This ensures that everyone is still able to self-invalidate a tile.

message

@mataharimhairi
Copy link

@ethan-nelson This is great! Thank you so much for contributing to the code. That's something we can tick off the list of TM enhancements once successfully pulled.

validation_message = _("You cannot validate a task that you have marked done.")
%>
<button type="submit" rel="tooltip"
name="validate"
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 guess some of these tags aren't absolutely necessary on the button, but I kept them in to be consistent with the enabled one (sans the tooltip, which will not show up if you hover over a disabled button).

@ethan-nelson
Copy link
Collaborator Author

And, glad to help 🎊

@pgiraud
Copy link
Collaborator

pgiraud commented May 10, 2015

Hi @ethan-nelson.
Thanks for addressing this issue.
I would prefer less code being duplicated. What about only adding the disabled and validation_message only instead of duplicating the button code twice?

By the way, there seem to be problems with the build which are not due to your pull request.

@ethan-nelson
Copy link
Collaborator Author

@pgiraud sounds like a plan. I'll revise and resubmit.

@pgiraud
Copy link
Collaborator

pgiraud commented May 10, 2015

While you're at it, you can rebase onto master to get travis happy.

A single button is employed. Now, we apply attributes as to whether the user is allowed to validate or not. If they can, we add `type="submit"`. Otherwise, we add `type="button" disabled` and also include a div explaining that the user cannot self-validate.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 95.33% when pulling fc0c525 on ethan-nelson:dev54 into 147d20c on hotosm:master.

@ethan-nelson
Copy link
Collaborator Author

Rearranged the code a bit and tested it. Let me know if I should make any further modifications.

pgiraud pushed a commit that referenced this pull request May 17, 2015
Preventing self-validation
@pgiraud pgiraud merged commit 7c30169 into hotosm:master May 17, 2015
@ethan-nelson ethan-nelson deleted the dev54 branch May 25, 2015 19:26
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.

4 participants