コード例 #1
0
ファイル: models.py プロジェクト: physikerwelt/Praktomat
    def withdraw(self, request, by):
        self.published = False
        self.final = False
        self.published_on = datetime.now()
        self.save()

        recps = nub([
            self.solution.author,  # student
            self.author,  # attestation writer
            by,  # usually attestation writer, may be trainer
        ] + list(User.objects.filter(
            groups__name="Trainer"))  # and, for withdrawals, all trainers
                    )
        emails = [u.email for u in recps if u.email]

        if not emails:
            return

        # Send confirmation email
        t = loader.get_template('attestation/attestation_withdraw_email.html')
        c = {
            'attest': self,
            'protocol': request.is_secure() and "https" or "http",
            'domain': RequestSite(request).domain,
            'site_name': settings.SITE_NAME,
            'by': by,
        }
        subject = _("Attestation for your solution of the task '%s' withdrawn"
                    ) % self.solution.task
        body = t.render(c)
        recipients = emails[0:1]
        bcc_recipients = emails[1:]
        email = EmailMessage(subject, body, None, recipients, bcc_recipients)
        email.send()
コード例 #2
0
ファイル: models.py プロジェクト: ifrh/Praktomat
        def withdraw(self, request, by):
		self.published = False
                self.final = False
		self.published_on = datetime.now()
		self.save()

                recps = nub([
                    self.solution.author, # student
                    self.author,          # attestation writer
                    by,                   # usually attestation writer, may be trainer
                    ] + list(User.objects.filter(groups__name="Trainer"))  # and, for withdrawals, all trainers
                    )
                emails = [u.email for u in recps if u.email]

                if not emails:
                    return

		# Send confirmation email
                t = loader.get_template('attestation/attestation_withdraw_email.html')
                c = {
                        'attest': self,
                        'protocol': request.is_secure() and "https" or "http",
                        'domain': RequestSite(request).domain,
                        'site_name': settings.SITE_NAME,
                        'by': by,
                        }
                subject = _("Attestation for your solution of the task '%s' withdrawn") % self.solution.task
                body = t.render(c)
                recipients = emails[0:1]
                bcc_recipients = emails[1:]
                email = EmailMessage(subject, body, None, recipients, bcc_recipients)
                email.send()