Ejemplo n.º 1
0
def expire_email(testing=False):
    for item in Advert.get_by_expiration():
        if not item.is_deleted and not item.is_deactivated:
            if item.is_expired:
                print item.owner + " delete"
                if not testing:
                    item.mark_deactivated(True)
                    item.save()
            else:
                print item.owner
                if not testing:
                    activation_link = app.config['LOCALHOST_URL'] + "/advert/" + item.id + "/reactivate"
                    to = [item.owner, app.config['BCC_EMAIL']]
                    fro = app.config['FEEDBACK_EMAIL']
                    subject = app.config.get("SERVICE_NAME", "") + ': ' + item.title + " - expires soon"
                    text = "Hello, " + item.owner + "!\n\n"
                    text += "Your advert " + item.title + " expires soon."
                    text += "Please visit " + activation_link + " if you want to keep it up for another week.\n\n"
                    text += "Regards, The UniBoard Team"

                    util.send_mail(to=to, fro=fro, subject=subject, text=text)
Ejemplo n.º 2
0
def create_still_okay():
    advert = Advert()
    advert.set_owner('*****@*****.**')
    advert.set_title('Foot')
    advert.set_authors('Feet')
    advert.set_price(50)
    advert.set_expires((datetime.now() + timedelta(days=365)).strftime(DATE_FORMAT))
    advert.save()
    print advert.owner
    return advert
Ejemplo n.º 3
0
def create_soon_expiring():
    advert = Advert()
    advert.set_owner('*****@*****.**')
    advert.set_title('Glug')
    advert.set_authors('Mug')
    advert.set_price(50)
    advert.set_expires((datetime.now() + timedelta(hours=36)).strftime(DATE_FORMAT))
    advert.save()
    print advert.owner
    return advert
Ejemplo n.º 4
0
def create_expired():
    advert = Advert()
    advert.set_owner('*****@*****.**')
    advert.set_title('Hippy')
    advert.set_authors('Pony')
    advert.set_price(50)
    advert.set_expires((datetime.now() - timedelta(days=365)).strftime(DATE_FORMAT))
    advert.save()
    print advert.owner
    return advert