refactor quota settings

This commit is contained in:
woodsaj
2015-09-11 01:47:33 +08:00
parent 555cbeffa5
commit 852f9bd277
9 changed files with 59 additions and 43 deletions
+4
View File
@@ -126,6 +126,9 @@ var (
// SMTP email settings
Smtp SmtpSettings
// QUOTA
Quota QuotaSettings
)
type CommandLineArgs struct {
@@ -434,6 +437,7 @@ func NewConfigContext(args *CommandLineArgs) {
readSessionConfig()
readSmtpSettings()
readQuotaSettings()
if VerifyEmailEnabled && !Smtp.Enabled {
log.Warn("require_email_validation is enabled but smpt is disabled")
+17
View File
@@ -0,0 +1,17 @@
package setting
type QuotaSettings struct {
Enabled bool
Default map[string]int64
}
func readQuotaSettings() {
// set global defaults.
DefaultQuotas := make(map[string]int64)
quota := Cfg.Section("quota")
Quota.Enabled = quota.Key("enabled").MustBool(false)
DefaultQuotas["user"] = quota.Key("user").MustInt64(10)
DefaultQuotas["data_source"] = quota.Key("data_source").MustInt64(10)
DefaultQuotas["dashboard"] = quota.Key("dashboard").MustInt64(10)
Quota.Default = DefaultQuotas
}