Browse Source

Реализована возможность менять координаты проекта #15

pull/120/head
Artur Galyamov 2 years ago
parent
commit
dc2e63eeef
  1. 2
      models/migrations/migrations.go
  2. 28
      models/migrations/v213.go
  3. 1
      models/repo/repo.go
  4. 1
      options/locale/locale_ru-RU.ini
  5. 1
      routers/web/repo/setting.go
  6. 1
      services/forms/repo_form.go
  7. 4
      templates/repo/settings/options.tmpl

2
models/migrations/migrations.go

@ -377,6 +377,8 @@ var migrations = []Migration{
NewMigration("add competences, resources, interests to user tbl", addTrustedPropsToUser),
// v212 -> v213
NewMigration("add competences and resources to repo tbl", addTrustedPropsToRepo),
// v213 -> v214
NewMigration("add location_coordinate to repo tbl", addLocationCoordinateToRepo),
}
// GetCurrentDBVersion returns the current db version

28
models/migrations/v213.go

@ -0,0 +1,28 @@
package migrations
import (
"fmt"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
func addLocationCoordinateToRepo(engine *xorm.Engine) error {
var err error
tableName := "repository"
switch engine.Dialect().URI().DBType {
case schemas.POSTGRES:
addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN location_coordinate VARCHAR(20);", tableName)
_, err = engine.Exec(addColsQuery)
case schemas.SQLITE:
addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN location_coordinate TEXT;", tableName)
_, err = engine.Exec(addColsQuery)
case schemas.MYSQL:
addColsQuery := fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN location_coordinate VARCHAR(20);", tableName)
_, err = engine.Exec(addColsQuery)
}
if err != nil {
return fmt.Errorf("Ошибка добавления колонок компетенции и ресурсы в проект: %v", err)
} else {
return nil
}
}

1
models/repo/repo.go

@ -103,6 +103,7 @@ type Repository struct {
Resources string `xorm:"TEXT"`
Competences string `xorm:"TEXT"`
Website string `xorm:"VARCHAR(2048)"`
LocationCoordinate string `xorm:"VARCHAR(20)"`
OriginalServiceType api.GitServiceType `xorm:"index"`
OriginalURL string `xorm:"VARCHAR(2048)"`
DefaultBranch string

1
options/locale/locale_ru-RU.ini

@ -1719,6 +1719,7 @@ settings.email_notifications.onmention=Посылать письмо на эл.
settings.email_notifications.disable=Отключить почтовые уведомления
settings.email_notifications.submit=Установить настройки электронной почты
settings.site=Сайт
settings.location_coordinate=Координаты
settings.update_settings=Обновить настройки
settings.branches.update_default_branch=Обновить ветку по умолчанию
settings.advanced_settings=Расширенные настройки

1
routers/web/repo/setting.go

@ -154,6 +154,7 @@ func SettingsPost(ctx *context.Context) {
repo.Resources = form.Resources
repo.Competences = form.Competences
repo.Website = form.Website
repo.LocationCoordinate = form.LocationCoordinate
repo.IsTemplate = form.Template
// Visibility of forked repository is forced sync with base repository.

1
services/forms/repo_form.go

@ -118,6 +118,7 @@ type RepoSettingForm struct {
Resources string `binding:"MaxSize(1024)"`
Competences string `binding:"MaxSize(1024)"`
Website string `binding:"ValidUrl;MaxSize(255)"`
LocationCoordinate string
Interval string
MirrorAddress string
MirrorUsername string

4
templates/repo/settings/options.tmpl

@ -56,6 +56,10 @@
<label for="website">{{.i18n.Tr "repo.settings.site"}}</label>
<input id="website" name="website" type="url" value="{{.Repository.Website}}">
</div>
<div class="field {{if .Err_LocationCoordinate}}error{{end}}">
<label for="location_coordinate">{{.i18n.Tr "repo.settings.location_coordinate"}}</label>
<input id="location_coordinate" name="location_coordinate" value="{{.Repository.LocationCoordinate}}" placeholder="55.4, 37.3">
</div>
<div class="field">
<button class="ui green button">{{$.i18n.Tr "repo.settings.update_settings"}}</button>

Loading…
Cancel
Save