aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Agafonov <supmea@gmail.com>2019-09-22 06:37:20 +0300
committerJiahua Chen <u@gogs.io>2019-09-21 20:37:20 -0700
commit209569a0354fa943a9e3889191ab9733f81f656a (patch)
tree98e3e3dde94e935b7b5c4b9d9d4ec0f3bc3692f6
parent0852e83eec6e1bb92c5c27a3baf5b31222bf4c2d (diff)
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)
-rw-r--r--routes/repo/repo.go8
-rw-r--r--templates/repo/user_cards.tmpl10
2 files changed, 17 insertions, 1 deletions
diff --git a/routes/repo/repo.go b/routes/repo/repo.go
index 00dbc2f8..96a8b45d 100644
--- a/routes/repo/repo.go
+++ b/routes/repo/repo.go
@@ -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":
diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl
index a29ea997..bb6c6348 100644
--- a/templates/repo/user_cards.tmpl
+++ b/templates/repo/user_cards.tmpl
@@ -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>