0001-initialize-document_type-in-FileField.__setstate__.patch
wcs/fields.py | ||
---|---|---|
726 | 726 | |
727 | 727 |
@property |
728 | 728 |
def file_type(self): |
729 |
return (self.document_type or {}).get('mimetypes', [])
|
|
729 |
return self.document_type.get('mimetypes', [])
|
|
730 | 730 | |
731 | 731 |
def fill_admin_form(self, form): |
732 | 732 |
WidgetField.fill_admin_form(self, form) |
733 | 733 |
document_types = self.get_document_types() |
734 |
cur_dt = self.document_type or {}
|
|
734 |
cur_dt = self.document_type |
|
735 | 735 |
# SingleSelectWidget compare the value and not the keys, so if we want |
736 | 736 |
# the current value not to be hidden, we must reset it with the corresponding |
737 | 737 |
# value from settings based on the 'id' |
... | ... | |
824 | 824 |
for key, document_type in document_types.iteritems(): |
825 | 825 |
document_type['id'] = key |
826 | 826 |
# add current file type if it does not exist anymore in the settings |
827 |
cur_dt = self.document_type or {}
|
|
827 |
cur_dt = self.document_type |
|
828 | 828 |
if cur_dt and cur_dt['id'] not in document_types: |
829 | 829 |
document_types[cur_dt['id']] = cur_dt |
830 | 830 |
return document_types |
... | ... | |
890 | 890 |
value = data.get(field_id) |
891 | 891 |
return getattr(value, 'metadata', {}) |
892 | 892 | |
893 |
def __setstate__(self, state): |
|
894 |
self.__dict__ = state |
|
895 |
self.document_type = self.document_type or {} |
|
896 | ||
893 | 897 | |
894 | 898 |
register_field_class(FileField) |
895 | 899 | |
896 |
- |