Jun 24 - Set broadcast message limit to 500 characters
This commit is contained in:
@@ -76,6 +76,8 @@ def send():
|
|||||||
errors.append('Title must be 255 characters or fewer.')
|
errors.append('Title must be 255 characters or fewer.')
|
||||||
if not body:
|
if not body:
|
||||||
errors.append('Message body is required.')
|
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]
|
valid_roles = [r for r in target_roles if r in BROADCAST_ROLES]
|
||||||
if not valid_roles:
|
if not valid_roles:
|
||||||
errors.append('Select at least one target role.')
|
errors.append('Select at least one target role.')
|
||||||
|
|||||||
@@ -48,9 +48,12 @@
|
|||||||
Message <span class="text-danger">*</span>
|
Message <span class="text-danger">*</span>
|
||||||
</label>
|
</label>
|
||||||
<textarea class="form-control" id="body" name="body"
|
<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>
|
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>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
@@ -149,4 +152,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!-- /row -->
|
</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 %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user