Jun 24 - Set broadcast message limit to 500 characters

This commit is contained in:
2026-06-24 13:34:53 -04:00
parent ed546418d2
commit 118238f030
2 changed files with 25 additions and 2 deletions
+2
View File
@@ -76,6 +76,8 @@ def send():
errors.append('Title must be 255 characters or fewer.')
if not body:
errors.append('Message body is required.')
elif len(body) > 500:
errors.append('Message must be 500 characters or fewer.')
valid_roles = [r for r in target_roles if r in BROADCAST_ROLES]
if not valid_roles:
errors.append('Select at least one target role.')
+23 -2
View File
@@ -48,9 +48,12 @@
Message <span class="text-danger">*</span>
</label>
<textarea class="form-control" id="body" name="body"
rows="4" required
rows="4" required maxlength="500"
placeholder="e.g. A new version of JanitorialQC is available. Please update to v1.3 from the App Store."></textarea>
<div class="form-text">The full message body shown in the notification and in-app inbox.</div>
<div class="d-flex justify-content-between align-items-center mt-1">
<span class="form-text mb-0">The full message body shown in the notification and in-app inbox.</span>
<span id="bodyCounter" class="form-text mb-0 text-muted">0 / 500</span>
</div>
</div>
<div class="mb-4">
@@ -149,4 +152,22 @@
</div>
</div><!-- /row -->
{% block scripts %}
<script>
(function () {
var textarea = document.getElementById('body');
var counter = document.getElementById('bodyCounter');
var MAX = 500;
function update() {
var len = textarea.value.length;
counter.textContent = len + ' / ' + MAX;
counter.className = 'form-text mb-0 ' + (len >= MAX ? 'text-danger fw-semibold' : len >= MAX * 0.9 ? 'text-warning' : 'text-muted');
}
textarea.addEventListener('input', update);
update();
})();
</script>
{% endblock %}