Exemplo n.º 1
0
    def save(self, *args, **kwargs):
        if not self.id and self.document:
            self.id = prefetch_id(self)

            email_list = []
            for entry in Download.objects.filter(jobdocument__job = self.job):
                if entry.downloaduser.email not in email_list:
                    email_list.append(entry.downloaduser.email)
                    
            message = "A new document has been uploaded for job: %(job_title)s. This new document is available to download from http://www.grimesengineering.com%(job_url)s" % {
                'job_url': self.job.url,
                'job_title': self.job.name,
            }
            from postmark import PMMail
            message = PMMail(
                 api_key = settings.POSTMARK_API_KEY,
                 subject = "Grimes & Associates New Document Uploaded",
                 sender = "*****@*****.**",
                 cc = ','.join(email_list),
                 to = "*****@*****.**",
                 text_body = message,
                 tag = "new document",
            )
            message.send()

        super(JobDocument, self).save(*args, **kwargs)
Exemplo n.º 2
0
 def save(self, *args, **kwargs):
     if not self.id and self.image:
         self.id = prefetch_id(self)
     super(JobImage, self).save(*args, **kwargs)