Permalink
Browse files

Add number to attachment name if name is None

  • Loading branch information...
1 parent 0d10815 commit 8892c642a5c2b1cb4cb9fe48e32e868b40d08d8b @stefanw stefanw committed Jul 1, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 froide/foirequest/models.py
@@ -526,13 +526,13 @@ def add_message_from_email(self, email, mail_string):
self.last_message = message.timestamp
self.save()
has_pdf = False
- for attachment in email['attachments']:
+ for i, attachment in enumerate(email['attachments']):
att = FoiAttachment(belongs_to=message,
name=attachment.name,
size=attachment.size,
filetype=attachment.content_type)
if att.name is None:
- att.name = _("attached_file")
+ att.name = _("attached_file_%d") % i
att.name = re.sub('[^\w\.\-]', '', att.name)
if att.name.endswith('pdf') or 'pdf' in att.filetype:
has_pdf = True

0 comments on commit 8892c64

Please sign in to comment.