From dc2e63eeefb89556ae646994b2960910ec50316a Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Wed, 14 Sep 2022 18:42:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BC=D0=B5=D0=BD=D1=8F=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BA=D0=BE=D0=BE=D1=80=D0=B4=D0=B8=D0=BD=D0=B0=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/migrations/migrations.go | 2 ++ models/migrations/v213.go | 28 ++++++++++++++++++++++++++++ models/repo/repo.go | 1 + options/locale/locale_ru-RU.ini | 1 + routers/web/repo/setting.go | 1 + services/forms/repo_form.go | 1 + templates/repo/settings/options.tmpl | 4 ++++ 7 files changed, 38 insertions(+) create mode 100644 models/migrations/v213.go diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 9036c4489b..8692db26ac 100644 --- a/models/migrations/migrations.go +++ b/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 diff --git a/models/migrations/v213.go b/models/migrations/v213.go new file mode 100644 index 0000000000..0bc3adcabe --- /dev/null +++ b/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 + } +} diff --git a/models/repo/repo.go b/models/repo/repo.go index 13108dfae8..52c51d545a 100644 --- a/models/repo/repo.go +++ b/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 diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index f073f5997e..09643754b4 100644 --- a/options/locale/locale_ru-RU.ini +++ b/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=Расширенные настройки diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 37dc4b3e99..d0d3cde190 100644 --- a/routers/web/repo/setting.go +++ b/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. diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 92cd82a1bf..c11b0f6edd 100644 --- a/services/forms/repo_form.go +++ b/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 diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index f2adec149c..dd9973f73f 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -56,6 +56,10 @@ +
+ + +