Skip to content

Commit

Permalink
feat: Custom fn_part for kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
miggol committed Jan 6, 2025
1 parent 135b4a7 commit c75fe13
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion attachments/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class AttachmentKind:
attached_field = "attachments"
desiredness = desiredness.OPTIONAL

def get_fn_part(self):
if hasattr(self, "fn_part"):
return self.fn_part
# Capitalize DB name
parts = self.db_name.split("_")
return "_".join([part.capitalize() for part in parts])


class AttachmentSlot(renderable):

Expand Down Expand Up @@ -316,7 +323,7 @@ def generate_filename(slot):
lastname = proposal.created_by.last_name
refnum = proposal.reference_number
original_fn = slot.attachment.upload.original_filename
kind = slot.kind.name
kind = slot.kind.get_fn_part()

extension = (
"." + original_fn.split(".")[-1][-7:]
Expand Down

0 comments on commit c75fe13

Please sign in to comment.