# The purpose of this script is to move all of the pending users with confirmed emails to the waitlist

from flask import render_template
from flask_script import Command
from sqlalchemy import and_

from pepper.users.models import User
from pepper.app import DB
from pepper.utils import send_email
from pepper import status, settings

import cStringIO
import base64
import qrcode

class SendPreeventEmailCommand(Command):
    def run(self):
        users = []

        query_result = User.query.filter(
            User.school_name.ilike('[uU][nN][iI]%'),
            User.school_name.ilike('%[tT][eE][xX][aA][sS]%'),
            User.school_name.ilike('%[aA][uU][sS]%')
        ).all()
        users += query_result

        query_result = User.query.filter(
            User.school_name.ilike('%[uU][tT] [aA][uU]%')
        ).all()
        users += query_result

        for user in users:
            user_email = user.email

            html =
                render_template('emails/application_decisions/freetail_recruitment.html', user=user)
            send_email(settings.GENERAL_INFO_EMAIL, "Join Freetail
                    Hackers -- the organizers of {}!".format(settings.HACKATHON_NAME),
                       user.email, html_content=html, attachments=None)
            print ('Sent freetail recruitment email to user_id={}'.format(user.id))

@@ -941,32 +941,16 @@
   html =
-%0A               
  render_
@@ -1050,16 +1050,33 @@
 d_email(
+%0A                
 settings
@@ -1099,23 +1099,8 @@
 AIL,
- %22Join Freetail
 %0A   
@@ -1112,19 +1112,30 @@
         
-   
+%22Join Freetail
  Hackers
@@ -1206,31 +1206,24 @@
             
-       
 user.email, 
@@ -1221,16 +1221,32 @@
 r.email,
+%0A               
  html_co
@@ -1256,16 +1256,32 @@
 nt=html,
+%0A               
  attachm
@@ -1289,16 +1289,29 @@
 nts=None
+%0A            
 )%0A      

edit script spacing errors