~edwargix/git.sr.ht

39b926ca100eca1317c4eb3538156177c9e97312 — Drew DeVault 6 years ago a751d89
Allow users to reconfigure repo visibility
M gitsrht/access.py => gitsrht/access.py +1 -0
@@ 40,6 40,7 @@ def get_access(repo, user=None):
        if repo.visibility == RepoVisibility.public or \
                repo.visibility == RepoVisibility.unlisted:
            return UserAccess.read
        return UserAccess.none
    if repo.owner_id == user.id:
        return UserAccess.read | UserAccess.write | UserAccess.manage
    acl = Access.query.filter(Access.repo_id == repo.id).first()

M gitsrht/blueprints/manage.py => gitsrht/blueprints/manage.py +4 -0
@@ 52,6 52,10 @@ def settings_info_POST(owner_name, repo_name):
        repo = repo.new_repo
    valid = Validation(request)
    desc = valid.optional("description", default=repo.description)
    visibility = valid.optional("visibility",
            cls=RepoVisibility,
            default=repo.visibility)
    repo.visibility = visibility
    repo.description = desc
    db.session.commit()
    return redirect("/{}/{}/settings/info".format(owner_name, repo_name))

M gitsrht/templates/cgit.html => gitsrht/templates/cgit.html +5 -0
@@ 5,6 5,11 @@
    <div class="col-md-12">
      <h2>
        <a href="/{{ owner.canonical_name }}">{{ owner.canonical_name }}</a>/{{ repo.name }}
        <small class="text-muted">
        {% if repo.visibility.value != "public" %}
          {{ repo.visibility.value }}
        {% endif %}
        </small>
        <small class="repo-nav">
        {% if has_access(repo, UserAccess.manage) %}
          <a href="/{{ owner.canonical_name }}/{{ repo.name }}/settings/info">Settings</a>

M gitsrht/templates/settings_access.html => gitsrht/templates/settings_access.html +5 -1
@@ 38,7 38,11 @@
    </table>
    <h4>Grant Access</h4>
    {% endif %}
    <form method="POST">
    <form method="POST"
      action="/~{{owner.username}}/{{
        repo.name
      }}/settings/access/grant"
    >
      <div class="form-group {{valid.cls("user")}}">
        <label for="user">User</label>
        <input

M gitsrht/templates/settings_info.html => gitsrht/templates/settings_info.html +44 -0
@@ 29,6 29,50 @@
          name="description"
          value="{{repo.description}}" />
      </div>
      <fieldset class="form-group">
        <div class="form-check form-check-inline">
          <label
            class="form-check-label"
            title="Publically visible and listed on your profile"
          >
            <input
              class="form-check-input"
              type="radio"
              name="visibility"
              value="public"
              {{ "checked" if repo.visibility.value == "public" else "" }}
            > Public
          </label>
        </div>
        <div class="form-check form-check-inline">
          <label
              class="form-check-label"
              title="Visible to anyone with the link, but not shown on your profile"
            >
            <input
              class="form-check-input"
              type="radio"
              name="visibility"
              value="unlisted"
              {{ "checked" if repo.visibility.value == "unlisted" else "" }}
            > Unlisted
          </label>
        </div>
        <div class="form-check form-check-inline">
          <label
            class="form-check-label"
            title="Only visible to you and your collaborators"
          >
            <input
              class="form-check-input"
              type="radio"
              name="visibility"
              value="private"
              {{ "checked" if repo.visibility.value == "private" else "" }}
            > Private
          </label>
        </div>
      </fieldset>
      <button type="submit" class="btn btn-default pull-right">Save</button>
    </form>
  </div>