Ver código fonte

Added Permission to Night Mode

Yoginth 7 anos atrás
pai
commit
12c65a91f7

+ 1 - 0
conf/locale/locale_en-GB.ini

@@ -305,6 +305,7 @@ status = Status
 private_email = This email is Private
 beta = Enroll to Beta Member
 ads = Display Ads on dashboard
+nightmode = Night mode on Gitote
 update_profile = Update Profile
 update_profile_success = Your profile has been updated successfully.
 update_social = Update Social

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -305,6 +305,7 @@ status = Status
 private_email = This email is Private
 beta = Enroll to Beta Member
 ads = Display Ads on dashboard
+nightmode = Night mode on Gitote
 update_profile = Update Profile
 update_profile_success = Your profile has been updated successfully.
 update_social = Update Social

+ 4 - 2
models/user.go

@@ -78,7 +78,6 @@ type User struct {
 	IsActive         bool // Activate primary email
 	PrivateEmail     bool
 	IsBeta           bool
-	ShowAds          bool
 	IsStaff          bool
 	IsIntern         bool
 	IsAdmin          bool
@@ -103,7 +102,6 @@ type User struct {
 	Codepen       string
 	Gitlab        string
 
-
 	// Avatar
 	Avatar          string `xorm:"VARCHAR(2048) NOT NULL"`
 	AvatarEmail     string `xorm:"NOT NULL"`
@@ -128,6 +126,10 @@ type User struct {
 	// Certificate
 	Recognized string
 	Certified  string
+
+	// Misc
+	ShowAds   bool
+	NightMode bool
 }
 
 func (u *User) BeforeInsert() {

Diferenças do arquivo suprimidas por serem muito extensas
+ 4 - 4
pkg/bindata/bindata.go


+ 1 - 1
pkg/form/user.go

@@ -84,6 +84,7 @@ type UpdateProfile struct {
 	ThemeColor   string
 	IsBeta       bool
 	ShowAds      bool
+	NightMode    bool
 	PrivateEmail bool
 }
 
@@ -97,7 +98,6 @@ type UpdateSocial struct {
 	Telegram      string `binding:"MaxSize(50)"`
 	Codepen       string `binding:"MaxSize(50)"`
 	Gitlab        string `binding:"MaxSize(50)"`
-
 }
 
 func (f *UpdateProfile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {

+ 2 - 0
routes/user/setting.go

@@ -57,6 +57,7 @@ func Settings(c *context.Context) {
 	c.Data["themecolor"] = c.User.ThemeColor
 	c.Data["is_beta"] = c.User.IsBeta
 	c.Data["show_ads"] = c.User.ShowAds
+	c.Data["night_mode"] = c.User.NightMode
 	c.Data["private_email"] = c.User.PrivateEmail
 	c.Success(SETTINGS_PROFILE)
 }
@@ -114,6 +115,7 @@ func SettingsPost(c *context.Context, f form.UpdateProfile) {
 	c.User.ThemeColor = f.ThemeColor
 	c.User.IsBeta = f.IsBeta
 	c.User.ShowAds = f.ShowAds
+	c.User.NightMode = f.NightMode
 	c.User.PrivateEmail = f.PrivateEmail
 
 	if err := models.UpdateUser(c.User); err != nil {

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

@@ -57,6 +57,13 @@
 							<label for="theme_color">Color</label>
 							<input type="text" id="theme_color" name="theme_color" class="jscolor {hash:true} jscolor-active" value="{{.themecolor}}" placeholder="#161616" autocomplete="off">
 						</div>
+						<div class="inline field">
+							<label for="location">Night Mode: </label>
+							<div class="ui checkbox">
+								<label><strong>{{.i18n.Tr "settings.nightmode"}}</strong></label>
+								<input name="night_mode" type="checkbox" {{if .night_mode}}checked{{end}}>
+							</div>
+						</div>
 						<div class="inline field">
 							<label for="location">Ads: </label>
 							<div class="ui checkbox">