# 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 pepper.users.models import User
from pepper.app import DB
from pepper.utils import send_email
from pepper import status, settings

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

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

        query_result = User.query.filter(
            User.school_name.like('%[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))

@@ -455,20 +455,23 @@
 ol_name.
-like
+op('~')
 ('%5BuU%5D%5Bn
@@ -506,28 +506,32 @@
 school_name.
-like
+op('~').
 ('%25%5BtT%5D%5BeE%5D%5B
@@ -571,28 +571,32 @@
 school_name.
-like
+op('~').
 ('%25%5BaA%5D%5BuU%5D%5B
@@ -724,12 +724,16 @@
 ame.
-like
+op('~').
 ('%25%5B

change like to regex expression in postgresql