Skip to content

Commit

Permalink
rearranging self-validation prevention
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ethan-nelson committed May 17, 2015
1 parent b2ed9a9 commit fc0c525
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions osmtm/templates/task.state.done.mako
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,31 @@ done = task.cur_state and task.cur_state.state == TaskState.state_done
<i class="glyphicon glyphicon-thumbs-down icon-white"></i> ${_('Invalidate')}
</button>
% if done:
<%
tooltip = _("Validate this task if you consider that the work is complete.")
%>
% if user == task.states[0].user and not (user.is_admin or user.is_project_manager):
<%
validation_message = _("You cannot validate a task that you have marked done.")
selfvalidatestate = """ type="button" disabled """
selfvalidatetext = _("You cannot validate a task that you have personally marked as done.")
selfvalidatediv = """<div id="self_validation" class="help-block small text-right">
<em><i class="glyphicon glyphicon-warning-sign"></i>""" + \
selfvalidatetext + """</em></div>"""
%>
<button type="submit" rel="tooltip"
name="validate"
data-container="body"
class="btn btn-success" disabled>
<i class="glyphicon glyphicon-thumbs-up icon-white"></i> ${_('Validate')}
</button>
<div id="self_validation" class="help-block small text-right">
<em><i class="glyphicon glyphicon-warning-sign"></i>
${validation_message}</em>
</div>
% else:
<%
tooltip = _("Validate this task if you consider that the work is complete.")
selfvalidatestate = """ type="submit" """
selfvalidatediv = """"""
%>
<button type="submit" rel="tooltip"
% endif
<button rel="tooltip"
name="validate"
data-container="body"
data-original-title="${tooltip}"
class="btn btn-success">
class="btn btn-success" ${selfvalidatestate | n }>
<i class="glyphicon glyphicon-thumbs-up icon-white"></i> ${_('Validate')}
</button>
% endif
${selfvalidatediv | n}
% endif
</form>
% endif

0 comments on commit fc0c525

Please sign in to comment.