Blob Blame Raw
{% extends "repo_master.html" %}
{% from "_formhelper.html" import render_field_in_row %}

{% block title %}Pull request #{{ requestid }} - {{ repo.name }}{% endblock %}
{%block tag %}home{% endblock %}


{% block repo %}

<h2>Request pull
  <a href="{{ url_for('view_repo', username=username, repo=repo.name)}}">
    {{ repo.name }}
  </a>

  (<a href="{{ url_for('view_tree', username=username,
               repo=repo.name, identifier=commitid) }}"
    >tree</a>)

</h2>

{% if pull_request %}
<div class="header">
    <h3>Title: {{ pull_request.title }}</h3>
    <ul class="buttons">
  {% if pull_request.status and repo_admin %}
      <li>
        <form action="{{ url_for('merge_request_pull', username=username,
            repo=repo.name, requestid=requestid) }}" method="POST">
          {{ mergeform.csrf_token }}
          <input class="button" type="submit" value="Merge"/>
        </form>
      </li>
      <li>
        <form action="{{ url_for('cancel_request_pull', username=username,
            repo=repo.name, requestid=requestid) }}" method="POST">
          {{ mergeform.csrf_token }}
          <input type="submit" value="Close" id="cancel_pr" class="button"/>
        </form>
      </li>
  {% elif pull_request and pull_request.status == False %}
    <li>
      <span class="error">Merged</span>
    </li>
  {% endif %}
      <li>
        <a class="button patch" href="{{ url_for('request_pull_patch', username=username,
            repo=repo.name, requestid=requestid) }}">Patch</a>
      </li>
    </ul>
</div>
{% endif %}

{% if form %}
<section class="new_project">
  <form action="{{ url_for('.new_request_pull', username=username,
    repo=repo.name, commitid=commitid, branch_from=branch_from,
    branch_to=branch_to) }}" method="post">
    <table>
      {{ render_field_in_row(form.title) }}
      <tr>
        <td>To branch</td>
        <td>
          <select id="branch_select" name="branch_to">
              <option>{{ branch_to }}</option>
            {% for branch in branches |reverse %}
              {% if branch != branch_to %}
              <option>{{ branch }}</option>
              {% endif %}
            {% endfor %}
          </select>
        </td>
      </tr>
    </table>
    <p class="buttons indent">
      <input type="submit" class="submit positive button" value="Create">
      {{ form.csrf_token }}
      <a href="{{ url_for('view_repo', username=username, repo=repo.name)}}">
        <input type="button" value="Cancel" />
      </a>
    </p>
  </form>
</section>
{% endif %}

<section class="commit_list">
  <ul>
    {% for commit in diff_commits %}
    <li>
    {% if pull_request and pull_request.status and pull_request.repo_from.is_fork %}
      <a href="{{ url_for('view_commit', username=pull_request.repo_from.user.user,
                  repo=pull_request.repo_from.name, commitid=commit.oid.hex)}}">
    {% else %}
      <a href="{{ url_for('view_commit', username=username,
                  repo=repo.name, commitid=commit.oid.hex)}}">
    {% endif %}
        <span class="commitid">{{ commit.oid.hex|short }}</span>
        {{ commit.message.split('\n')[0] }}
      </a>
    </li>
    {% else %}
      <p class="error"> No commits found </p>
    {% endfor %}
  </ul>
</section>

<section class="request_diff">


{% if diff %}
{% for patch in diff %}
    <span class="addrem_bar">
      {% if (patch.additions + patch.deletions) %}
        <span style="width: {{ (100.0 * patch.additions / (patch.additions + patch.deletions))|round|int }}%">
            {% if patch.additions > 0 %}+{{ patch.additions }}{% endif %}
            {% if patch.deletions > 0 %}-{{ patch.deletions }}{% endif %}
        </span>
      {% endif %}
    </span>
    {{ patch.new_file_path }}
{% autoescape false %}
    {{ patch | patch_to_diff | html_diff | format_loc(
            filename=patch.new_file_path, prequest=pull_request)}}
{% endautoescape %}
{% endfor %}
{% endif %}

</section>




{% endblock %}

{% block jscripts %}
{{ super() }}
<script type="text/javascript">
 $(function(){
  $( "#branch_select" ).change(
    function() {
      var sel = $('#branch_select');
      var final_url = "{{ url_for('.new_request_pull', username=username,
        repo=repo.name, commitid=commitid, branch_from=branch_from,
        branch_to='--') }}";
      final_url = final_url.replace('--', sel.val());
      window.location.href = final_url;
    }
  );
{% if pull_request %}
{# These lines are only for existing pull-requests, not new ones #}
  $('#cancel_pr').click(function(){
        return window.confirm("Are you sure you want to close this requested pull?");
  });
 });

  function comment() {
    $( ".cancel" ).click(
      function() {
        $(this).parent().parent().parent().parent().remove();
      }
    );
  };

 $(function(){
  $( "tr" ).hover(
    function() {
      $( this ).find( "img" ).show().width(13);
    }, function() {
      $( this ).find( "img" ).hide();
    }
  );

  $( ".prc" ).click(
    function() {
      var row = $( this ).attr('data-row');
      var commit = $( this ).attr('data-commit');
      var url = "{{ url_for(
        'pull_request_add_comment', username=username, repo=repo.name,
        requestid=requestid, commit='', row='') }}".slice(0, -1);
      url = url + commit + '/' + row;
      var rowid = $(this).prev().find('a').attr('id');
      var table = $( this ).parent().parent();
      var nextid = rowid.replace('_' + row, '_' + (Number(row) + 1));
      var next_row = table.find('#' + nextid).parent().parent();
      if (next_row.prev().find('.pr_comment_form').length == 0){
        $.get( url , function( data ) {
          next_row.before(
            '<tr><td></td><td colspan="2" class="pr_comment_form">' + data + '</td></tr>' );
          comment();
        });
      } else {
          next_row.prev().find('.pr_comment_form').parent().remove();
      }
    }
  );
{% endif %}

 });
</script>
{% endblock %}