Skip to content

Commit 3d8cfe2

Browse files
committed
Allow Organisations to have a E-Mail
1 parent d851bd9 commit 3d8cfe2

File tree

9 files changed

+25
-1
lines changed

9 files changed

+25
-1
lines changed

modules/structs/org.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type Organization struct {
88
ID int64 `json:"id"`
99
Name string `json:"name"`
1010
FullName string `json:"full_name"`
11+
EMail string `json:"email"`
1112
AvatarURL string `json:"avatar_url"`
1213
Description string `json:"description"`
1314
Website string `json:"website"`

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,7 @@ form.create_org_not_allowed = You are not allowed to create an organization.
25112511
settings = Settings
25122512
settings.options = Organization
25132513
settings.full_name = Full Name
2514+
settings.email = Contact E-Mail
25142515
settings.website = Website
25152516
settings.location = Location
25162517
settings.permission = Permissions

routers/api/v1/org/org.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,15 @@ func Get(ctx *context.APIContext) {
299299
ctx.NotFound("HasOrgOrUserVisible", nil)
300300
return
301301
}
302-
ctx.JSON(http.StatusOK, convert.ToOrganization(ctx, ctx.Org.Organization))
302+
303+
org := convert.ToOrganization(ctx, ctx.Org.Organization)
304+
305+
// Don't show Mail, when User is not logged in
306+
if ctx.Doer == nil {
307+
org.EMail = ""
308+
}
309+
310+
ctx.JSON(http.StatusOK, org)
303311
}
304312

305313
// Edit change an organization's information

routers/web/org/setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func SettingsPost(ctx *context.Context) {
101101
}
102102

103103
org.FullName = form.FullName
104+
org.Email = form.Email
104105
org.Description = form.Description
105106
org.Website = form.Website
106107
org.Location = form.Location

services/convert/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ func ToOrganization(ctx context.Context, org *organization.Organization) *api.Or
289289
Name: org.Name,
290290
UserName: org.Name,
291291
FullName: org.FullName,
292+
EMail: org.Email,
292293
Description: org.Description,
293294
Website: org.Website,
294295
Location: org.Location,

services/forms/org.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func (f *CreateOrgForm) Validate(req *http.Request, errs binding.Errors) binding
3838
type UpdateOrgSettingForm struct {
3939
Name string `binding:"Required;Username;MaxSize(40)" locale:"org.org_name_holder"`
4040
FullName string `binding:"MaxSize(100)"`
41+
Email string `binding:"MaxSize(255)"`
4142
Description string `binding:"MaxSize(255)"`
4243
Website string `binding:"ValidUrl;MaxSize(255)"`
4344
Location string `binding:"MaxSize(50)"`

templates/org/home.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<div class="text grey meta">
1818
{{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
1919
{{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer me" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}
20+
{{if $.IsSigned}}
21+
{{if .Org.Email}}<div class="item">{{svg "octicon-mail"}} <a href="mailto:{{.Org.Email}}">{{.Org.Email}}</a></div>{{end}}
22+
{{end}}
2023
</div>
2124
</div>
2225
<div class="right stackable menu">

templates/org/settings/options.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<label for="full_name">{{.locale.Tr "org.org_full_name_holder"}}</label>
1919
<input id="full_name" name="full_name" value="{{.Org.FullName}}" maxlength="100">
2020
</div>
21+
<div class="field {{if .Err_Email}}error{{end}}">
22+
<label for="email">{{.locale.Tr "org.settings.email"}}</label>
23+
<input id="email" name="email" type="email" value="{{.Org.Email}}" maxlength="255">
24+
</div>
2125
<div class="field {{if .Err_Description}}error{{end}}">
2226
<label for="description">{{$.locale.Tr "org.org_desc"}}</label>
2327
<textarea id="description" name="description" rows="2" maxlength="255">{{.Org.Description}}</textarea>

templates/swagger/v1_json.tmpl

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)