def signup_post(): name = get_post_value("name") email = get_post_value("email") phone = get_post_value("phone") errors = resources.members.validate(name, email, phone) # Check if the "agree" checkbox was ticked if get_post_value("agree") is None: errors.append("You must agree to the rules and code of conduct to become a member!") if resources.members.exists(email): errors.append("There is already a member with that email address!") if len(errors) > 0: # This means that an error has occured for e in errors: flash(e, 'danger') return render_template('signup.html', name=name, email=email, phone=phone), 400 resources.members.create(name, email, phone) flash("Thanks for registering!", "success") mailer.send(email, "Welcome to MakeHackVoid!", render_template("emails/signup.txt", name=name)) return signup()
def member_renewal_email(): ''' Finds all expired members who have been 'new style' members - that is they have agreement_date from 2014 onwards, and have not yet been sent a reminder - reminders_date tests will probably want to be a bit more complex at some stage Sends reminder email asking them to renew. ''' members = Entity.select().where(Entity.is_member) do_not_email = app.config['DO_NOT_EMAIL'] # flash('do_not_email= ' + ', '.join(do_not_email)) emails_sent = 0 for member in members: if member.active_member(): None else: if member.name not in do_not_email: if member.agreement_date.year >= 2014 and not member.reminder_date: mailer.send( member.email, "MakeHackVoid membership renewal reminder", render_template("emails/renewal_reminder.txt", name=member.name, email=member.email, agreement_date=member.agreement_date)) # set the reminder date in database so can test when sending another email member.reminder_date = date.today() member.save() emails_sent += 1 flash("Sent " + str(emails_sent) + " once only emails.") return redirect(url_for('.index'))
def member_once_only_email(): ''' Finds all expired members and sends once only email asking them to renew. Used for first run, before we setup regular emails as people expire. ''' members = Entity.select().where(Entity.is_member) do_not_email = app.config['DO_NOT_EMAIL'] # flash('do_not_email= ' + ', '.join(do_not_email)) emails_sent = 0 for member in members: if member.active_member(): None else: if member.name in do_not_email: flash("Not emailing: " + member.name) else: if member.reminder_date: flash("Not emailing: " + member.name + " reminder_date set " + member.reminder_date.strftime('%m/%d/%Y')) else: # only send this email to people who have not joined under new system (2014) if member.agreement_date.year < 2014: mailer.send( member.email, "MakeHackVoid Membership Renewal - once only reminder email", render_template("emails/once_only_renewal.txt", name=member.name, email=member.email)) # set the reminder date in database so can test when sending another email member.reminder_date = date.today() member.save() emails_sent += 1 flash("Sent " + str(emails_sent) + " once only emails.") return redirect(url_for('.index'))
def signup_post(): name = get_post_value("name") email = get_post_value("email") phone = get_post_value("phone") errors = resources.members.validate(name, email, phone) # Check if the "agree" checkbox was ticked if get_post_value("agree") is None: errors.append( "You must agree to the rules and code of conduct to become a member!" ) if resources.members.exists(email): errors.append("There is already a member with that email address!") if len(errors) > 0: # This means that an error has occured for e in errors: flash(e, 'danger') return render_template('signup.html', name=name, email=email, phone=phone), 400 resources.members.create(name, email, phone) flash("Thanks for registering!", "success") mailer.send(email, "Welcome to MakeHackVoid!", render_template("emails/signup.txt", name=name)) return signup()
def renew_post(): email = get_post_value("email") if resources.members.exists(email): token = resources.members.create_token(email) url = url_for("renew_token", token=token, _external=True) mailer.send(email, "MakeHackVoid Membership Renewal", render_template("emails/renew.txt", url=url)) flash("Please the confirmation link sent to your email address to continue.", "info") return render_template("renew.html") else: flash("Sorry, no user exists with that email address.", "danger") return render_template("renew.html", email=email)
def renew_post(): email = get_post_value("email") if resources.members.exists(email): token = resources.members.create_token(email) url = url_for("renew_token", token=token, _external=True) mailer.send(email, "MakeHackVoid Membership Renewal", render_template("emails/renew.txt", url=url)) flash( "Please visit the confirmation link sent to your email address to continue.", "info") return render_template("renew.html") else: flash("Sorry, no user exists with that email address.", "danger") return render_template("renew.html", email=email)