Implement global configuration for new organizations
This commit is contained in:
parent
7bdc6e8bbc
commit
fb0c45abb1
|
|
@ -245,6 +245,11 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
|
||||||
; Default value for AllowCreateOrganization
|
; Default value for AllowCreateOrganization
|
||||||
; New user will have rights set to create organizations depending on this setting
|
; New user will have rights set to create organizations depending on this setting
|
||||||
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
|
||||||
|
; Either "public", "limited" or "private", default is "public"
|
||||||
|
; Limited is for signed user only
|
||||||
|
; Private is only for member of the organization
|
||||||
|
; Public is for everyone
|
||||||
|
DEFAULT_VISIBILITY = public
|
||||||
; Default value for the domain part of the user's email address in the git log
|
; Default value for the domain part of the user's email address in the git log
|
||||||
; if he has set KeepEmailPrivate true. The user's email replaced with a
|
; if he has set KeepEmailPrivate true. The user's email replaced with a
|
||||||
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
|
; concatenation of the user name in lower case, "@" and NO_REPLY_ADDRESS.
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
"github.com/go-xorm/builder"
|
"github.com/go-xorm/builder"
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
|
|
@ -125,7 +127,7 @@ func CreateOrganization(org, owner *User) (err error) {
|
||||||
org.NumTeams = 1
|
org.NumTeams = 1
|
||||||
org.NumMembers = 1
|
org.NumMembers = 1
|
||||||
org.Type = UserTypeOrganization
|
org.Type = UserTypeOrganization
|
||||||
org.Visibility = VisibleTypePublic
|
org.Visibility = VisibleType(setting.Service.DefaultVisibilityMode)
|
||||||
|
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sessionRelease(sess)
|
defer sessionRelease(sess)
|
||||||
|
|
|
||||||
|
|
@ -991,6 +991,8 @@ var Service struct {
|
||||||
DefaultKeepEmailPrivate bool
|
DefaultKeepEmailPrivate bool
|
||||||
DefaultAllowCreateOrganization bool
|
DefaultAllowCreateOrganization bool
|
||||||
NoReplyAddress string
|
NoReplyAddress string
|
||||||
|
DefaultVisibility string
|
||||||
|
DefaultVisibilityMode int
|
||||||
|
|
||||||
// OpenID settings
|
// OpenID settings
|
||||||
EnableOpenIDSignIn bool
|
EnableOpenIDSignIn bool
|
||||||
|
|
@ -999,6 +1001,12 @@ var Service struct {
|
||||||
OpenIDBlacklist []*regexp.Regexp
|
OpenIDBlacklist []*regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var visibilityModes = map[string]int{
|
||||||
|
"public": 1,
|
||||||
|
"limited": 2,
|
||||||
|
"private": 3,
|
||||||
|
}
|
||||||
|
|
||||||
func newService() {
|
func newService() {
|
||||||
sec := Cfg.Section("service")
|
sec := Cfg.Section("service")
|
||||||
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
|
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
|
||||||
|
|
@ -1012,6 +1020,8 @@ func newService() {
|
||||||
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
|
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
|
||||||
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
|
Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
|
||||||
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
||||||
|
Service.DefaultVisibility = sec.Key("DEFAULT_VISIBILITY").In("public", []string{"public", "limited", "private"})
|
||||||
|
Service.DefaultVisibilityMode = visibilityModes[Service.DefaultVisibility]
|
||||||
|
|
||||||
sec = Cfg.Section("openid")
|
sec = Cfg.Section("openid")
|
||||||
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(false)
|
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(false)
|
||||||
|
|
|
||||||
|
|
@ -1286,6 +1286,7 @@ config.active_code_lives = Active Code Lives
|
||||||
config.reset_password_code_lives = Reset Password Code Expiry Time
|
config.reset_password_code_lives = Reset Password Code Expiry Time
|
||||||
config.default_keep_email_private = Default Value for Keep Email Private
|
config.default_keep_email_private = Default Value for Keep Email Private
|
||||||
config.default_allow_create_organization = Default permission to create Organizations
|
config.default_allow_create_organization = Default permission to create Organizations
|
||||||
|
config.default_visibility_organization = Default visibility for new Organizations
|
||||||
config.no_reply_address = No-reply Address
|
config.no_reply_address = No-reply Address
|
||||||
|
|
||||||
config.webhook_config = Webhook Configuration
|
config.webhook_config = Webhook Configuration
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,9 @@
|
||||||
<dd><i class="fa fa{{if .Service.DefaultKeepEmailPrivate}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Service.DefaultKeepEmailPrivate}}-check{{end}}-square-o"></i></dd>
|
||||||
<dt>{{.i18n.Tr "admin.config.default_allow_create_organization"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.default_allow_create_organization"}}</dt>
|
||||||
<dd><i class="fa fa{{if .Service.DefaultAllowCreateOrganization}}-check{{end}}-square-o"></i></dd>
|
<dd><i class="fa fa{{if .Service.DefaultAllowCreateOrganization}}-check{{end}}-square-o"></i></dd>
|
||||||
|
<dt>{{.i18n.Tr "admin.config.default_visibility_organization"}}</dt>
|
||||||
|
<dd>{{.Service.DefaultVisibility}}</dd>
|
||||||
|
|
||||||
<dt>{{.i18n.Tr "admin.config.no_reply_address"}}</dt>
|
<dt>{{.i18n.Tr "admin.config.no_reply_address"}}</dt>
|
||||||
<dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd>
|
<dd>{{if .Service.NoReplyAddress}}{{.Service.NoReplyAddress}}{{else}}-{{end}}</dd>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user