Esempio n. 1
0
 def notify_restaurant(self, status):
     """Sends a message to the restaurant with the information about the order
     and flags the order as either sent or paid.
     """
     self.status = status
     content = self.get_pdf_invoice()
     location = self.site.location_set.all()[0]
     if location.receive_via == OrderSettings.RECEIPT_EMAIL:
         email = EmailMessage('Takeout Tiger Order #%d' % self.id,
                              'Your order details are attached as PDF.',
                              '*****@*****.**',
                              [location.order_email])
         email.attach('order-%d.pdf' % self.id, content, 'application/pdf')
         email.send()
     else:
         fax_machine = FaxMachine(self.site)
         fax_machine.send(self.site.fax_number, content)
     self.save()
Esempio n. 2
0
 def dispatch_fax(self, fax_list):
     site = self.site
     social = site.social
     fax_machine = FaxMachine(site)
     cover_page = None
     attachment = None
     if self.body:
         cover_page = render_to_pdf('notify/cover_page.html', {'release': self})
         content = cover_page
     if self.pdf:
         attachment = open(self.pdf.path).read()
         content = attachment
     kwargs ={}
     if cover_page and attachment:
         kwargs['FileSizes'] = '%d;%d' % (len(cover_page), len(attachment))
         kwargs['FileTypes'] = 'PDF;PDF'
         content = cover_page + attachment
     fax_numbers = [s.fax for s in fax_list.subscriber_set.all()]
     transaction = fax_machine.send(fax_numbers, content, **kwargs)
     Release.objects.filter(id=self.id).update(
         fax_transaction = transaction
     )
     Fax.objects.create(parent_transaction=transaction, 
         transaction=transaction, site=site)