diff --git a/scripts/register/noowner.sql b/scripts/register/noowner.sql new file mode 100644 index 000000000..5901c995c --- /dev/null +++ b/scripts/register/noowner.sql @@ -0,0 +1,3 @@ +select id ID, faction Partei, race Rasse, status Status + from subscriptions + where user=0; diff --git a/scripts/register/register.py b/scripts/register/register.py index 33b42f636..9b57cdf14 100755 --- a/scripts/register/register.py +++ b/scripts/register/register.py @@ -54,16 +54,6 @@ matchemail=re.compile( re.IGNORECASE | re.DOTALL | re.VERBOSE) email=None -matchuserid=re.compile( - r""".*userid:\s*([^\n\r]*)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -userid=None - -matchpassword=re.compile( - r""".*passwort:\s*([^\n\r]*)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -password=None - matchaddress=re.compile( r""".*adresse:\s*([^\n\r]*)\s*""", re.IGNORECASE | re.DOTALL | re.VERBOSE) @@ -84,58 +74,12 @@ matchphone=re.compile( re.IGNORECASE | re.DOTALL | re.VERBOSE) phone=None -matchnewrace=re.compile( - r""".*neues\sspiel:\s*([^\n\r]+)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -newrace=0 - -matcholdrace=re.compile( - r""".*altes\sspiel:\s*([^\n\r]+)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -oldrace=0 - -matchstandin=re.compile( - r""".*Stand-In:\s(on)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -standin=0 - -matchwaiting=re.compile( - r""".*Warteliste:\s(on)\s*""", - re.IGNORECASE | re.DOTALL | re.VERBOSE) -waiting=0 - for line in sys.stdin.readlines(): - match=matchwaiting.match(line) - if (match!=None): - waiting=1 - continue - match=matchstandin.match(line) - if (match!=None): - standin=1 - continue - match=matcholdrace.match(line) - if (match!=None): - oldrace=match.group(1) - continue - match=matchnewrace.match(line) - if (match!=None): - newrace=match.group(1) - continue - match=matchfrom.match(line) if (match!=None): email=match.group(1) continue - match=matchuserid.match(line) - if (match!=None): - userid=match.group(1) - continue - match=matchpassword.match(line) - if (match!=None): - password=match.group(1) - continue - match=matchfirstname.match(line) if (match!=None): firstname=match.group(1) @@ -165,63 +109,32 @@ for line in sys.stdin.readlines(): phone=match.group(1) continue -oldrace=validrace(oldrace) -newrace=validrace(newrace) - -okay=0 -if (password!=None) & (userid!=None): - query="select id from users where password='" + password + "' and id="+str(userid) - cursor=db.cursor() - num=cursor.execute(query) - if num==1: - okay=1 - else: - if email==None: - email="enno@eressea.upb.de" - error(email, "Das Passwort für Kundennummer "+str(userid)+" war nicht korrekt.") - +if email==None: + error("enno@eressea.upb.de", + "Es wurde keine Emailadresse angegeben: "+firstname+" "+lastname) +elif (firstname==None): + error(email, "Es wurde kein Vorname angegeben") +elif (lastname==None): + error(email, "Es wurde kein Nachname angegeben") +elif (address==None): + error(email, "Es wurde keine Adresse angegeben") +elif (city==None): + error(email, "Es wurde kein Wohnort angegeben") +elif (country==None): + error(email, "Es wurde kein Land angegeben") else: - if email==None: - error("enno@eressea.upb.de", - "Es wurde keine Emailadresse angegeben: "+firstname+" "+lastname) - elif (oldrace==None) & (newrace==None) & (standin==0) & (waiting==0): - error(email, "Es wurde kein Spiel ausgewählt.") - elif (firstname==None): - error(email, "Es wurde kein Vorname angegeben") - elif (lastname==None): - error(email, "Es wurde kein Nachname angegeben") - elif (address==None): - error(email, "Es wurde keine Adresse angegeben") - elif (city==None): - error(email, "Es wurde kein Wohnort angegeben") - elif (country==None): - error(email, "Es wurde kein Land angegeben") - else: - if (phone==None): - phone = "NULL" - okay=1 - cursor=db.cursor() - cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+ - "VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')") + if (phone==None): + phone = "NULL" + + cursor=db.cursor() + cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+ + "VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')") - cursor.execute("SELECT LAST_INSERT_ID() from dual") - userid=str(int(cursor.fetchone()[0])) + cursor.execute("SELECT LAST_INSERT_ID() from dual") + userid=str(int(cursor.fetchone()[0])) -if okay: - if (oldrace!=None): - error(email, "Derzeit wird kein Spiel nach alten Regeln angeboten") -# cursor.execute("INSERT INTO subscriptions (user, race, game) "+ -# "VALUES ("+str(userid)+", '"+oldrace+"', 1)") - if (newrace!=None): - error(email, "Derzeit wird kein Spiel nach neuen Regeln angeboten") -# cursor.execute("INSERT INTO subscriptions (user, race, game, status) "+ -# "VALUES ("+str(userid)+", '"+newrace+"', 2, 'WAITING')") - if waiting: - cursor.execute("INSERT INTO subscriptions (user, game, status) "+ - "VALUES ("+str(userid)+", 3, 'WAITING')") - if standin: - cursor.execute("INSERT INTO subscriptions (user, game, status) "+ - "VALUES ("+str(userid)+", 4, 'WAITING')") + cursor.execute("INSERT INTO subscriptions (user, game, status) "+ + "VALUES ("+str(userid)+", 3, 'WAITING')") errors.close() unlock(sys.argv[1]+".err") diff --git a/scripts/register/status.sh b/scripts/register/status.sh new file mode 100755 index 000000000..f65990159 --- /dev/null +++ b/scripts/register/status.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +if [ $# -gt 0 ]; then + db="$1" +else + db="vinyambar" +fi +echo "Vinyambar I" +echo +mysql --table $db -e "source subscriptions-1.sql" +echo +echo + +echo "Vinyambar II" +echo +mysql --table $db -e "source subscriptions-2.sql" +echo +echo + +echo "Rassenverteilung" +echo +mysql --table $db -e "source races.sql" +echo +echo + +echo "Ausgemusterte Parteien" +echo +mysql --table $db -e "source noowner.sql" +echo +echo + +echo "Überweisung erforderlich" +echo +mysql --table $db -e "source unpaid.sql" +echo +echo + +echo "Parteienverteilung" +echo +mysql --table $db -e "source summary.sql" +echo +echo diff --git a/scripts/register/summary.sql b/scripts/register/summary.sql new file mode 100644 index 000000000..c8c6cfc58 --- /dev/null +++ b/scripts/register/summary.sql @@ -0,0 +1,6 @@ +select count(users.status) Anzahl, subscriptions.status Status, games.name Spiel + from users, games, subscriptions + where games.id = subscriptions.game + and users.id = subscriptions.user + group by games.name, subscriptions.status + order by subscriptions.game; diff --git a/scripts/register/unpaid.sql b/scripts/register/unpaid.sql index efeb06841..87554d854 100644 --- a/scripts/register/unpaid.sql +++ b/scripts/register/unpaid.sql @@ -4,10 +4,3 @@ select u.id ID, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, su and u.status!='CONFIRMED' GROUP BY u.id HAVING SUM(t.balance)<2.5; - -select count(users.status) Anzahl, subscriptions.status Status, games.name Spiel - from users, games, subscriptions - where games.id = subscriptions.game - and users.id = subscriptions.user - group by games.name, subscriptions.status - order by subscriptions.game; diff --git a/scripts/register/zat.py b/scripts/register/zat.py index d4e5a5400..d47a41c69 100755 --- a/scripts/register/zat.py +++ b/scripts/register/zat.py @@ -9,6 +9,15 @@ price=1.25 db=MySQLdb.connect(db=dbname) cursor=db.cursor() +k = cursor.execute("UPDATE subscriptions SET user=NULL where status='TRANSFERED' and updated<'"+date+"'" +print "Removing "+str(int(k))+" transfered subscriptions." + +k = cursor.execute("UPDATE subscriptions SET user=NULL where status='CANCELLED' and updated<'"+date+"'" +print "Removing "+str(int(k))+" cancelled subscriptions." + +k = cursor.execute("UPDATE subscriptions SET user=NULL where status='DEAD' and updated<'"+date+"'" +print "Removing "+str(int(k))+" dead subscriptions." + k = cursor.execute("SELECT users.id FROM users, subscriptions WHERE users.id=subscriptions.user and subscriptions.status='ACTIVE' and subscriptions.game="+str(game)) while k!=0: k=k-1