diff --git a/models/dataset.go b/models/dataset.go index b2a6c9665..d03a38a79 100644 --- a/models/dataset.go +++ b/models/dataset.go @@ -6,18 +6,18 @@ import ( // Issue represents an issue or pull request of repository. type Dataset struct { - ID int64 `xorm:"pk autoincr"` - Title string `xorm:"INDEX NOT NULL"` - Status int32 `xorm:"INDEX"` - Category string - Description string `xorm:"TEXT"` - Download_times int64 - License string - Task string - Release_id int64 `xorm:"INDEX"` - User_id int64 `xorm:"INDEX"` - CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` - UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` + ID int64 `xorm:"pk autoincr"` + Title string `xorm:"INDEX NOT NULL"` + Status int32 `xorm:"INDEX"` + Category string + Description string `xorm:"TEXT"` + DownloadTimes int64 + License string + Task string + ReleaseID int64 `xorm:"INDEX"` + UserID int64 `xorm:"INDEX"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` Attachments []*Attachment `xorm:"-"` } diff --git a/models/migrations/v140.go b/models/migrations/v140.go index bad436197..758a7ef19 100644 --- a/models/migrations/v140.go +++ b/models/migrations/v140.go @@ -13,18 +13,18 @@ import ( func addDatasetTable(x *xorm.Engine) error { type Dataset struct { - ID int64 `xorm:"pk autoincr"` - Title string `xorm:"INDEX NOT NULL"` - Status int32 `xorm:"INDEX"` - Category string - Description string `xorm:"TEXT"` - Download_times int64 - License string - Task string - Release_id int64 `xorm:"INDEX"` - User_id int64 `xorm:"INDEX"` - CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` - UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` + ID int64 `xorm:"pk autoincr"` + Title string `xorm:"INDEX NOT NULL"` + Status int32 `xorm:"INDEX"` + Category string + Description string `xorm:"TEXT"` + DownloadTimes int64 + License string + Task string + ReleaseID int64 `xorm:"INDEX"` + UserID int64 `xorm:"INDEX"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } if err := x.Sync2(new(Dataset)); err != nil { diff --git a/modules/auth/dataset.go b/modules/auth/dataset.go index 110d4e137..eeed8b267 100644 --- a/modules/auth/dataset.go +++ b/modules/auth/dataset.go @@ -10,9 +10,9 @@ type CreateDatasetForm struct { Title string `binding:"Required"` Category string `binding:"Required"` Description string `binding:"Required;MaxSize(254)"` - License string `binding:"OmitEmpty;MaxSize(64)"` - Task string - Release_id int64 `xorm:"INDEX"` + License string `binding:"Required;MaxSize(64)"` + Task string `binding:"Required;MaxSize(64)"` + ReleaseID int64 `xorm:"INDEX"` } // Validate validates the fields diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 465a71f14..a32f6b02c 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -626,7 +626,7 @@ description = Description create_dataset = Create Dataset category = Category task = Task -Licenses = Licenses +license = license file = Dataset File [repo] diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 5c774f240..58158ea77 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -625,7 +625,7 @@ description = 描述 create_dataset = 创建数据集 category = 分类 task = 针对的具体任务 -Licenses = Licenses +license = license file = 数据集文件 [repo] diff --git a/routers/dataset/dataset.go b/routers/dataset/dataset.go index 1abb5665a..d432c08d2 100644 --- a/routers/dataset/dataset.go +++ b/routers/dataset/dataset.go @@ -6,6 +6,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" ) const ( @@ -58,23 +59,25 @@ func CreatePost(ctx *context.Context, form auth.CreateDatasetForm) { Description: form.Description, License: form.License, Task: form.Task, - Release_id: form.Release_id, - User_id: ctxUser.ID, + ReleaseID: form.ReleaseID, + UserID: ctxUser.ID, Status: 0, } - log.Debug("======================================") - log.Debug("%#v", opts) - log.Debug("======================================") // if !opts.IsValid() { // ctx.RenderWithErr(ctx.Tr("repo.template.one_item"), tplCreate, form) // return - // } if err = models.CreateDataset(&opts); err != nil { log.Error("%v", err) } + if err == nil { + log.Trace("Dataset created [%d]: %s/%s", opts.ID, ctxUser.Name, opts.Title) + ctx.Redirect(setting.AppSubURL + "/datasets") + return + } + // handleCreateError(ctx, ctxUser, err, "CreatePost", tplCreate, &form) } diff --git a/templates/datasets/create.tmpl b/templates/datasets/create.tmpl index 04e642377..646c4fb40 100644 --- a/templates/datasets/create.tmpl +++ b/templates/datasets/create.tmpl @@ -77,10 +77,10 @@