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

{% block title %}{{ select.capitalize() }} - {{ repo.name }}{% endblock %}
{%block tag %}home{% endblock %}

{% block header %}
<link href="{{ url_for('static', filename='fontawesome/font-awesome.min.css') }}"
  rel="stylesheet" />
{% endblock %}

{% block repo %}

<section class="settings">
  <h2>Settings</h2>

  <div>
    <h3>Update project</h3>
    <form action="{{ url_for('.update_project',
                    username=username, repo=repo.name) }}" method="post">
      <table>
        <tr>
          <td>
            <label for="description">Description</label>
          </td>
          <td>
            <input name="description" value="{{ repo.description }}" /> <br />
          </td>
        </tr>
        <tr>
          <td>
            <label for="url">Project's url</label>
          </td>
          <td>
            <input name="url" value="{{ repo.url if repo.url else '' }}" />
          </td>
        </tr>
        <tr>
          <td>
            <label for="avatar">Avatar email</label>
          </td>
          <td>
            <input name="avatar_email" value="{{ repo.avatar_email if repo.avatar_email else '' }}" />
          </td>
        </tr>
        <tr>
          <td>
            <label for="tags">Project tags</label>
          </td>
          <td>
            <input name="tags" value="{{ repo.tags_text |join(', ') if repo.tags else '' }}" />
          </td>
        </tr>
      </table>
      <button type="submit" title="Update description">
        Update
      </button>
      {{ form.csrf_token }}
    </form>
  </div>
  <div>
    <h3> Default Branch </h3>

    <form action="{{ url_for('change_ref_head',
                     username=username, repo=repo.name) }}" method="post">
    {{ branches_form.csrf_token }}
    {{ branches_form.branches }}
    <input type="submit" value="Make Default"/>
  </form>
  </div>
  <div>
    <h3>Private web-hook key</h3>
    <p>
      Each message sent to the web-hook are signed via hmac and SHA1 using
      this private key.
    </p>
    <p>
      This key is private to your project, make sure to store in a safe place
      and do not share it.
    </p>
    <pre>
        {{ repo.hook_token }}
    </pre>
    <form action="{{ url_for('.new_repo_hook_token',
                  username=username, repo=repo.name) }}"
        method="post" class="icon">
    <button class="icon_button" type="submit"
      onclick="return confirm('Are you sure to generate a new token for '
        + 'this project/fork? \nThis will break all web hook in place and '
        + 'cannot be un-done.');"
      title="Generate a new hook token">
      <span class="icon icon-refresh blue"></span>
      Re-generate
    </button>
    {{ form.csrf_token }}
  </form>
  </div>

  <div>
    <h3>API key</h3>
    <p>
      API keys are tokens used to authenticate you on pagure. They can also
      be used to grant access to 3rd party application to behave on this
      project on your name.
    </p>
    <p>
      These keys are valid for <span class="strong">60</span> days.
    </p>
    <p>
      These keys are private to your project, make sure to store in a safe
      place and do not share it.
    </p>

    {% if repo.tokens %}
    <table>
    {% for token in repo.tokens %}
      {% if token.user.username == g.fas_user.username %}
      <tr>
        <td>
          {{ token.id }}
        </td>
        <td>
        {% if token.expired %}
          <span class="error">Expired</span> since {{ token.expiration.date() }}
        {% else %}
          <span class="message">Valid</span> until: {{ token.expiration.date() }}
        {% endif %}
        </td>
        <td>
          <a class="clickable"
            onclick="show_acls({{ token.acls_list |safe }})">ACLs</a>
        </td>
        <td>
          <form action="{{ url_for('.revoke_api_token',
                username=username, repo=repo.name, token_id=token.id) }}"
            method="post" class="icon">
            <button class="icon_button" type="submit"
                onclick="return confirm('Are you sure to revoke this token ?'
                    + '\nThis will break all application using it and '
                    + 'cannot be un-done.');"
                title="Revoke token">
              <span class="icon icon-trash blue"></span>
              Revoke
            </button>
            {{ form.csrf_token }}
          </form>
        </td>
      </tr>
      {% endif %}
    {% endfor %}
    </table>
    {% endif %}

    <a href="{{ url_for('.add_token', username=username, repo=repo.name) }}"
        method="post" class="icon">
    <button class="icon_button" type="submit"
      title="Generate a new API token">
      <span class="icon icon-plus blue"></span>
      Get a new Key
    </button>
    </a>
  </div>


  <h3>Project's options</h3>
  <form action="{{ url_for('.view_settings',
                  username=username, repo=repo.name) }}" method="post">
  <table>
    {% for key in repo.settings | sort %}
    {% if not config.get('PROJECT_TICKETS', True) and key in ['issue_tracker'] %}
    {% elif not config.get('DOC_APP_URL') and key in ['project_documentation'] %}
    {% else %}
    <tr>
      <td><label for="{{ key }}">Activate {{ key | replace('_', ' ') }}</label></td>
      <td>
        {% if repo.settings[key] in [True, False, 'y'] %}
        <input id="{{ key }}" type="checkbox" value="y" name="{{ key }}" {%
         if repo.settings[key] -%}checked=""{%- endif -%}/>
        {% else %}
        <input id="{{ key }}" type="text" {% if repo.settings[key]
            %}value="{{ repo.settings[key] }}"{% endif %} name="{{ key }}" />
        {% endif %}
      </td>
    </tr>
    {% endif %}
    {% endfor %}
  </table>
  <p class="buttons indent">
      <input type="submit" class="submit positive button" value="Update">
      <input type="button" value="Cancel" class="button" onclick="history.back();">
      {{ form.csrf_token }}
    </p>
  </form>

  <h3>Re-generate git repos</h3>
  <form action="{{ url_for('.regenerate_git',
                  username=username, repo=repo.name) }}" method="post"
        class="icon">
    <input name="regenerate" value="tickets" type="hidden"/>
    <button class="" type="submit"
      title="Regenerate tickets git repo">
      <span class="icon icon-refresh blue"></span>
      Regenerate the git repo for issues
    </button>
    {{ form.csrf_token }}
  </form>
  <form action="{{ url_for('.regenerate_git',
                  username=username, repo=repo.name) }}" method="post"
        class="icon">
    <input name="regenerate" value="requests" type="hidden"/>
    <button class="icon_button" type="submit"
      title="Regenerate requests git repo">
      <span class="icon icon-refresh blue"></span>
      Regenerate the git repo for requests
    </button>
    {{ form.csrf_token }}
  </form>
