forked from github/server
resetting the waitinglist
This commit is contained in:
parent
baa41eab03
commit
04150b17b2
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import MySQLdb
|
||||
import re
|
||||
import sys
|
||||
|
||||
dbname=sys.argv[1]
|
||||
file=sys.argv[2]
|
||||
game=int(sys.argv[3])
|
||||
infile=open(file, 'r')
|
||||
db=MySQLdb.connect(db=dbname)
|
||||
cursor=db.cursor()
|
||||
|
||||
matchrenum=re.compile(
|
||||
r"""\brenum\s([^\s]+)\s(.*)\n""",
|
||||
re.IGNORECASE | re.DOTALL | re.VERBOSE)
|
||||
|
||||
matchdropout=re.compile(
|
||||
r"""dropout\s(.*)""",
|
||||
re.IGNORECASE | re.DOTALL | re.VERBOSE)
|
||||
|
||||
for line in infile.readlines():
|
||||
match=matchrenum.match(line)
|
||||
if match!=None:
|
||||
fold=match.group(1)
|
||||
fnew=match.group(2)
|
||||
i=cursor.execute("update subscriptions set faction='"+fnew+"' where game="+str(game)+" and faction='"+fold+"'")
|
||||
if i!=1:
|
||||
print "could not renum faction "+fold+" to new id "+fnew
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# reset the waiting list after ZAT.
|
||||
# before running this script, be sure to apply the patchfile generated by the eressea-server to
|
||||
# mark users with new accounts as ACTIVE.
|
||||
# * Will mark WAITING users as EXPIRED, removig them from the waitng list.
|
||||
# * Will mark CONFIRMED users as WAITING, and send them another mail.
|
||||
|
||||
import MySQLdb
|
||||
import re
|
||||
import sys
|
||||
import smtplib
|
||||
|
||||
dbname=sys.argv[1]
|
||||
date=sys.argv[2]
|
||||
db=MySQLdb.connect(db=dbname)
|
||||
From='accounts@eressea-pbem.de'
|
||||
cursor=db.cursor()
|
||||
MailTemplate="templates/register.mail"
|
||||
smtpserver='localhost'
|
||||
server=smtplib.SMTP(smtpserver)
|
||||
|
||||
def Send(email, custid, firstname, password, position, locale):
|
||||
TemplateHandle = open(MailTemplate+"."+locale, "r") # open in read only mode
|
||||
# read the entire file as a string
|
||||
TemplateInput = TemplateHandle.read()
|
||||
TemplateHandle.close() # close the file
|
||||
|
||||
SubResult = re.subn("<FIRSTNAME>", firstname, TemplateInput)
|
||||
SubResult = re.subn("<PASSWORD>", password, SubResult[0])
|
||||
SubResult = re.subn("<POSITION>", str(int(position)), SubResult[0])
|
||||
SubResult = re.subn("<CUSTID>", str(int(custid)), SubResult[0])
|
||||
|
||||
Msg="From: "+From+"\nTo: "+email+"\nSubject: Eressea Anmeldung\n\n"
|
||||
Msg=Msg+SubResult[0]
|
||||
server.sendmail(From, email, Msg)
|
||||
return
|
||||
|
||||
cursor.execute("update users set status='EXPIRED' where TO_DAYS(updated)<TO_DAYS('"+date+"') and status='WAITING'")
|
||||
cursor.execute("update users set status='WAITING' where TO_DAYS(updated)<TO_DAYS('"+date+"') and status='CONFIRMED'")
|
||||
users = cursor.execute("select firstname, locale, email, id, password from users where status='WAITING' order by id")
|
||||
|
||||
position=0
|
||||
while users:
|
||||
users=users-1
|
||||
position=position+1
|
||||
firstname, locale, email, custid, password = cursor.fetchone()
|
||||
print "Sending reminder email to "+str(int(custid))+" "+email
|
||||
Send(email, custid, firstname, password, position, locale)
|
||||
|
||||
server.close()
|
||||
|
|
@ -13,7 +13,7 @@ warnahead=2
|
|||
db=MySQLdb.connect(db=dbname)
|
||||
cursor=db.cursor()
|
||||
|
||||
users = cursor.execute("select users.email, users.id, count(subscriptions.game) from users, subscriptions, games where users.id=subscriptions.user and subscriptions.game=games.id user.id!=0 and games.status='RUNNING' GROUP BY users.id")
|
||||
users = cursor.execute("select users.email, users.id, count(subscriptions.game) from users, subscriptions, games where users.id=subscriptions.user and subscriptions.game=games.id and users.id!=0 and games.status='RUNNING' GROUP BY users.id")
|
||||
server=smtplib.SMTP('localhost')
|
||||
while users > 0:
|
||||
users=users-1
|
||||
|
|
Loading…
Reference in New Issue