From 3d8cfe22ced9fd4c72ceda7f89b405f689697912 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 5 Jun 2023 15:43:51 +0200 Subject: [PATCH 1/6] Allow Organisations to have a E-Mail --- modules/structs/org.go | 1 + options/locale/locale_en-US.ini | 1 + routers/api/v1/org/org.go | 10 +++++++++- routers/web/org/setting.go | 1 + services/convert/convert.go | 1 + services/forms/org.go | 1 + templates/org/home.tmpl | 3 +++ templates/org/settings/options.tmpl | 4 ++++ templates/swagger/v1_json.tmpl | 4 ++++ 9 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index 7c83dcdee7e4d..b3d5b565a242b 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -8,6 +8,7 @@ type Organization struct { ID int64 `json:"id"` Name string `json:"name"` FullName string `json:"full_name"` + EMail string `json:"email"` AvatarURL string `json:"avatar_url"` Description string `json:"description"` Website string `json:"website"` diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2245d9bae0e95..deca07e2a7b41 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2511,6 +2511,7 @@ form.create_org_not_allowed = You are not allowed to create an organization. settings = Settings settings.options = Organization settings.full_name = Full Name +settings.email = Contact E-Mail settings.website = Website settings.location = Location settings.permission = Permissions diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 4e30ad17620f3..143f4ffa2c69f 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -299,7 +299,15 @@ func Get(ctx *context.APIContext) { ctx.NotFound("HasOrgOrUserVisible", nil) return } - ctx.JSON(http.StatusOK, convert.ToOrganization(ctx, ctx.Org.Organization)) + + org := convert.ToOrganization(ctx, ctx.Org.Organization) + + // Don't show Mail, when User is not logged in + if ctx.Doer == nil { + org.EMail = "" + } + + ctx.JSON(http.StatusOK, org) } // Edit change an organization's information diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 2c4a6b93e39e0..471f9d3bbe821 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -101,6 +101,7 @@ func SettingsPost(ctx *context.Context) { } org.FullName = form.FullName + org.Email = form.Email org.Description = form.Description org.Website = form.Website org.Location = form.Location diff --git a/services/convert/convert.go b/services/convert/convert.go index bce0e7ba214b6..5f808a1646353 100644 --- a/services/convert/convert.go +++ b/services/convert/convert.go @@ -289,6 +289,7 @@ func ToOrganization(ctx context.Context, org *organization.Organization) *api.Or Name: org.Name, UserName: org.Name, FullName: org.FullName, + EMail: org.Email, Description: org.Description, Website: org.Website, Location: org.Location, diff --git a/services/forms/org.go b/services/forms/org.go index c333bead316dd..6e2d787516d26 100644 --- a/services/forms/org.go +++ b/services/forms/org.go @@ -38,6 +38,7 @@ func (f *CreateOrgForm) Validate(req *http.Request, errs binding.Errors) binding type UpdateOrgSettingForm struct { Name string `binding:"Required;Username;MaxSize(40)" locale:"org.org_name_holder"` FullName string `binding:"MaxSize(100)"` + Email string `binding:"MaxSize(255)"` Description string `binding:"MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 97047c71cc01a..3d85735759e67 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -17,6 +17,9 @@
{{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} + {{if $.IsSigned}} + {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} + {{end}}
+
+ + +
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 75492ab631610..b840407be6e07 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -19908,6 +19908,10 @@ "type": "string", "x-go-name": "Description" }, + "email": { + "type": "string", + "x-go-name": "EMail" + }, "full_name": { "type": "string", "x-go-name": "FullName" From 30e2732a12000f335144dafa16d944af79df6307 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 5 Jun 2023 16:40:58 +0200 Subject: [PATCH 2/6] Improve API --- modules/structs/org.go | 4 +++- routers/api/v1/org/org.go | 4 +++- services/convert/convert.go | 2 +- templates/swagger/v1_json.tmpl | 10 +++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/structs/org.go b/modules/structs/org.go index b3d5b565a242b..c0a545ac1c3fa 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -8,7 +8,7 @@ type Organization struct { ID int64 `json:"id"` Name string `json:"name"` FullName string `json:"full_name"` - EMail string `json:"email"` + Email string `json:"email"` AvatarURL string `json:"avatar_url"` Description string `json:"description"` Website string `json:"website"` @@ -33,6 +33,7 @@ type CreateOrgOption struct { // required: true UserName string `json:"username" binding:"Required;Username;MaxSize(40)"` FullName string `json:"full_name" binding:"MaxSize(100)"` + Email string `json:"email" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` @@ -47,6 +48,7 @@ type CreateOrgOption struct { // EditOrgOption options for editing an organization type EditOrgOption struct { FullName string `json:"full_name" binding:"MaxSize(100)"` + Email string `json:"email" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 143f4ffa2c69f..b0666c87f89ce 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -255,6 +255,7 @@ func Create(ctx *context.APIContext) { org := &organization.Organization{ Name: form.UserName, FullName: form.FullName, + Email: form.Email, Description: form.Description, Website: form.Website, Location: form.Location, @@ -304,7 +305,7 @@ func Get(ctx *context.APIContext) { // Don't show Mail, when User is not logged in if ctx.Doer == nil { - org.EMail = "" + org.Email = "" } ctx.JSON(http.StatusOK, org) @@ -336,6 +337,7 @@ func Edit(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.EditOrgOption) org := ctx.Org.Organization org.FullName = form.FullName + org.Email = form.Email org.Description = form.Description org.Website = form.Website org.Location = form.Location diff --git a/services/convert/convert.go b/services/convert/convert.go index 5f808a1646353..0877598876160 100644 --- a/services/convert/convert.go +++ b/services/convert/convert.go @@ -289,7 +289,7 @@ func ToOrganization(ctx context.Context, org *organization.Organization) *api.Or Name: org.Name, UserName: org.Name, FullName: org.FullName, - EMail: org.Email, + Email: org.Email, Description: org.Description, Website: org.Website, Location: org.Location, diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index b840407be6e07..8871238144a1c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -16942,6 +16942,10 @@ "type": "string", "x-go-name": "Description" }, + "email": { + "type": "string", + "x-go-name": "Email" + }, "full_name": { "type": "string", "x-go-name": "FullName" @@ -17860,6 +17864,10 @@ "type": "string", "x-go-name": "Description" }, + "email": { + "type": "string", + "x-go-name": "Email" + }, "full_name": { "type": "string", "x-go-name": "FullName" @@ -19910,7 +19918,7 @@ }, "email": { "type": "string", - "x-go-name": "EMail" + "x-go-name": "Email" }, "full_name": { "type": "string", From 3cf0815d2a187591f21c9c1e84cae2077b6cb22d Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 6 Jun 2023 10:34:30 +0200 Subject: [PATCH 3/6] Do requsted changes --- templates/org/home.tmpl | 4 ++-- tests/integration/api_user_orgs_test.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 3d85735759e67..5c06b61f72d7d 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -14,11 +14,11 @@ {{end}}
{{if $.RenderedDescription}}
{{$.RenderedDescription|Str2html}}
{{end}} -
+
{{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} {{if $.IsSigned}} - {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} + {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} {{end}}
diff --git a/tests/integration/api_user_orgs_test.go b/tests/integration/api_user_orgs_test.go index 323facaf48ed9..8df02f9eaf71f 100644 --- a/tests/integration/api_user_orgs_test.go +++ b/tests/integration/api_user_orgs_test.go @@ -106,6 +106,7 @@ func TestMyOrgs(t *testing.T) { Name: user17.Name, UserName: user17.Name, FullName: user17.FullName, + Email: "user17@example.com", AvatarURL: user17.AvatarLink(db.DefaultContext), Description: "", Website: "", @@ -117,6 +118,7 @@ func TestMyOrgs(t *testing.T) { Name: user3.Name, UserName: user3.Name, FullName: user3.FullName, + Email: "user3@example.com", AvatarURL: user3.AvatarLink(db.DefaultContext), Description: "", Website: "", From 5982992c8053d53fbb4981ad0cf8a0b1880485a3 Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sat, 1 Jul 2023 11:17:05 +0200 Subject: [PATCH 4/6] fix test, adjust styles --- templates/org/home.tmpl | 8 ++++---- tests/integration/api_user_orgs_test.go | 6 ++++-- web_src/css/org.css | 12 +++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 390245a45dd28..453940f8eb395 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -14,11 +14,11 @@ {{end}} {{if $.RenderedDescription}}
{{$.RenderedDescription|Str2html}}
{{end}} -
- {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} - {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} +
+ {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} + {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}} {{if $.IsSigned}} - {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} + {{if .Org.Email}}
{{svg "octicon-mail"}} {{.Org.Email}}
{{end}} {{end}}
diff --git a/tests/integration/api_user_orgs_test.go b/tests/integration/api_user_orgs_test.go index 8df02f9eaf71f..f76c61f818f5e 100644 --- a/tests/integration/api_user_orgs_test.go +++ b/tests/integration/api_user_orgs_test.go @@ -36,6 +36,7 @@ func TestUserOrgs(t *testing.T) { Name: user17.Name, UserName: user17.Name, FullName: user17.FullName, + Email: user17.Email, AvatarURL: user17.AvatarLink(db.DefaultContext), Description: "", Website: "", @@ -47,6 +48,7 @@ func TestUserOrgs(t *testing.T) { Name: user3.Name, UserName: user3.Name, FullName: user3.FullName, + Email: user3.Email, AvatarURL: user3.AvatarLink(db.DefaultContext), Description: "", Website: "", @@ -106,7 +108,7 @@ func TestMyOrgs(t *testing.T) { Name: user17.Name, UserName: user17.Name, FullName: user17.FullName, - Email: "user17@example.com", + Email: user17.Email, AvatarURL: user17.AvatarLink(db.DefaultContext), Description: "", Website: "", @@ -118,7 +120,7 @@ func TestMyOrgs(t *testing.T) { Name: user3.Name, UserName: user3.Name, FullName: user3.FullName, - Email: "user3@example.com", + Email: user3.Email, AvatarURL: user3.AvatarLink(db.DefaultContext), Description: "", Website: "", diff --git a/web_src/css/org.css b/web_src/css/org.css index 400f4fbbd9719..0f1bca451131c 100644 --- a/web_src/css/org.css +++ b/web_src/css/org.css @@ -117,13 +117,11 @@ margin-bottom: 10px; } -.organization.profile #org-info .meta .item { - display: inline-block; - margin-right: 10px; -} - -.organization.profile #org-info .meta .item .icon { - margin-right: 5px; +.organization.profile #org-info .meta { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; } .organization.profile .ui.top.header .ui.right { From 640fd522e8bbfe8cac07bdcb471c7886d6a47680 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 3 Jul 2023 15:27:19 +0200 Subject: [PATCH 5/6] E-Mail -> EMail --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ead410a5af806..8b05a4c015f89 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2525,7 +2525,7 @@ form.create_org_not_allowed = You are not allowed to create an organization. settings = Settings settings.options = Organization settings.full_name = Full Name -settings.email = Contact E-Mail +settings.email = Contact EMail settings.website = Website settings.location = Location settings.permission = Permissions From 9228af5329c42b02265f3937b5c386d7e47f7798 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 24 Jul 2023 17:35:18 +0800 Subject: [PATCH 6/6] Update options/locale/locale_en-US.ini --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 8b05a4c015f89..bbe6a8f7e2763 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2525,7 +2525,7 @@ form.create_org_not_allowed = You are not allowed to create an organization. settings = Settings settings.options = Organization settings.full_name = Full Name -settings.email = Contact EMail +settings.email = Contact Email settings.website = Website settings.location = Location settings.permission = Permissions