</section>

<section class="users">
  <h2>Users and Groups</h2>

  <p>Here below is the list of user having commit rights to this repo.</p>

  <p>
    <a href="{{ url_for('.add_user', username=username, repo=repo.name) }}"
        class="icon icon-plus-sign blue">
        [add]
    </a>

    <a href="{{ url_for('.add_group_project', username=username, repo=repo.name) }}"
        class="icon icon-plus-sign blue">
        [add group]
    </a>
  </p>

  <ul>
    <li>
      <a href="{{ url_for('.view_user', username=repo.user.user) }}">{{ repo.user.user }}</a>
      (owner)
    </li>
  {% for user in repo.users %}
    <li>
      <a href="{{ url_for('.view_user', username=user.user) }}">{{ user.user }}</a>
      <form class="icon del_icon" method="POST"
        action="{{ url_for('.remove_user', username=username, repo=repo.name, userid=user.id) }}">
        <button
          onclick="return confirm('You sure you want to remove this user from this project?');"
          title="Remove user">
          <span class="icon icon-trash blue"></span>
        </button>
        {{ form.csrf_token }}
      </form>
    </li>
  {% endfor %}
  {% for group in repo.groups %}
    <li>
      <a href="{{ url_for('.view_group', group=group.group_name) }}">@{{ group.group_name }}</a>
      <form class="icon del_icon" method="POST"
        action="">
        <button
          onclick="return confirm('You sure you want to remove this group from this project?');"
          title="Remove group">
          <span class="icon icon-trash blue"></span>
        </button>
        {{ form.csrf_token }}
      </form>
    </li>
  {% endfor %}
  </ul>
</section>


{% if plugins %}
<section class="hooks">
  <h2>Hooks</h2>
  <div id="accordion">
    {% for plugin in plugins %}
      <h3 class="plugin_title" data-plugin="{{ plugin }}">{{ plugin }}</h3>
      <div id="body_{{ plugin }}"></div>
    {% endfor %}
  </div>
</section>
{% endif %}


{% if config.get('PROJECT_TICKETS', True) %}
<section class="tags">
  <h2>Tags</h2>

  <p>
    Here below is the list of tags associated with one or more issue of
    the project.
  </p>

  <ul>
  {% for tag in tags %}
    <li>
      <a href="{{ url_for('view_issues', username=username,
        repo=repo.name, tags=tag.tag) }}">
        {{ tag.tag }}
      </a>
      <form class="icon del_icon" method="POST"
        action="{{ url_for('remove_tag', username=username, repo=repo.name) }}">
        <input type="hidden" value="{{ tag.tag }}" name="tag" />
        {{ tag_form.csrf_token }}
        <button
          onclick="return confirm('Do you really want to remove the tag: {{ tag.tag }}?');"
          title="Remove tag">
          <span class="icon icon-trash blue"></span>
        </button>
      </form>
      <a href="{{ url_for(
            '.edit_tag',username=username, repo=repo.name, tag=tag.tag) }}">
        <button class="icon_button" title="Edit tag">
          <span class="icon icon-edit blue"></span>
        </button>
      </a>
    </li>
  {% endfor %}
  </ul>
</section>
{% endif %}

<section class="delete">
  <form action="{{ url_for('.delete_repo',
                  username=username, repo=repo.name) }}"
        method="post" class="icon">
    <button class="icon_button" type="submit"
      onclick="return confirm('Are you sure to delete this project/fork? \nThis is final and cannot be un-done.');"
      title="Delete the project/fork">
      <h3>
        <span class="icon icon-trash blue"></span>
        Delete project
      </h3>
    </button>
  </form>
</section>

{% endblock %}

{% block jscripts %}
{{ super() }}
<script>
  function show_acls(acls) {
    var _txt = '<div title="ACLs details" id="show_meeting">'
      + '<ul>';

    for (i = 0; i < acls.length; i++) {
        _txt += '<li>' + acls[i] + '</li>';
    }

    _txt += '</ul>' + '</div>';
    var _elt = $(_txt);
    var _height = $(window).height() * 0.8;
    _elt.dialog({
        height: 250,
        width: 250,
        modal: true,
        cache: false,
    });
    }

  $(function() {
    $( "#accordion" ).accordion({
      collapsible: true,
      active: false,
      heightStyle: 'content',
      activate: function( event, ui ) {
        var _plugin = ui.newHeader.attr('data-plugin');
        if (!_plugin) {
          return false;
        }
        var _url = "{{ url_for('.view_plugin', repo=repo.name, username=username, plugin='') }}";
        _url += _plugin + '/0';
        console.log(_url);
        $.ajax({
            url: _url ,
            type: 'GET',
            dataType: 'html',
            success: function(res) {
                ui.newPanel.html(res);
            },
        });
        return false;

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