|
|
|
@@ -7,6 +7,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/routers/repo" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
@@ -92,6 +93,68 @@ func CreatePost(ctx *context.Context, form auth.CreateDatasetForm) { |
|
|
|
// handleCreateError(ctx, ctxUser, err, "CreatePost", tplCreate, &form) |
|
|
|
} |
|
|
|
|
|
|
|
// EditRelease render release edit page |
|
|
|
func EditDataset(ctx *context.Context) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.dataset.edit_release") |
|
|
|
ctx.Data["PageIsEditDataset"] = true |
|
|
|
repo.RenderAttachmentSettings(ctx) |
|
|
|
rel, err := models.GetDatasetByID(ctx.ParamsInt64(":id")) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetDataset", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.Data["ID"] = rel.ID |
|
|
|
ctx.Data["title"] = rel.Title |
|
|
|
ctx.Data["description"] = rel.Description |
|
|
|
ctx.Data["category"] = rel.Category |
|
|
|
ctx.Data["task"] = rel.Task |
|
|
|
ctx.Data["license"] = rel.License |
|
|
|
|
|
|
|
ctx.HTML(200, tplCreate) |
|
|
|
} |
|
|
|
|
|
|
|
func EditDatasetPost(ctx *context.Context, form auth.EditDatasetForm) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.dataset.edit_release") |
|
|
|
ctx.Data["PageIsEditDataset"] = true |
|
|
|
|
|
|
|
rel, err := models.GetDatasetByID(ctx.ParamsInt64(":id")) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetDataset", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.Data["ID"] = rel.ID |
|
|
|
ctx.Data["title"] = rel.Title |
|
|
|
ctx.Data["description"] = rel.Description |
|
|
|
ctx.Data["category"] = rel.Category |
|
|
|
ctx.Data["task"] = rel.Task |
|
|
|
ctx.Data["license"] = rel.License |
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, tplCreate) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var attachmentUUIDs []string |
|
|
|
if setting.Attachment.Enabled { |
|
|
|
attachmentUUIDs = form.Files |
|
|
|
} |
|
|
|
|
|
|
|
rel.Title = form.Title |
|
|
|
rel.Description = form.Description |
|
|
|
rel.Category = form.Category |
|
|
|
rel.Task = form.Task |
|
|
|
rel.License = form.License |
|
|
|
if err = models.UpdateDataset(models.DefaultDBContext(), rel); err != nil { |
|
|
|
log.Error("%v", err) |
|
|
|
} |
|
|
|
|
|
|
|
if err = models.AddDatasetAttachments(rel.ID, attachmentUUIDs); err != nil { |
|
|
|
log.Error("%v", err) |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/datasets") |
|
|
|
} |
|
|
|
|
|
|
|
func Delete(ctx *context.Context) { |
|
|
|
log.Debug("[dataset] Delete...\n") |
|
|
|
} |