| 4 |
import re |
import re |
| 5 |
import sys |
import sys |
| 6 |
import urllib |
import urllib |
| 7 |
|
import dc_objs |
| 8 |
from BeautifulSoup import BeautifulSoup |
from BeautifulSoup import BeautifulSoup |
| 9 |
|
|
| 10 |
FRONTACCOUNTING_URL = "https://debconf10.kaplowitz.org/account" |
FRONTACCOUNTING_URL = "https://debconf10.kaplowitz.org/account" |
| 13 |
APP_USERNAME = "XXXXXX" |
APP_USERNAME = "XXXXXX" |
| 14 |
APP_PASSWORD = "XXXXXX" |
APP_PASSWORD = "XXXXXX" |
| 15 |
|
|
| 16 |
|
CAT_MAPPINGS = { } |
| 17 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_B, 'Pays Own Bed & Food')) |
| 18 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_BA, 'Sponsored Bed Only')) |
| 19 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_BF, 'Sponsored Food Only')) |
| 20 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_BAF, 'Sponsored Bed & Food')) |
| 21 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_PRO, 'Professional')) |
| 22 |
|
CAT_MAPPINGS.update(dict.fromkeys(dc_objs.CAT_COR, 'Corporate')) |
| 23 |
|
|
| 24 |
def clean_html(br): |
def clean_html(br): |
| 25 |
data = br.response().get_data() |
data = br.response().get_data() |
| 26 |
soup = BeautifulSoup(data) |
soup = BeautifulSoup(data) |
| 60 |
br["password"] = APP_PASSWORD |
br["password"] = APP_PASSWORD |
| 61 |
br.submit() |
br.submit() |
| 62 |
|
|
| 63 |
#####br.follow_link(text="Add and Manage Customers") |
People = dc_objs.get_people(where="dcvn.attend and dcvn.reconfirmed") |
|
##### |
|
|
#####br.select_form(nr=0) |
|
|
#####br["CustName"] = br["cust_ref"] = "Test Monkey" #XXX NAME |
|
|
######br["address"] = """ |
|
|
######123 So-and-so Street |
|
|
######Whoo-boy, DC 10000 |
|
|
######""" #XXX ADDRESS |
|
|
#####br["email"] = "jimmy@kaplowitz.org" #XXX EMAIL |
|
|
#####br["notes"] = "person_id: XXX" #XXX person_id |
|
|
#####br.set_value_by_label(["Sponsored Bed & Food"], name="sales_type") #XXX PARTICIPANT CATEGORY |
|
|
#####br.set_value_by_label(["Net 30"], name="payment_terms") |
|
|
#####br.set_value_by_label(["Conference Registration"], name="dimension_id") |
|
|
###### Log information about HTTP redirects and Refreshes. |
|
|
######br.set_debug_redirects(True) |
|
|
###### Log HTTP response bodies (ie. the HTML, most of the time). |
|
|
######br.set_debug_responses(True) |
|
|
###### Print HTTP headers. |
|
|
######br.set_debug_http(True) |
|
|
##### |
|
|
###### To make sure you're seeing all debug output: |
|
|
######logger = logging.getLogger("mechanize") |
|
|
######logger.addHandler(logging.StreamHandler(sys.stdout)) |
|
|
######logger.setLevel(logging.INFO) |
|
|
##### |
|
|
#####ajax_submit(br) |
|
|
|
|
|
#####br.open(FRONTACCOUNTING_URL) |
|
|
#####br.follow_link(text="Customer Branches") |
|
|
#####clean_html(br) |
|
|
#####br.select_form(nr=0) |
|
|
#####ajax_select(br, ["Test Monkey"], name="customer_id") #XXX NAME |
|
|
#####ajax_submit(br, name="ADD_ITEM") |
|
|
|
|
|
br.open(FRONTACCOUNTING_URL) |
|
|
br.follow_link(text="Direct Invoice") |
|
|
clean_html(br) |
|
|
br.select_form(nr=0) |
|
|
ajax_select(br, ["Test Monkey"], name="customer_id") #XXX NAME |
|
|
#ajax_select(br, ["Residence Hall Bed"], name="stock_id") #XXX line_item |
|
|
#br["qty"] = 6 #XXX line_item |
|
|
|
|
| 64 |
|
|
| 65 |
print br.response().read() |
for P in people: |
| 66 |
|
br.open(FRONTACCOUNTING_URL) |
| 67 |
|
br.follow_link(text="Add and Manage Customers") |
| 68 |
|
|
| 69 |
|
br.select_form(nr=0) |
| 70 |
|
br["CustName"] = br["cust_ref"] = P.name |
| 71 |
|
br["email"] = P.email |
| 72 |
|
br["notes"] = "person_id: %d" % P.person_id |
| 73 |
|
br.set_value_by_label([CAT_MAPPINGS[P.participant_category]], name="sales_type") |
| 74 |
|
br.set_value_by_label(["Net 30"], name="payment_terms") |
| 75 |
|
br.set_value_by_label(["Conference Registration"], name="dimension_id") |
| 76 |
|
|
| 77 |
|
ajax_submit(br) |
| 78 |
|
|
| 79 |
|
br.open(FRONTACCOUNTING_URL) |
| 80 |
|
br.follow_link(text="Customer Branches") |
| 81 |
|
clean_html(br) |
| 82 |
|
br.select_form(nr=0) |
| 83 |
|
ajax_select(br, [P.name], name="customer_id") #XXX NAME |
| 84 |
|
ajax_submit(br, name="ADD_ITEM") |
| 85 |
|
|
| 86 |
|
# This part isn't working |
| 87 |
|
#br.open(FRONTACCOUNTING_URL) |
| 88 |
|
#br.follow_link(text="Direct Invoice") |
| 89 |
|
#clean_html(br) |
| 90 |
|
#br.select_form(nr=0) |
| 91 |
|
#ajax_select(br, ["Test Monkey"], name="customer_id") #XXX NAME |
| 92 |
|
##ajax_select(br, ["Residence Hall Bed"], name="stock_id") #XXX line_item |
| 93 |
|
##br["qty"] = 6 #XXX line_item |