From b790661cfee5d3a4aa216ca4222bc11d4498a640 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 14 2016 13:24:56 +0000 Subject: Make the `Take` button work on the issue page --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 0505dea..f6d2f90 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -147,8 +147,12 @@ {% else %} unassigned {% endif %} - {% if authenticated and repo_admin %} - + {% if authenticated and repo_admin + and (not issue.assignee or issue.assignee.username != g.fas_user.username) %} + {% endif %} @@ -615,6 +619,25 @@ $( document ).ready(function() { } ); + {% if authenticated and repo_admin %} + $("#take-btn").click(function(){ + var _url = "{{ url_for( + 'api_ns.api_assign_issue', repo=repo.name, username=username, issueid=issueid + ) }}"; + var _data = {assignee: "{{ g.fas_user.username }}"}; + $.post( _url, _data ).done( + function(data) { + var _user_url = '\n' + + '{{ g.fas_user.username }}'; + $('#assignee_plain').html(_user_url); + $('#assignee').val("{{ g.fas_user.username }}"); + } + ) + return false; + }); + {% endif %} + }); {% endblock %}