Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/shiftings/shifts/forms/shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def clean(self) -> Dict[str, Any]:
start = cleaned_data.get('start')
end = cleaned_data.get('end')
if start and end and start > end:
self.add_error('end', ValidationError(""))
self.add_error('start', ValidationError(""))
raise ValidationError(_('End time must be after start time'))

## TODO: raise form error if not valid, but first implement proper error display in template
Expand Down
12 changes: 11 additions & 1 deletion src/shiftings/shifts/templates/shifts/create_shift.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ <h4>Update Shift "{{ name }} for {{ organization }}"</h4>
</div>
</div>
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{% for error in form.non_field_errors %}
{% if 'constraint' not in error|lower %}
<div>{{ error }}</div>
{% endif %}
{% endfor %}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endif %}
{% bootstrap_field form.name %}
{% bootstrap_field form.place %}
<div class="center-items">
Expand Down Expand Up @@ -87,4 +97,4 @@ <h4>{% trans "Create from Template" %}</h4>
</div>
{% endif %}
</div>
{% endblock %}
{% endblock %}
30 changes: 30 additions & 0 deletions src/shiftings/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,36 @@ nav .dropdown {
border-color: var(--bs-body-color) !important;
}

.form-control.is-valid:not([required]),
.form-control-color.is-valid:not([required]) {
border-color: var(--bs-gray-700);
box-shadow: none;
background-image: none;
padding-right: .75rem;
}

.form-select.is-valid {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
background-position: right .75rem center;
background-size: 16px 12px;
}

.form-select.is-valid:not([required]) {
border-color: var(--bs-gray-700);
box-shadow: none;
padding-right: 2.25rem;
}

.form-check-input.is-valid:not([required]) {
border-color: var(--bs-body-color) !important;
background-color: transparent;
box-shadow: none;
}

.form-check-input.is-valid:not([required]) ~ .form-check-label {
color: var(--bs-body-color) !important;
}

.plain-link, .link, .link-remove {
cursor: pointer;
text-decoration: none;
Expand Down