repo: allow admin to remove observers from the repository (#5782) (#5803)

* admin can remove observers from the repository (#5782)

* admin can remove observers from the repository (#5782)

* admin can remove observers from the repository (#5782)

* admin can remove observers from the repository (#5782)

* admin can remove observers from the repository (#5782)
This commit is contained in:
Alexey Agafonov
2019-09-22 06:37:20 +03:00
committed by Jiahua Chen
parent 0852e83eec
commit 209569a035
2 changed files with 17 additions and 1 deletions

View File

@@ -235,7 +235,13 @@ func Action(c *context.Context) {
case "watch":
err = models.WatchRepo(c.User.ID, c.Repo.Repository.ID, true)
case "unwatch":
err = models.WatchRepo(c.User.ID, c.Repo.Repository.ID, false)
if userID := c.QueryInt64("user_id"); userID != 0 {
if c.User.IsAdmin {
err = models.WatchRepo(userID, c.Repo.Repository.ID, false)
}
} else {
err = models.WatchRepo(c.User.ID, c.Repo.Repository.ID, false)
}
case "star":
err = models.StarRepo(c.User.ID, c.Repo.Repository.ID, true)
case "unstar":

View File

@@ -19,6 +19,16 @@
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}}
{{end}}
</div>
{{if $.IsAdmin}}
<form class="display inline" action="{{$.RepoLink}}/action/unwatch?redirect_to={{$.Link}}" method="POST">
{{$.CSRFTokenHTML}}
<input type="hidden" name="user_id" value="{{.ID}}">
<div class="ui labeled button" tabindex="0">
<button class="ui red small button">{{$.i18n.Tr "repo.unwatch"}}</button>
</div>
</form>
{{end}}
</li>
{{end}}
</ul>