| 
					
				 | 
			
			
				@@ -7,11 +7,9 @@ package user 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"io/ioutil" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"net/url" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"strings" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"github.com/Unknwon/com" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	"github.com/Unknwon/paginater" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	log "gopkg.in/clog.v1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"github.com/gogits/gogs/models" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -32,7 +30,7 @@ const ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	SETTINGS_SOCIAL        base.TplName = "user/settings/social" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	SETTINGS_APPLICATIONS  base.TplName = "user/settings/applications" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	SETTINGS_ORGANIZATIONS base.TplName = "user/settings/organizations" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	SETTINGS_REPOS         base.TplName = "user/settings/repos" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	SETTINGS_REPOSITORIES  base.TplName = "user/settings/repositories" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	SETTINGS_DELETE        base.TplName = "user/settings/delete" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	NOTIFICATION           base.TplName = "user/notification" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	SECURITY               base.TplName = "user/security" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -446,6 +444,9 @@ func SettingsLeaveOrganization(ctx *context.Context) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	err := models.RemoveOrgUser(ctx.QueryInt64("id"), ctx.User.ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if models.IsErrLastOrgOwner(err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		ctx.Flash.Error(ctx.Tr("form.last_org_owner")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ctx.Handle(500, "RemoveOrgUser", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ctx.JSON(200, map[string]interface{}{ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -454,63 +455,39 @@ func SettingsLeaveOrganization(ctx *context.Context) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func SettingsRepos(ctx *context.Context) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ctx.Data["Title"] = ctx.Tr("admin.repositories") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ctx.Data["Title"] = ctx.Tr("settings") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ctx.Data["PageIsSettingsRepositories"] = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	keyword := ctx.Query("q") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	page := ctx.QueryInt("page") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if page <= 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		page = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Keyword:  keyword, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		UserID:   ctx.User.ID, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		OrderBy:  "lower_name", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Page:     page, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		PageSize: setting.UI.Admin.RepoPagingNum, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	repos, err := models.GetUserAndCollaborativeRepositories(ctx.User.ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ctx.Handle(500, "SearchRepositoryByName", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ctx.Handle(500, "GetUserAndCollaborativeRepositories", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err = models.RepositoryList(repos).LoadAttributes(); err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		ctx.Handle(500, "LoadAttributes", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ctx.Data["Keyword"] = keyword 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ctx.Data["Total"] = count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ctx.Data["Page"] = paginater.New(int(count), setting.UI.Admin.RepoPagingNum, page, 5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ctx.Data["Repos"] = repos 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ctx.HTML(200, SETTINGS_REPOS) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ctx.HTML(200, SETTINGS_REPOSITORIES) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func SettingsDeleteRepo(ctx *context.Context) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func SettingsLeaveRepo(ctx *context.Context) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	repo, err := models.GetRepositoryByID(ctx.QueryInt64("id")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ctx.Handle(500, "GetRepositoryByID", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ctx.NotFoundOrServerError("GetRepositoryByID", errors.IsRepoNotExist, err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	// make sure the user owns the repository or is an admin before allowing them to delete it 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if repo.OwnerID == ctx.User.ID || ctx.User.IsAdmin { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err := models.DeleteRepository(repo.MustOwner().ID, repo.ID); err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ctx.Handle(500, "DeleteRepository", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		log.Trace("Repository deleted: %s/%s", repo.MustOwner().Name, repo.Name) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ctx.JSON(200, map[string]interface{}{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			"redirect": setting.AppSubUrl + "/user/settings/repos?page=" + ctx.Query("page") + "&q=" + url.QueryEscape(ctx.Query("q")), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// logged in user doesn't have rights to delete this repository 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		err := errors.New("You do not have rights to delete repository '" + repo.FullName() + "'") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ctx.Handle(403, "SettingsDeleteRepo", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err = repo.DeleteCollaboration(ctx.User.ID); err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		ctx.Handle(500, "DeleteCollaboration", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ctx.Flash.Success(ctx.Tr("settings.repos.leave_success", repo.FullName())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ctx.JSON(200, map[string]interface{}{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		"redirect": setting.AppSubUrl + "/user/settings/repositories", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func SettingsDelete(ctx *context.Context) { 
			 |