diff --git a/api/application.go b/api/application.go index 833383885..2e048bfa4 100644 --- a/api/application.go +++ b/api/application.go @@ -1069,18 +1069,20 @@ func (h ApplicationHandler) AssessmentCreate(ctx *gin.Context) { return } m := r.Model() - m.Sections = q.Sections m.Thresholds = q.Thresholds m.RiskMessages = q.RiskMessages m.CreateUser = h.CurrentUser(ctx) - - resolver, err := assessment.NewTagResolver(h.DB(ctx)) - if err != nil { - _ = ctx.Error(err) - return + // if sections aren't nil that indicates that this assessment is being + // created "as-is" and should not have its sections populated or autofilled. + if m.Sections == nil { + m.Sections = q.Sections + resolver, rErr := assessment.NewTagResolver(h.DB(ctx)) + if rErr != nil { + _ = ctx.Error(rErr) + return + } + assessment.PrepareForApplication(resolver, application, m) } - assessment.PrepareForApplication(resolver, application, m) - result = h.DB(ctx).Create(m) if result.Error != nil { _ = ctx.Error(result.Error) diff --git a/api/archetype.go b/api/archetype.go index 8f4488d99..690d7e324 100644 --- a/api/archetype.go +++ b/api/archetype.go @@ -283,17 +283,20 @@ func (h ArchetypeHandler) AssessmentCreate(ctx *gin.Context) { return } m := r.Model() - m.Sections = q.Sections m.Thresholds = q.Thresholds m.RiskMessages = q.RiskMessages m.CreateUser = h.CurrentUser(ctx) - - resolver, err := assessment.NewTagResolver(h.DB(ctx)) - if err != nil { - _ = ctx.Error(err) - return + // if sections aren't nil that indicates that this assessment is being + // created "as-is" and should not have its sections populated or autofilled. + if m.Sections == nil { + m.Sections = q.Sections + resolver, rErr := assessment.NewTagResolver(h.DB(ctx)) + if rErr != nil { + _ = ctx.Error(rErr) + return + } + assessment.PrepareForArchetype(resolver, archetype, m) } - assessment.PrepareForArchetype(resolver, archetype, m) result = h.DB(ctx).Create(m) if result.Error != nil { _ = ctx.Error(result.Error)