Revision 265 trunk/swipe/tooltron.py
| tooltron.py (revision 265) | ||
|---|---|---|
| 41 | 41 |
import sys |
| 42 | 42 |
import MySQLdb |
| 43 | 43 |
import getpass |
| 44 |
import datetime |
|
| 45 |
from datetime import date |
|
| 44 | 46 |
from time import * |
| 45 | 47 |
sys.path.append('../common')
|
| 46 | 48 |
import common |
| ... | ... | |
| 386 | 388 |
|
| 387 | 389 |
print user |
| 388 | 390 |
|
| 391 |
|
|
| 392 |
# check if member has paid recently |
|
| 393 |
|
|
| 394 |
# first, figure out what semester it is |
|
| 395 |
today = date.today() |
|
| 396 |
|
|
| 397 |
# semester start dates |
|
| 398 |
aug20 = datetime.date(today.year, 8, 20) # Fall semester |
|
| 399 |
may21 = datetime.date(today.year, 5, 21) # summer |
|
| 400 |
jan1 = datetime.date(today.year, 1, 1) # Spring semester |
|
| 401 |
# if they don't fall after those two, its fall |
|
| 402 |
|
|
| 403 |
if today > aug20: |
|
| 404 |
print "its fall semester!" |
|
| 405 |
#its fall, so they must have paid after may21 (either full year of half) to be paid |
|
| 406 |
qry3 = "SELECT civicrm_value_roboclub_info_2.date_paid_10 >= STR_TO_DATE('" + may21.strftime('%m/%d/%Y') + "', '%m/%d/%Y') , \
|
|
| 407 |
DATE_FORMAT(civicrm_value_roboclub_info_2.date_paid_10, '%M %d %Y') \ |
|
| 408 |
FROM civicrm_value_roboclub_info_2 \ |
|
| 409 |
WHERE civicrm_value_roboclub_info_2.card_number_1 = " + id.group(1) + ";" |
|
| 410 |
|
|
| 411 |
elif today > may21: |
|
| 412 |
print "its summer!" |
|
| 413 |
#its summer, so they need to have paid either full year since aug20 or one semester since jan 1 |
|
| 414 |
qry3 = "SELECT (civicrm_value_roboclub_info_2.date_paid_10 >= STR_TO_DATE('" + aug20.strftime('%m/%d/%Y') + "', '%m/%d/%Y') AND \
|
|
| 415 |
civicrm_value_roboclub_info_2.amount_paid_11 = 25) OR \ |
|
| 416 |
(civicrm_value_roboclub_info_2.date_paid_10 >= STR_TO_DATE('" + jan1.strftime('%m/%d/%Y') + "', '%m/%d/%Y') AND \
|
|
| 417 |
civicrm_value_roboclub_info_2.amount_paid_11 = 15) , \ |
|
| 418 |
DATE_FORMAT(civicrm_value_roboclub_info_2.date_paid_10, '%M %d %Y') \ |
|
| 419 |
FROM civicrm_value_roboclub_info_2 \ |
|
| 420 |
WHERE civicrm_value_roboclub_info_2.card_number_1 = " + id.group(1) + ";" |
|
| 421 |
|
|
| 422 |
|
|
| 423 |
cursor.execute(qry3) |
|
| 424 |
result = cursor.fetchall() |
|
| 425 |
print result |
|
| 426 |
else: |
|
| 427 |
print "its spring!" |
|
| 428 |
#its spring, so they must have either paid full after aug20 or one semester since jan 1 (this is the same as summer) |
|
| 429 |
qry3 = "SELECT (civicrm_value_roboclub_info_2.date_paid_10 >= STR_TO_DATE('" + aug20.strftime('%m/%d/%Y') + "', '%m/%d/%Y') AND \
|
|
| 430 |
civicrm_value_roboclub_info_2.amount_paid_11 = 25) OR \ |
|
| 431 |
(civicrm_value_roboclub_info_2.date_paid_10 >= STR_TO_DATE('" + jan1.strftime('%m/%d/%Y') + "', '%m/%d/%Y') AND \
|
|
| 432 |
civicrm_value_roboclub_info_2.amount_paid_11 = 15) , \ |
|
| 433 |
DATE_FORMAT(civicrm_value_roboclub_info_2.date_paid_10, '%M %d %Y') \ |
|
| 434 |
FROM civicrm_value_roboclub_info_2 \ |
|
| 435 |
WHERE civicrm_value_roboclub_info_2.card_number_1 = 810797813" |
|
| 436 |
#" + id.group(1) + ";" |
|
| 437 |
|
|
| 438 |
|
|
| 439 |
cursor.execute(qry3) |
|
| 440 |
result = cursor.fetchall() |
|
| 441 |
|
|
| 442 |
if len(result) == 0 or result[0][0] == 0 or result[0][0] == "NULL": |
|
| 443 |
print "DENIED: user has not paid recently enough!" |
|
| 444 |
if len(result[0]) >= 2: |
|
| 445 |
print "date_paid: ",result[0][1] |
|
| 446 |
logMessage(user + " has not paid since " + result[0][1] + ", revoking access!") |
|
| 447 |
else: |
|
| 448 |
logMessage(user + " has not paid, revoking access!") |
|
| 449 |
acl = [] |
|
| 450 |
|
|
| 451 |
|
|
| 389 | 452 |
# while we don't have a valid response |
| 390 | 453 |
# Note that this might already be set above when we were heoping for an ACK |
| 391 | 454 |
while resp==None: |
Also available in: Unified diff