From c62d1a2570bc5cf42c8b2a1e5f8b36d729b0e351 Mon Sep 17 00:00:00 2001 From: Gitea Date: Tue, 14 Jun 2022 19:13:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BE=D1=80=D0=B4=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D1=82=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user/user.go | 2 ++ modules/convert/convert.go | 1 + modules/convert/user.go | 2 ++ modules/structs/admin_user.go | 1 + modules/structs/org.go | 3 +++ modules/structs/user.go | 4 ++++ options/locale/locale_ru-RU.ini | 2 ++ routers/api/v1/admin/org.go | 1 + routers/api/v1/admin/user.go | 3 +++ routers/api/v1/org/org.go | 2 ++ routers/api/v1/user/settings.go | 3 +++ routers/web/admin/users.go | 1 + routers/web/org/setting.go | 1 + routers/web/user/setting/profile.go | 1 + services/forms/admin.go | 1 + services/forms/org.go | 1 + services/forms/user_form.go | 1 + templates/admin/user/edit.tmpl | 4 ++++ templates/explore/organizations.tmpl | 2 +- templates/explore/users.tmpl | 2 +- templates/org/home.tmpl | 2 +- templates/org/settings/options.tmpl | 5 +++++ templates/repo/user_cards.tmpl | 2 +- templates/user/profile.tmpl | 2 +- templates/user/settings/profile.tmpl | 4 ++++ 25 files changed, 48 insertions(+), 5 deletions(-) diff --git a/models/user/user.go b/models/user/user.go index e375f3de0a..680bd61f50 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -94,6 +94,7 @@ type User struct { LoginName string Type UserType Location string + LocationCoordinate string Website string Rands string `xorm:"VARCHAR(32)"` Salt string `xorm:"VARCHAR(32)"` @@ -187,6 +188,7 @@ func (u *User) BeforeUpdate() { u.LowerName = strings.ToLower(u.Name) u.Location = base.TruncateString(u.Location, 255) + u.LocationCoordinate = base.TruncateString(u.LocationCoordinate, 255) u.Website = base.TruncateString(u.Website, 255) u.Description = base.TruncateString(u.Description, 255) } diff --git a/modules/convert/convert.go b/modules/convert/convert.go index 41a044c6d7..bbb89f97e6 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -289,6 +289,7 @@ func ToOrganization(org *models.Organization) *api.Organization { Description: org.Description, Website: org.Website, Location: org.Location, + LocationCoordinate: org.LocationCoordinate, Visibility: org.Visibility.String(), RepoAdminChangeTeamAccess: org.RepoAdminChangeTeamAccess, } diff --git a/modules/convert/user.go b/modules/convert/user.go index dc4a8c49c7..5f9ba9fc3d 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -55,6 +55,7 @@ func toUser(user *user_model.User, signed, authed bool) *api.User { Created: user.CreatedUnix.AsTime(), Restricted: user.IsRestricted, Location: user.Location, + LocationCoordinate: user.LocationCoordinate, Website: user.Website, Description: user.Description, // counter's @@ -87,6 +88,7 @@ func User2UserSettings(user *user_model.User) api.UserSettings { FullName: user.FullName, Website: user.Website, Location: user.Location, + LocationCoordinate: user.LocationCoordinate, Language: user.Language, Description: user.Description, Theme: user.Theme, diff --git a/modules/structs/admin_user.go b/modules/structs/admin_user.go index eccbf29a46..ea52caa64a 100644 --- a/modules/structs/admin_user.go +++ b/modules/structs/admin_user.go @@ -36,6 +36,7 @@ type EditUserOption struct { MustChangePassword *bool `json:"must_change_password"` Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"` Location *string `json:"location" binding:"MaxSize(50)"` + LocationCoordinate *string `json:"location_coordinate" binding:"MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(255)"` Active *bool `json:"active"` Admin *bool `json:"admin"` diff --git a/modules/structs/org.go b/modules/structs/org.go index d8bd59e1ec..7716465754 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -13,6 +13,7 @@ type Organization struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` + LocationCoordinate string `json:"location_coordinate"` Visibility string `json:"visibility"` RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"` } @@ -34,6 +35,7 @@ type CreateOrgOption struct { Description string `json:"description" binding:"MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` + LocationCoordinate string `json:"location_coordinate" binding:"MaxSize(255)"` // possible values are `public` (default), `limited` or `private` // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` @@ -48,6 +50,7 @@ type EditOrgOption struct { Description string `json:"description" binding:"MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` + LocationCoordinate string `json:"location_coordinate" binding:"MaxSize(255)"` // possible values are `public`, `limited` or `private` // enum: public,limited,private Visibility string `json:"visibility" binding:"In(,public,limited,private)"` diff --git a/modules/structs/user.go b/modules/structs/user.go index 431e230fac..2c50935265 100644 --- a/modules/structs/user.go +++ b/modules/structs/user.go @@ -39,6 +39,8 @@ type User struct { ProhibitLogin bool `json:"prohibit_login"` // the user's location Location string `json:"location"` + // the user's location coordinate + LocationCoordinate string `json:"location_coordinate"` // the user's website Website string `json:"website"` // the user's description @@ -69,6 +71,7 @@ type UserSettings struct { Website string `json:"website"` Description string `json:"description"` Location string `json:"location"` + LocationCoordinate string `json:"location_coordinate"` Language string `json:"language"` Theme string `json:"theme"` DiffViewStyle string `json:"diff_view_style"` @@ -84,6 +87,7 @@ type UserSettingsOptions struct { Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(255)"` Location *string `json:"location" binding:"MaxSize(50)"` + LocationCoordinate *string `json:"location_coordinate" binding:"MaxSize(255)"` Language *string `json:"language"` Theme *string `json:"theme"` DiffViewStyle *string `json:"diff_view_style"` diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index 0111dfe434..67d6b9bf94 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -524,6 +524,7 @@ password_username_disabled=Нелокальным пользователям з full_name=Имя и фамилия website=Веб-сайт location=Местоположение +locationcoordinate=Координаты update_theme=Обновить тему update_profile=Обновить профиль update_language=Обновить язык @@ -2188,6 +2189,7 @@ settings.options=Организация settings.full_name=Полное имя settings.website=Сайт settings.location=Местоположение +settings.locationcoordinate=Координаты settings.permission=Разрешения settings.repoadminchangeteam=Администратор репозитория может добавлять и удалять права доступа для команд settings.visibility=Видимость diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index bdfe87fd4e..40d67f5e62 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -62,6 +62,7 @@ func CreateOrg(ctx *context.APIContext) { Description: form.Description, Website: form.Website, Location: form.Location, + LocationCoordinate: form.LocationCoordinate, IsActive: true, Type: user_model.UserTypeOrganization, Visibility: visibility, diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 7262073bbd..a987e59096 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -240,6 +240,9 @@ func EditUser(ctx *context.APIContext) { if form.Location != nil { u.Location = *form.Location } + if form.LocationCoordinate != nil { + u.LocationCoordinate = *form.LocationCoordinate + } if form.Description != nil { u.Description = *form.Description } diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 133cce3416..817d6d5c98 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -267,6 +267,7 @@ func Create(ctx *context.APIContext) { Description: form.Description, Website: form.Website, Location: form.Location, + LocationCoordinate: form.LocationCoordinate, IsActive: true, Type: user_model.UserTypeOrganization, Visibility: visibility, @@ -340,6 +341,7 @@ func Edit(ctx *context.APIContext) { org.Description = form.Description org.Website = form.Website org.Location = form.Location + org.LocationCoordinate = form.LocationCoordinate if form.Visibility != "" { org.Visibility = api.VisibilityModes[form.Visibility] } diff --git a/routers/api/v1/user/settings.go b/routers/api/v1/user/settings.go index 5f4d76ed72..8f01da4543 100644 --- a/routers/api/v1/user/settings.go +++ b/routers/api/v1/user/settings.go @@ -57,6 +57,9 @@ func UpdateUserSettings(ctx *context.APIContext) { if form.Location != nil { ctx.User.Location = *form.Location } + if form.LocationCoordinate != nil { + ctx.User.LocationCoordinate = *form.LocationCoordinate + } if form.Language != nil { ctx.User.Language = *form.Language } diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 1576f58b41..8aaa654a39 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -372,6 +372,7 @@ func EditUserPost(ctx *context.Context) { u.Email = form.Email u.Website = form.Website u.Location = form.Location + u.LocationCoordinate = form.LocationCoordinate u.MaxRepoCreation = form.MaxRepoCreation u.IsActive = form.Active u.IsAdmin = form.Admin diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 081e103f79..16f83f8b80 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -100,6 +100,7 @@ func SettingsPost(ctx *context.Context) { org.Description = form.Description org.Website = form.Website org.Location = form.Location + org.LocationCoordinate = form.LocationCoordinate org.RepoAdminChangeTeamAccess = form.RepoAdminChangeTeamAccess visibilityChanged := form.Visibility != org.Visibility diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index ab156b43fc..ddc5a7c47d 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -119,6 +119,7 @@ func ProfilePost(ctx *context.Context) { ctx.User.KeepEmailPrivate = form.KeepEmailPrivate ctx.User.Website = form.Website ctx.User.Location = form.Location + ctx.User.LocationCoordinate = form.LocationCoordinate ctx.User.Description = form.Description ctx.User.KeepActivityPrivate = form.KeepActivityPrivate ctx.User.Visibility = form.Visibility diff --git a/services/forms/admin.go b/services/forms/admin.go index 5abef0550e..435e5d4c15 100644 --- a/services/forms/admin.go +++ b/services/forms/admin.go @@ -42,6 +42,7 @@ type AdminEditUserForm struct { Password string `binding:"MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` + LocationCoordinate string `binding:"MaxSize(255)"` MaxRepoCreation int Active bool Admin bool diff --git a/services/forms/org.go b/services/forms/org.go index dec2dbfa65..3239ee80fb 100644 --- a/services/forms/org.go +++ b/services/forms/org.go @@ -42,6 +42,7 @@ type UpdateOrgSettingForm struct { Description string `binding:"MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` + LocationCoordinate string `binding:"MaxSize(255)"` Visibility structs.VisibleType MaxRepoCreation int RepoAdminChangeTeamAccess bool diff --git a/services/forms/user_form.go b/services/forms/user_form.go index a886e89f87..40ef2c1c19 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -245,6 +245,7 @@ type UpdateProfileForm struct { KeepEmailPrivate bool Website string `binding:"ValidSiteUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` + LocationCoordinate string `binding:"MaxSize(255)"` Description string `binding:"MaxSize(255)"` Visibility structs.VisibleType KeepActivityPrivate bool diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 17bd2b936c..f88e2bbc56 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -81,6 +81,10 @@ +
+ + +
diff --git a/templates/explore/organizations.tmpl b/templates/explore/organizations.tmpl index b2fee6c19a..0b9e001294 100644 --- a/templates/explore/organizations.tmpl +++ b/templates/explore/organizations.tmpl @@ -17,7 +17,7 @@
{{if .Location}} - {{svg "octicon-location"}} {{.Location}} + {{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}}) {{end}} {{if and .Website}} {{svg "octicon-link"}} diff --git a/templates/explore/users.tmpl b/templates/explore/users.tmpl index dff4e8c8be..261ddec16f 100644 --- a/templates/explore/users.tmpl +++ b/templates/explore/users.tmpl @@ -12,7 +12,7 @@ {{.Name}} {{.FullName}}
{{if .Location}} - {{svg "octicon-location"}} {{.Location}} + {{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}}) {{end}} {{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}} {{svg "octicon-mail"}} diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index c72fc53de5..7ba5f95b46 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -12,7 +12,7 @@
{{if $.RenderedDescription}}

{{$.RenderedDescription|Str2html}}

{{end}}
- {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} + {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}} ({{.Org.LocationCoordinate}})
{{end}} {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}}
diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 09bf5e0caa..a6d30dae48 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -36,6 +36,11 @@ +
+ + +
+
diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl index 3526c698b9..0ec40116ca 100644 --- a/templates/repo/user_cards.tmpl +++ b/templates/repo/user_cards.tmpl @@ -16,7 +16,7 @@ {{if .Website}} {{svg "octicon-link"}} {{.Website}} {{else if .Location}} - {{svg "octicon-location"}} {{.Location}} + {{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}}) {{else}} {{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}} {{end}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index e0a6b39121..d14a86fd17 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -20,7 +20,7 @@
    {{if .Owner.Location}} -
  • {{svg "octicon-location"}} {{.Owner.Location}}
  • +
  • {{svg "octicon-location"}} {{.Owner.Location}} ({{.Owner.LocationCoordinate}})
  • {{end}} {{if .ShowUserEmail }}
  • diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 9429db1ad6..18f5ed4b5c 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -46,6 +46,10 @@
+
+ + +