diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index f6c336649..e77798d04 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -122,9 +122,11 @@ function pick(kind, price, coins, marseybux) { if (kind == "agendaposter") { document.getElementById('phrase_section').classList.remove("d-none") + document.getElementById('note_section').classList.add("d-none") } else { document.getElementById('phrase_section').classList.add("d-none") + document.getElementById('note_section').classList.remove("d-none") } if (kind == "flairlock") { @@ -171,16 +173,13 @@ function buy(mb) { function giveaward(t) { const kind = document.getElementById('kind').value; - const values = { - "kind": kind, - "note": document.getElementById('note').value - } - - if (kind == "agendaposter") - values["agendaposter_phrase"] = document.getElementById('agendaposter_phrase').value + const note_id = (kind == "agendaposter" ? "agendaposter_phrase" : "note") postToast(t, t.dataset.action, - values, + { + "kind": kind, + "note": document.getElementById(note_id).value + }, () => { let owned = document.getElementById(`${kind}-owned`) let ownednum = Number(owned.textContent) - 1; diff --git a/files/routes/awards.py b/files/routes/awards.py index a921cbeea..801b7145d 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -300,21 +300,17 @@ def award_thing(v, thing_type, id): abort(409, f"{safe_username} is under the effect of a conflicting award: Marsey award!") if author.agendaposter == 1: - abort(409, f"{safe_username} is perma-chudded!") + abort(409, f"{safe_username} is already chudded permanently!") if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400 else: author.agendaposter = int(time.time()) + 86400 - agendaposter_phrase = request.values.get("agendaposter_phrase").lower() - if not agendaposter_phrase: abort(400, "Missing phrase!") + if not note: abort(400, "Missing phrase!") - agendaposter_phrase = agendaposter_phrase.strip() - if not agendaposter_phrase: abort(400, "Missing phrase!") - - if len(agendaposter_phrase) > 50: + if len(note) > 50: abort(400, "Max length for phrase is 50 characters!") - author.agendaposter_phrase = agendaposter_phrase + author.agendaposter_phrase = note badge_grant(user=author, badge_id=28) elif kind == "flairlock": diff --git a/files/templates/modals/award.html b/files/templates/modals/award.html index bbc172d27..078f13d7d 100644 --- a/files/templates/modals/award.html +++ b/files/templates/modals/award.html @@ -54,8 +54,10 @@ - - +
+ + +