Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #400

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

WIP #400

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
10 changes: 10 additions & 0 deletions contrib/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,21 @@ class Media:
)


class AdmissionFileBoundField(forms.BoundField):
@property
def bound_css_class(self):
if self.value() in self.field.empty_values:
return 'empty-file-upload'


class AdmissionFileUploadField(FileUploadField):
def __init__(self, **kwargs):
kwargs.setdefault('mimetypes', DEFAULT_MIME_TYPES)
super().__init__(**kwargs)

def get_bound_field(self, form, field_name):
return AdmissionFileBoundField(form=form, field=self, name=field_name)


def get_example_text(example: str):
return _("e.g.: %(example)s") % {'example': example}
Expand Down
6 changes: 5 additions & 1 deletion static/admission/admission.css
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,8 @@ body, html {

.mt-1 {
margin-top: 1em;
}
}

.required_field.empty-file-upload label, .required_field .empty-file-upload:first-child label {
color: #a94442;
}