From 7f7561ad3e0691363efcd16e4f1cd46489d7839b Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 16 Sep 2022 12:14:26 +0200 Subject: [PATCH] On work/survey update, regenerate description from markdown --- questions.go | 2 ++ works.go | 1 + 2 files changed, 3 insertions(+) diff --git a/questions.go b/questions.go index 3087001..19a4a25 100644 --- a/questions.go +++ b/questions.go @@ -311,6 +311,8 @@ func (q *Question) Update() (*Question, error) { if _, err := DBExec("UPDATE survey_quests SET id_survey = ?, title = ?, description = ?, placeholder = ?, kind = ? WHERE id_question = ?", q.IdSurvey, q.Title, q.DescriptionRaw, q.Placeholder, q.Kind, q.Id); err != nil { return nil, err } else { + q.Description = string(blackfriday.Run([]byte(q.DescriptionRaw))) + _questions_cache_mutex.Lock() _questions_cache[q.Id] = q _questions_cache_mutex.Unlock() diff --git a/works.go b/works.go index 248e35c..3b0a106 100644 --- a/works.go +++ b/works.go @@ -345,6 +345,7 @@ func (w *Work) Update() (*Work, error) { if _, err := DBExec("UPDATE works SET title = ?, promo = ?, grp = ?, shown = ?, description = ?, tag = ?, submission_url = ?, corrected = ?, start_availability = ?, end_availability = ? WHERE id_work = ?", w.Title, w.Promo, w.Group, w.Shown, w.DescriptionRaw, w.Tag, w.SubmissionURL, w.Corrected, w.StartAvailability, w.EndAvailability, w.Id); err != nil { return nil, err } else { + w.Description = string(blackfriday.Run([]byte(w.DescriptionRaw))) return w, err } }