Browse Source

Добавлены новые поля координат для пользователей #2

pull/13/head
Gitea 3 years ago
parent
commit
c62d1a2570
  1. 2
      models/user/user.go
  2. 1
      modules/convert/convert.go
  3. 2
      modules/convert/user.go
  4. 1
      modules/structs/admin_user.go
  5. 3
      modules/structs/org.go
  6. 4
      modules/structs/user.go
  7. 2
      options/locale/locale_ru-RU.ini
  8. 1
      routers/api/v1/admin/org.go
  9. 3
      routers/api/v1/admin/user.go
  10. 2
      routers/api/v1/org/org.go
  11. 3
      routers/api/v1/user/settings.go
  12. 1
      routers/web/admin/users.go
  13. 1
      routers/web/org/setting.go
  14. 1
      routers/web/user/setting/profile.go
  15. 1
      services/forms/admin.go
  16. 1
      services/forms/org.go
  17. 1
      services/forms/user_form.go
  18. 4
      templates/admin/user/edit.tmpl
  19. 2
      templates/explore/organizations.tmpl
  20. 2
      templates/explore/users.tmpl
  21. 2
      templates/org/home.tmpl
  22. 5
      templates/org/settings/options.tmpl
  23. 2
      templates/repo/user_cards.tmpl
  24. 2
      templates/user/profile.tmpl
  25. 4
      templates/user/settings/profile.tmpl

2
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)
}

1
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,
}

2
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,

1
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"`

3
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)"`

4
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"`

2
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=Видимость

1
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,

3
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
}

2
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]
}

3
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
}

1
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

1
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

1
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

1
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

1
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

1
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

4
templates/admin/user/edit.tmpl

@ -81,6 +81,10 @@
<label for="location">{{.i18n.Tr "settings.location"}}</label>
<input id="location" name="location" value="{{.User.Location}}">
</div>
<div class="field {{if .LocationCoordinate}}error{{end}}">
<label for="location_coordinate">{{.i18n.Tr "settings.locationcoordinate"}}</label>
<input id="location_coordinate" name="location_coordinate" value="{{.User.LocationCoordinate}}" placeholder="55.4, 37.3">
</div>
<div class="ui divider"></div>

2
templates/explore/organizations.tmpl

@ -17,7 +17,7 @@
</span>
<div class="description">
{{if .Location}}
{{svg "octicon-location"}} {{.Location}}
{{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}})
{{end}}
{{if and .Website}}
{{svg "octicon-link"}}

2
templates/explore/users.tmpl

@ -12,7 +12,7 @@
<span class="header"><a href="{{.HomeLink}}">{{.Name}}</a> {{.FullName}}</span>
<div class="description">
{{if .Location}}
{{svg "octicon-location"}} {{.Location}}
{{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}})
{{end}}
{{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}}
{{svg "octicon-mail"}}

2
templates/org/home.tmpl

@ -12,7 +12,7 @@
</div>
{{if $.RenderedDescription}}<p class="render-content markup">{{$.RenderedDescription|Str2html}}</p>{{end}}
<div class="text grey meta">
{{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
{{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span> <span>({{.Org.LocationCoordinate}})</span></div>{{end}}
{{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}
</div>
</div>

5
templates/org/settings/options.tmpl

@ -36,6 +36,11 @@
<input id="location" name="location" value="{{.Org.Location}}">
</div>
<div class="field">
<label for="location_coordinate">{{.i18n.Tr "org.settings.locationcoordinate"}}</label>
<input id="location_coordinate" name="location_coordinate" value="{{.Org.LocationCoordinate}}" placeholder="55.4, 37.3">
</div>
<div class="ui divider"></div>
<div class="field" id="visibility_box">
<label for="visibility">{{.i18n.Tr "org.settings.visibility"}}</label>

2
templates/repo/user_cards.tmpl

@ -16,7 +16,7 @@
{{if .Website}}
{{svg "octicon-link"}} <a href="{{.Website}}" target="_blank" rel="noopener noreferrer">{{.Website}}</a>
{{else if .Location}}
{{svg "octicon-location"}} {{.Location}}
{{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}})
{{else}}
{{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
{{end}}

2
templates/user/profile.tmpl

@ -20,7 +20,7 @@
<div class="extra content word-break">
<ul>
{{if .Owner.Location}}
<li>{{svg "octicon-location"}} {{.Owner.Location}}</li>
<li>{{svg "octicon-location"}} {{.Owner.Location}} ({{.Owner.LocationCoordinate}})</li>
{{end}}
{{if .ShowUserEmail }}
<li>

4
templates/user/settings/profile.tmpl

@ -46,6 +46,10 @@
<label for="location">{{.i18n.Tr "settings.location"}}</label>
<input id="location" name="location" value="{{.SignedUser.Location}}">
</div>
<div class="field">
<label for="location_coordinate">{{.i18n.Tr "settings.locationcoordinate"}}</label>
<input id="location_coordinate" name="location_coordinate" value="{{.SignedUser.LocationCoordinate}}" placeholder="55.4, 37.3">
</div>
<div class="ui divider"></div>
<!-- private block -->

Loading…
Cancel
Save