Exemple #1
0
        def messages():
            for sub in subs:
                message = Message(user=sub.user,
                                  body=body,
                                  sent_at=body.sent_at)

                # collect to a bulk email if the subscription is by email:
                if sub.type == EMAIL_MESSAGE or sub.type == ALL_MESSAGES:
                    try:
                        token = ReplyToken(user=sub.user,
                                           post=post,
                                           token=make_uuid(8),
                                           date=now())
                        from_email = settings.EMAIL_FROM_PATTERN % (
                            author.name, settings.DEFAULT_FROM_EMAIL)
                        from_email = from_email.encode("utf-8")
                        reply_to = settings.EMAIL_REPLY_PATTERN % token.token
                        subject = settings.EMAIL_REPLY_SUBJECT % body.subject
                        # create the email message
                        email = mail.EmailMultiAlternatives(
                            subject=subject,
                            body=email_text,
                            from_email=from_email,
                            to=[sub.user.email],
                            headers={'Reply-To': reply_to},
                        )
                        email.attach_alternative(email_html, "text/html")
                        emails.append(email)
                        tokens.append(token)
                    except Exception, exc:
                        # This here can crash the post submission hence the catchall
                        logger.error(exc)

                yield message
        def messages():
            for sub in subs:
                message = Message(user=sub.user, body=body, sent_at=body.sent_at)

                # collect to a bulk email if the subscription is by email:
                if sub.type == EMAIL_MESSAGE or sub.type == ALL_MESSAGES:
                    try:
                        token = ReplyToken(user=sub.user, post=post, token=make_uuid(8), date=now())
                        from_email = settings.EMAIL_FROM_PATTERN % (author.name, settings.DEFAULT_FROM_EMAIL)
                        from_email = from_email.encode("utf-8")
                        reply_to = settings.EMAIL_REPLY_PATTERN % token.token
                        subject = settings.EMAIL_REPLY_SUBJECT % body.subject
                        # create the email message
                        email = mail.EmailMultiAlternatives(
                            subject=subject,
                            body=email_text,
                            from_email=from_email,
                            to=[sub.user.email],
                            headers={'Reply-To': reply_to},
                        )
                        email.attach_alternative(email_html, "text/html")
                        emails.append(email)
                        tokens.append(token)
                    except Exception, exc:
                        # This here can crash the post submission hence the catchall
                        logger.error(exc)

                yield message
Exemple #3
0
    def save(self, *args, **kwargs):

        # Clean the info fields.
        self.info = bleach.clean(self.info, tags=ALLOWED_TAGS,
                                 attributes=ALLOWED_ATTRIBUTES, styles=ALLOWED_STYLES)

        if not self.id:
            # This runs only once upon object creation.
            self.uuid = util.make_uuid()
            self.date_joined = self.date_joined or now()
            self.last_login = self.date_joined

        super(Profile, self).save(*args, **kwargs)
Exemple #4
0
    def save(self, *args, **kwargs):

        # Clean the info fields.
        self.info = bleach.clean(self.info,
                                 tags=ALLOWED_TAGS,
                                 attributes=ALLOWED_ATTRIBUTES,
                                 styles=ALLOWED_STYLES)

        if not self.id:
            # This runs only once upon object creation.
            self.uuid = util.make_uuid()
            self.date_joined = self.date_joined or datetime.datetime.utcnow(
            ).replace(tzinfo=utc)
            self.last_login = self.date_joined

        super(Profile, self).save(*args, **kwargs)
    def save(self, *args, **kwargs):

        # Clean the info fields.
        self.info = bleach.clean(self.info, tags=ALLOWED_TAGS,
                                 attributes=ALLOWED_ATTRIBUTES, styles=ALLOWED_STYLES)


        # Strip whitespace from location string
        self.location = self.location.strip()

        if not self.id:
            # This runs only once upon object creation.
            self.uuid = util.make_uuid()
            self.date_joined = self.date_joined or now()
            self.last_login = self.date_joined

        super(Profile, self).save(*args, **kwargs)
Exemple #6
0
 def save(self, *args, **kwargs):
     if not self.id:
         self.token = util.make_uuid()
     super(ReplyToken, self).save(*args, **kwargs)
Exemple #7
0
 def save(self, *args, **kwargs):
     if not self.id:
         self.token = util.make_uuid()
     super(ReplyToken, self).save(*args, **kwargs)