summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-05 18:08:42 -0500
committerUnknwon <u@gogs.io>2016-03-05 18:08:42 -0500
commit045f14fbd0e3553521f5092cf839be363c74a090 (patch)
tree9c82f5111c5c5262c97bd7936462fa4170e76b4f /routers/repo
parent05d8664f15013b0159b3689bda84e89dd7be22fd (diff)
downloadgitea-045f14fbd0e3553521f5092cf839be363c74a090.tar.gz
gitea-045f14fbd0e3553521f5092cf839be363c74a090.zip
#1146 finsih UI work for access mode of collaborators
Collaborators have write access as default, and can be changed via repository collaboration settings page to change between read, write and admin.
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/setting.go39
1 files changed, 21 insertions, 18 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index d72b3fa118..e6b3580a1c 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -257,30 +257,13 @@ func Collaboration(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsCollaboration"] = true
- // Delete collaborator.
- remove := strings.ToLower(ctx.Query("remove"))
- if len(remove) > 0 && remove != ctx.Repo.Owner.LowerName {
- u, err := models.GetUserByName(remove)
- if err != nil {
- ctx.Handle(500, "GetUserByName", err)
- return
- }
- if err := ctx.Repo.Repository.DeleteCollaborator(u); err != nil {
- ctx.Handle(500, "DeleteCollaborator", err)
- return
- }
- ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
- ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
- return
- }
-
users, err := ctx.Repo.Repository.GetCollaborators()
if err != nil {
ctx.Handle(500, "GetCollaborators", err)
return
}
-
ctx.Data["Collaborators"] = users
+
ctx.HTML(200, COLLABORATION)
}
@@ -332,6 +315,26 @@ func CollaborationPost(ctx *middleware.Context) {
ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path)
}
+func ChangeCollaborationAccessMode(ctx *middleware.Context) {
+ if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(
+ ctx.QueryInt64("uid"),
+ models.AccessMode(ctx.QueryInt("mode"))); err != nil {
+ log.Error(4, "ChangeCollaborationAccessMode: %v", err)
+ }
+}
+
+func DeleteCollaboration(ctx *middleware.Context) {
+ if err := ctx.Repo.Repository.DeleteCollaboration(ctx.QueryInt64("id")); err != nil {
+ ctx.Flash.Error("DeleteCollaboration: " + err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": ctx.Repo.RepoLink + "/settings/collaboration",
+ })
+}
+
func parseOwnerAndRepo(ctx *middleware.Context) (*models.User, *models.Repository) {
owner, err := models.GetUserByName(ctx.Params(":username"))
if err != nil {