def add_attachments(self, flag):
     ''' Add uploaded files as attachments to flags '''
     if hasattr(self.request, 'files'):
         if not 'attachments' in self.request.files:
             return
         for attachment in self.request.files['attachments']:
             flag_attachment = FlagAttachment(file_name=attachment['name'])
             flag_attachment.data = attachment['body']
             flag.attachments.append(flag_attachment)
             self.dbsession.add(flag_attachment)
         self.dbsession.flush()
示例#2
0
 def add_attachments(self, flag):
     """ Add uploaded files as attachments to flags """
     if hasattr(self.request, "files"):
         if "flag" not in self.request.files:
             return
         for attachment in self.request.files["flag"]:
             flag_attachment = FlagAttachment(file_name=attachment["filename"])
             flag_attachment.data = attachment["body"]
             flag.flag_attachments.append(flag_attachment)
             self.dbsession.add(flag_attachment)
         self.dbsession.flush()
 def add_attachments(self, flag):
     ''' Add uploaded files as attachments to flags '''
     if hasattr(self.request, 'files'):
         if not 'attachments' in self.request.files:
             return
         for attachment in self.request.files['attachments']:
             flag_attachment = FlagAttachment(file_name=attachment['name'])
             flag_attachment.data = attachment['body']
             flag.attachments.append(flag_attachment)
             self.dbsession.add(flag_attachment)
         self.dbsession.flush()