Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #1760 from laws-africa/source-file""
Browse files Browse the repository at this point in the history
This reverts commit 9e18d6b.
  • Loading branch information
longhotsummer committed Mar 6, 2024
1 parent 9e18d6b commit 22154a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 2 additions & 5 deletions peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ def clean_content_html(self):
return self.instance.content_html
return self.cleaned_data["content_html"]

def _save_m2m(self):
super()._save_m2m()
# update document text
self.instance.update_text_content()


class AttachedFilesInline(BaseAttachmentFileInline):
model = AttachedFiles
Expand Down Expand Up @@ -504,7 +499,9 @@ def save_related(self, request, form, formsets, change):
cp.queue_re_extract_citations(form.instance.date)

super().save_related(request, form, formsets, change)

form.instance.save()
form.instance.update_text_content()

def get_urls(self):
return [
Expand Down
11 changes: 11 additions & 0 deletions peachjam/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ def _save_m2m(self):
self.instance.file_as_pdf.delete()
self.instance.ensure_file_as_pdf()

def clean(self):
cleaned_data = super().clean()
if "file" in self.changed_data:
# clear all the fields that are derived from the file
self.instance.mimetype = None
self.instance.size = None
self.instance.file_as_pdf = None
self.instance.filename = None

return cleaned_data


class AttachedFilesForm(AttachmentFormMixin, forms.ModelForm):
class Meta:
Expand Down

0 comments on commit 22154a9

Please sign in to comment.