Bläddra i källkod

Added Private Email and Resolves #30

Yoginth 7 år sedan
förälder
incheckning
62cff0c9fc

+ 1 - 0
models/user.go

@@ -74,6 +74,7 @@ type User struct {
 
 	// Permissions
 	IsActive         bool // Activate primary email
+	PrivateEmail     bool
 	IsBeta           bool
 	ShowSponsors     bool
 	IsStaff          bool

+ 1 - 0
pkg/form/admin.go

@@ -52,6 +52,7 @@ type AdminEditUser struct {
 	IsBeta           bool
 	IsStaff          bool
 	IsIntern         bool
+	PrivateEmail     bool
 }
 
 func (f *AdminEditUser) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {

+ 1 - 0
pkg/form/user.go

@@ -84,6 +84,7 @@ type UpdateProfile struct {
 	ThemeColor   string
 	IsBeta       bool
 	ShowSponsors bool
+	PrivateEmail bool
 }
 
 type UpdateSocial struct {

+ 2 - 0
routes/user/setting.go

@@ -55,6 +55,7 @@ func Settings(c *context.Context) {
 	c.Data["themecolor"] = c.User.ThemeColor
 	c.Data["is_beta"] = c.User.IsBeta
 	c.Data["show_sponsors"] = c.User.ShowSponsors
+	c.Data["private_email"] = c.User.PrivateEmail
 	c.Success(SETTINGS_PROFILE)
 }
 
@@ -110,6 +111,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
 	c.User.ThemeColor = f.ThemeColor
 	c.User.IsBeta = f.IsBeta
 	c.User.ShowSponsors = f.ShowSponsors
+	c.User.PrivateEmail = f.PrivateEmail
 
 	if err := models.UpdateUser(c.User); err != nil {
 		c.ServerError("UpdateUser", err)

+ 6 - 4
templates/user/profile.tmpl

@@ -131,10 +131,12 @@
 								</li>
 							{{end}}
 							{{if and .Owner.Email .IsLogged}}
-								<li>
-									<i class="menu-icon octicon">📧</i>
-									<a class="pro-truncate" href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>
-								</li>
+								{{if not .Owner.PrivateEmail}}
+									<li>
+										<i class="menu-icon octicon">📧</i>
+										<a class="pro-truncate" href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>
+									</li>
+								{{end}}
 							{{else}}
 								<li>
 									<i class="menu-icon octicon">📧</i>

+ 1 - 4
templates/user/settings/email.tmpl

@@ -17,10 +17,7 @@
 							<div class="item ui grid">
 								<div class="column">
 									<strong>{{.Email}}</strong>
-									{{if .IsPrimary}}
-										<span class="ui green tiny primary label">{{$.i18n.Tr "settings.primary"}}</span>
-										<button class="ui orange tiny basic button right">Make Private</button>
-									{{end}}
+									{{if .IsPrimary}}<span class="ui green tiny primary label">{{$.i18n.Tr "settings.primary"}}</span>{{end}}
 									{{if not .IsPrimary}}
 										<div class="ui right">
 											<button class="ui red tiny basic button delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}">

+ 7 - 1
templates/user/settings/profile.tmpl

@@ -33,7 +33,13 @@
 						</div>
 						<div class="required field {{if .Err_Email}}error{{end}}">
 							<label for="email">{{.i18n.Tr "email"}}</label>
-							<input id="email" name="email" value="{{.email}}" required>
+							<input id="email" name="email" type="email" value="{{.email}}" required>
+						</div>
+						<div class="inline field">
+							<div class="ui checkbox">
+								<label><strong>Email is Private</strong></label>
+								<input name="private_email" type="checkbox" {{if .private_email}}checked{{end}}>
+							</div>
 						</div>
 						<div class="field {{if .Err_Website}}error{{end}}">
 							<label for="website">{{.i18n.Tr "settings.website"}}</label>