summaryrefslogtreecommitdiffstats
path: root/routers
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
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')
-rw-r--r--routers/admin/auths.go10
-rw-r--r--routers/repo/setting.go39
2 files changed, 28 insertions, 21 deletions
diff --git a/routers/admin/auths.go b/routers/admin/auths.go
index c519d5a7e0..b9e86a1ef5 100644
--- a/routers/admin/auths.go
+++ b/routers/admin/auths.go
@@ -5,6 +5,8 @@
package admin
import (
+ "fmt"
+
"github.com/Unknwon/com"
"github.com/go-xorm/core"
@@ -218,11 +220,13 @@ func DeleteAuthSource(ctx *middleware.Context) {
if err = models.DeleteSource(source); err != nil {
switch err {
case models.ErrAuthenticationUserUsed:
- ctx.Flash.Error("form.still_own_user")
- ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid"))
+ ctx.Flash.Error(ctx.Tr("admin.auths.still_in_used"))
default:
- ctx.Handle(500, "DeleteSource", err)
+ ctx.Flash.Error(fmt.Sprintf("DeleteSource: %v", err))
}
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid"),
+ })
return
}
log.Trace("Authentication deleted by admin(%s): %d", ctx.User.Name, source.ID)
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 {