diff --git a/models/user.go b/models/user.go index 7e6bbd5dc..8c136e25f 100644 --- a/models/user.go +++ b/models/user.go @@ -72,6 +72,20 @@ var ( ErrUnsupportedLoginType = errors.New("Login source is unknown") ) +// VisibleType define the visibility (Organization only) +type VisibleType int + +const ( + // VisibleType Visible for everyone + VisibleTypePublic VisibleType = iota + 1 + + // VisibleTypeLimited Visible for every connected user + VisibleTypeLimited + + // VisibleTypePrivate Visible only for organization's members + VisibleTypePrivate +) + // User represents the object of individual and member of organization. type User struct { ID int64 `xorm:"pk autoincr"` @@ -129,8 +143,9 @@ type User struct { Description string NumTeams int NumMembers int - Teams []*Team `xorm:"-"` - Members []*User `xorm:"-"` + Teams []*Team `xorm:"-"` + Members []*User `xorm:"-"` + Visibility VisibleType `xorm:"DEFAULT 1"` // Preferences DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"` diff --git a/modules/auth/org.go b/modules/auth/org.go index d6c26b633..f1f5e17a0 100644 --- a/modules/auth/org.go +++ b/modules/auth/org.go @@ -35,6 +35,7 @@ type UpdateOrgSettingForm struct { Description string `binding:"MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` + Visibility models.VisibleType MaxRepoCreation int } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 75f02a626..b5688e1c5 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -992,6 +992,11 @@ settings.options = Options settings.full_name = Full Name settings.website = Website settings.location = Location +settings.visibility = Visibility +settings.visibility.public = Public +settings.visibility.limited = Limited (Visible to connected user only) +settings.visibility.private = Private (Visible only to organization members) + settings.update_settings = Update Settings settings.update_setting_success = Organization settings have been updated. settings.change_orgname_prompt = This change will change the links to the organization. @@ -1424,4 +1429,4 @@ error.failed_retrieval_gpg_keys = "Failed to retrieve any key attached to the co [units] error.no_unit_allowed_repo = Cannot find any unit allowed on this repository -error.unit_not_allowed = You have not allowed to visit this repository unit \ No newline at end of file +error.unit_not_allowed = You have not allowed to visit this repository unit diff --git a/routers/org/setting.go b/routers/org/setting.go index 4faed77d0..47235fcaf 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -29,6 +29,7 @@ const ( func Settings(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsOptions"] = true + ctx.Data["CurrentVisibility"] = models.VisibleType(ctx.Org.Organization.Visibility) ctx.HTML(200, tplSettingsOptions) } @@ -79,6 +80,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { org.Description = form.Description org.Website = form.Website org.Location = form.Location + org.Visibility = form.Visibility if err := models.UpdateUser(org); err != nil { ctx.Handle(500, "UpdateUser", err) return diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 804136543..07941988d 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -33,6 +33,29 @@ +
+