Page: /org/:orgname/settings
This commit is contained in:
parent
2935ee440c
commit
5acc948562
19 changed files with 393 additions and 184 deletions
|
@ -27,15 +27,17 @@ func (f *CreateOrgForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i
|
|||
validate(errs, ctx.Data, f, l)
|
||||
}
|
||||
|
||||
type OrgSettingForm struct {
|
||||
DisplayName string `form:"display_name" binding:"Required;MaxSize(100)"`
|
||||
type UpdateOrgSettingForm struct {
|
||||
OrgUserName string `form:"uname" binding:"Required;MaxSize(35)"`
|
||||
OrgFullName string `form:"fullname" binding:"MaxSize(100)"`
|
||||
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
|
||||
Description string `form:"desc" binding:"MaxSize(255)"`
|
||||
Website string `form:"site" binding:"Url;MaxSize(100)"`
|
||||
Website string `form:"website" binding:"Url;MaxSize(100)"`
|
||||
Location string `form:"location" binding:"MaxSize(50)"`
|
||||
Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
|
||||
}
|
||||
|
||||
func (f *OrgSettingForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
|
||||
func (f *UpdateOrgSettingForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
|
||||
validate(errs, ctx.Data, f, l)
|
||||
}
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ func (f *SignInForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n
|
|||
|
||||
type UpdateProfileForm struct {
|
||||
UserName string `form:"uname" binding:"Required;MaxSize(35)"`
|
||||
FullName string `form:"fullname" binding:"MaxSize(40)"`
|
||||
FullName string `form:"fullname" binding:"MaxSize(100)"`
|
||||
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
|
||||
Website string `form:"website" binding:"Url;MaxSize(50)"`
|
||||
Website string `form:"website" binding:"Url;MaxSize(100)"`
|
||||
Location string `form:"location" binding:"MaxSize(50)"`
|
||||
Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
|
||||
}
|
||||
|
|
|
@ -64,6 +64,12 @@ type Context struct {
|
|||
CommitsCount int
|
||||
Mirror *models.Mirror
|
||||
}
|
||||
|
||||
Org struct {
|
||||
IsOwner bool
|
||||
IsMember bool
|
||||
Organization *models.User
|
||||
}
|
||||
}
|
||||
|
||||
// Query querys form parameter.
|
||||
|
|
55
modules/middleware/org.go
Normal file
55
modules/middleware/org.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/Unknwon/macaron"
|
||||
|
||||
"github.com/gogits/gogs/models"
|
||||
)
|
||||
|
||||
func OrgAssignment(redirect bool, args ...bool) macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
var (
|
||||
requireMember bool
|
||||
requireOwner bool
|
||||
)
|
||||
if len(args) >= 1 {
|
||||
requireMember = args[0]
|
||||
}
|
||||
if len(args) >= 2 {
|
||||
requireOwner = args[1]
|
||||
}
|
||||
|
||||
orgName := ctx.Params(":org")
|
||||
|
||||
var err error
|
||||
ctx.Org.Organization, err = models.GetUserByName(orgName)
|
||||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "GetUserByName", err)
|
||||
} else if redirect {
|
||||
ctx.Redirect("/")
|
||||
} else {
|
||||
ctx.Handle(500, "GetUserByName", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.Data["Org"] = ctx.Org.Organization
|
||||
|
||||
if ctx.IsSigned {
|
||||
ctx.Org.IsOwner = ctx.Org.Organization.IsOrgOwner(ctx.User.Id)
|
||||
if ctx.Org.IsOwner {
|
||||
ctx.Org.IsMember = true
|
||||
} else {
|
||||
ctx.Org.IsMember = ctx.Org.Organization.IsOrgMember(ctx.User.Id)
|
||||
}
|
||||
}
|
||||
if (requireMember && !ctx.Org.IsMember) || (requireOwner && !ctx.Org.IsOwner) {
|
||||
ctx.Handle(404, "OrgAssignment", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,15 +20,13 @@ import (
|
|||
|
||||
func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
// To valid brach name.
|
||||
var validBranch bool
|
||||
// To display bare quick start if it is a bare repo.
|
||||
var displayBare bool
|
||||
|
||||
var (
|
||||
validBranch bool // To valid brach name.
|
||||
displayBare bool // To display bare page if it is a bare repo.
|
||||
)
|
||||
if len(args) >= 1 {
|
||||
validBranch = args[0]
|
||||
}
|
||||
|
||||
if len(args) >= 2 {
|
||||
displayBare = args[1]
|
||||
}
|
||||
|
@ -60,12 +58,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||
if err != nil {
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Handle(404, "GetUserByName", err)
|
||||
return
|
||||
} else if redirect {
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
} else {
|
||||
ctx.Handle(500, "GetUserByName", err)
|
||||
}
|
||||
ctx.Handle(500, "GetUserByName", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue