Browse Source

При редактировании проекта возможно указывать необходимые ресурсы и компетенции #65

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

2
models/migrations/migrations.go

@ -375,6 +375,8 @@ var migrations = []Migration{
NewMigration("v208 was completely broken - remigrate", remigrateU2FCredentials),
// v211 -> v212
NewMigration("add competences, resources, interests to user tbl", addTrustedPropsToUser),
// v212 -> v213
NewMigration("add competences and resources to repo tbl", addTrustedPropsToRepo),
}
// GetCurrentDBVersion returns the current db version

28
models/migrations/v212.go

@ -0,0 +1,28 @@
package migrations
import (
"fmt"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
func addTrustedPropsToRepo(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 competences TEXT, ADD COLUMN resources TEXT;", tableName)
_, err = engine.Exec(addColsQuery)
case schemas.SQLITE:
addColsQuery := fmt.Sprintf("ALTER TABLE \"%s\" ADD COLUMN competences TEXT;\nALTER TABLE \"%s\" ADD COLUMN resources TEXT;", tableName, tableName)
_, err = engine.Exec(addColsQuery)
case schemas.MYSQL:
addColsQuery := fmt.Sprintf("ALTER TABLE `%s` ADD COLUMN competences TEXT, ADD COLUMN resources TEXT;", tableName)
_, err = engine.Exec(addColsQuery)
}
if err != nil {
return fmt.Errorf("Ошибка добавления колонок компетенции и ресурсы в проект: %v", err)
} else {
return nil
}
}

2
models/repo/repo.go

@ -100,6 +100,8 @@ type Repository struct {
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
Description string `xorm:"TEXT"`
Resources string `xorm:"TEXT"`
Competences string `xorm:"TEXT"`
Website string `xorm:"VARCHAR(2048)"`
OriginalServiceType api.GitServiceType `xorm:"index"`
OriginalURL string `xorm:"VARCHAR(2048)"`

2
options/locale/locale_ru-RU.ini

@ -804,6 +804,8 @@ download_bundle=Скачать BUNDLE
generate_repo=Создать проект
generate_from=Создать из
repo_desc=Описание
resources=Необходимые ресурсы
competences=Необходимые компетенции
repo_desc_helper=Добавьте краткое описание (необязательно)
repo_lang=Язык
repo_gitignore_helper=Выберите шаблон .gitignore.

2
routers/web/repo/setting.go

@ -151,6 +151,8 @@ func SettingsPost(ctx *context.Context) {
repo.Name = newRepoName
repo.LowerName = strings.ToLower(newRepoName)
repo.Description = form.Description
repo.Resources = form.Resources
repo.Competences = form.Competences
repo.Website = form.Website
repo.IsTemplate = form.Template

2
services/forms/repo_form.go

@ -115,6 +115,8 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string) (string, err
type RepoSettingForm struct {
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
Description string `binding:"MaxSize(255)"`
Resources string `binding:"MaxSize(1024)"`
Competences string `binding:"MaxSize(1024)"`
Website string `binding:"ValidUrl;MaxSize(255)"`
Interval string
MirrorAddress string

8
templates/repo/settings/options.tmpl

@ -44,6 +44,14 @@
<label for="description">{{$.i18n.Tr "repo.repo_desc"}}</label>
<textarea id="description" name="description" rows="2">{{.Repository.Description}}</textarea>
</div>
<div class="field {{if .Err_Resources}}error{{end}}">
<label for="resources">{{$.i18n.Tr "repo.resources"}}</label>
<textarea id="resources" name="resources" rows="6">{{.Repository.Resources}}</textarea>
</div>
<div class="field {{if .Err_Competences}}error{{end}}">
<label for="competences">{{$.i18n.Tr "repo.competences"}}</label>
<textarea id="competences" name="competences" rows="6">{{.Repository.Competences}}</textarea>
</div>
<div class="field {{if .Err_Website}}error{{end}}">
<label for="website">{{.i18n.Tr "repo.settings.site"}}</label>
<input id="website" name="website" type="url" value="{{.Repository.Website}}">

Loading…
Cancel
Save