diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index 22f44cc..7955131 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -127,7 +127,7 @@ func (svc *Service) SetSubmissionCompleted(ctx context.Context, params api.SetSu return err } -// PatchSubmissionModel implements patchSubmissionModel operation. +// UpdateSubmissionModel implements patchSubmissionModel operation. // // Update model following role restrictions. // diff --git a/pkg/service_internal/submissions.go b/pkg/service_internal/submissions.go index 491939d..8e46735 100644 --- a/pkg/service_internal/submissions.go +++ b/pkg/service_internal/submissions.go @@ -8,6 +8,21 @@ import ( "git.itzana.me/strafesnet/maps-service/pkg/model" ) +// UpdateSubmissionModel implements patchSubmissionModel operation. +// +// Update model following role restrictions. +// +// POST /submissions/{SubmissionID}/model +func (svc *Service) UpdateSubmissionModel(ctx context.Context, params internal.UpdateSubmissionModelParams) error { + // check if Status is ChangesRequested|Submitted|UnderConstruction + pmap := datastore.Optional() + pmap.AddNotNil("asset_id", params.ModelID) + pmap.AddNotNil("asset_version", params.VersionID) + //always reset completed when model changes + pmap.Add("completed", false) + return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.Status{model.StatusValidating}, pmap) +} + // ActionSubmissionValidate invokes actionSubmissionValidate operation. // // Role Validator changes status from Validating -> Validated.