فهرست منبع

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)
Alexey Agafonov 5 سال پیش
والد
کامیت
209569a035
2فایلهای تغییر یافته به همراه17 افزوده شده و 1 حذف شده
  1. 7 1
      routes/repo/repo.go
  2. 10 0
      templates/repo/user_cards.tmpl

+ 7 - 1
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":

+ 10 - 0
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>