def remind(self, card, force=False, last_state=None):
        # Get last reminded for card
        last_reminder_sent = self.last_reminded(card)
        if not force and last_reminder_sent and (last_reminder_sent.sent_date - datetime.now()).days < 1:
            # Don't proceed if we've already sent out a reminder today
            app.logger.info('%s Reminder for card %s has already been sent today. Last sent: %s' % (self.type,
                                                                                                    card.last_four,
                                                                                                    last_reminder_sent))
            return

        app.logger.info('Begin %s reminder check for %s' % (self.type, card.last_four))

        if not self.check_reminder(card, last_state=last_state):
            app.logger.info('Card %s does not need a %s reminder' % (card.last_four, self.type))
            return

        from flask import render_template
        from breezeminder.app import context, filters
        from breezeminder.models.messaging import Messaging

        app.logger.info('Reminding user %s of %s at or below threshold' % (self.owner.id, self.type))

        subject = '[BreezeMinder] %s reminder' % self.type.name
        messages = []
        context = {
            'card': card,
            'reminder': self,
            'last_state': last_state
        }

        # Build list of expiring content
        if self.type == 'EXP':
            delta = self._exp_delta()
            expiring = {
                'card': self._will_expire(card.expiration_date, delta)
            }

            expiring['products'] = [ p for p in card.products if self._will_expire(p.expiration_date, delta) ]
            context['expiring'] = expiring

        if self.send_email:
            template = 'messages/email/reminders/%s.html' % self.type.key.lower()
            with app.test_request_context():
                content = render_template(template, **context)

            # Queue message for celery
            Messaging.objects.create(recipients=[self.owner.email],
                                     sender=app.config['DEFAULT_MAIL_SENDER'],
                                     subject=subject,
                                     message=content)

        if self.send_sms:
            recipients=[]
            if self.owner.can_receive_sms:
                recipients.append(self.owner.cell_phone.sms_address)

            if len(recipients) > 0:
                template = 'messages/sms/reminders/%s.html' % self.type.key.lower()
                with app.test_request_context():
                    content = render_template(template, **context)

                # Make mobile friendly by removing excess whitespace
                content = re.sub('\s{2,}', ' ', content)

                subject = '%s reminder' % self.type.name

                # Queue message for celery
                Messaging.objects.create(recipients=recipients,
                                         sender=app.config['DEFAULT_MAIL_SENDER'],
                                         subject=subject.upper(), 
                                         message=content,
                                         is_plain=True)

        # Record History, but don't bring down the house
        try:
            with app.test_request_context():
                web_message = render_template('messages/web/reminders/%s.html' % self.type.key.lower(), **context)

            ReminderHistory.objects.create(reminder=self,
                                           card=card,
                                           message=web_message,
                                           sent_date=datetime.now(),
                                           owner=self.owner)
        except:
            app.logger.exception('Could not save a reminder history object')

        # Bump the last reminder
        self.save()
dataset/ETHPy150Open shaunduncan/breezeminder/breezeminder/models/reminder.py/Reminder.remind/swapped operands of `-`