def main1(): conn = toolbox.get_connection() arthur = Arthur(conn) data_ao = { "status": "prospective", "move_out_date": "2018-07-17", "rent_amount_weekly": "undefined", "duration": "undefined", "break_clause": "2018-07-17", "tenancy_start": "2018-01-17", "registered_deposit_date": "2018-07-17", "rent_frequency": "weekly", "registered_deposit": "700", "tenancy_end": "2018-07-17", "rent_amount": "350", "Tenancy.tag_cache": "undefined", "status_alias": "undefined", "move_in_date": "2018-07-17", "rent_frequency_id": "5", "holding_deposit_amount": "350", "transactions_deposit_payment": "450", # "Tenancy.recurring_amount":"355", # "contract_type_id": "4", # "ContractType.name":"Assured Shorthold Tenancy" #"renters_all": "Faisal Amri", } arthur.add_tenancy(data_ao, str(53060), "Tenant 4")
def db_display(): #head=request.headers['Authorization'] #if check_authentication(head): conn = toolbox.get_connection() front = front_tb.Front(conn) intel = request.get_json() id_sub = intel["UniqueID"] email = intel["Email"] #hard coded shit I know form = formstack.Formstack(conn) initial_data = form.get_submission(id_sub) dict_initial = dict( map(lambda x: (x['field'], x['value']), initial_data['data'])) link = "https://cocoon.formstack.com/forms/tenant_information?id_sub={0}".format( str(id_sub)) data_email_propective_tenant = { "link": link, "last_name": dict_initial["64515438"], "first_name": dict_initial["64515437"], "address": dict_initial["64515442"], "bond": str(2 * int(dict_initial["64515461"])), "rent": str(int(dict_initial["64515461"])), "incoming_date": dict_initial["64515462"], } try: query = [] house_info = toolbox.select_db( "SELECT * FROM ops.houses WHERE address='" + dict_initial["64515442"] + "'", conn)[0] query.append( "SELECT t.first_name, t.nationality, TIMESTAMPDIFF(year,t.birthdate, now() ) AS age,t.sex,t.occupation,t.phone,t.email" ) query.append( "FROM ops.tenants AS t INNER JOIN ops.tenants_history AS th ON t.id=th.tenant_id" ) query.append("WHERE th.house_id='" + house_info["id"] + "' AND '" + dict_initial["64515462"] + "' BETWEEN incoming_date AND outgoing_date ") roommates = toolbox.select_db(' '.join(query), conn) emails = [] extension = [] for roommate in roommates: emails.append(roommate["email"]) string = "<td>" + roommate["first_name"] + "</td>" string += "<td>" + roommate["nationality"] + "</td>" string += "<td>" + str(roommate["age"]) + "</td>" string += "<td>" + roommate["sex"] + "</td>" string += "<td>" + roommate["occupation"] + "</td>" string += "<td>" + str(roommate["phone"]) + "</td>" string += "<td>" + roommate["email"] + "</td>" extension.append("<tr>" + string + "</tr>") with open("templates/deposit_email.html", "r") as file: template = file.read() template = template.format(**data_email_propective_tenant) template = template.replace("<h3></h3>", ' '.join(extension)) except Exception, e: front.send_email(["*****@*****.**"], "issue", str(e))
def big_daddy(): logging.debug('start') conn = toolbox.get_connection() front = front_tb.Front(conn) try: arthur_tb = arthur.Arthur(conn) form = formstack.Formstack(conn) logging.debug('passed1') except Exception, e: front.send_email(["*****@*****.**"], "issue2", str(e)) logging.debug("a" + str(e))
def check_authentication(Authorization): conn = toolbox.get_connection() data = toolbox.select_db("SELECT access_token FROM ops.webhooks_tokens;", conn) conn.close() list_bearer = list(map(lambda x: "Bearer " + x["access_token"], data)) print(list_bearer) if Authorization in list_bearer: return True else: raise InvalidUsage('Authentication failed', status_code=410)
"https://flatmates.com.au/people/{0}/max-31yrs+min-180+min-8-weeks+newest+share-house", "https://flatmates.com.au/people/{0}/max-31yrs+min-180+min-8-weeks+newest+student-accommodation", ] locations = [ "alexandria-2015", "darling-harbour-2007", "forest-lodge-2037", "glebe-2037", "sydney-2000", "barangaroo-2000", "camperdown-2050", "centennial-park-2021", "chippendale-2008", "darlinghurst-2010", "darlington-2008", "erskineville-2043", "eveleigh-2015", "haymarket-2000", "kingsford-2032", "millers-point-2000", "moore-park-2021", "paddington-2021", "potts-point-2011", "pyrmont-2009", "randwick-2031", "redfern-2016", "rozelle-2039", "rushcutters-bay-2011", "surry-hills-2010", "the-rocks-2000", "ultimo-2007", "waterloo-2017", "woolloomooloo-2011", "zetland-2017" ] paths = list(map(lambda x: x.format('+'.join(locations)), links)) conn = toolbox.get_connection() with requests.Session() as s: #proxies={"http":"http://119.40.106.250:8080","https":"https://139.99.172.152:3128"} #s.proxies.update(proxies) login_in_flatmates(s) i = 0 for path in paths: print("new batch") if i == 0: couple = True else: couple = False profiles = get_last_profiles(s, path) candidates = check_interest_profile(s, profiles, couple=couple) exclusion_list, not_interesting = get_exclusion_list(conn) to_exclude = []
def main3(): conn = toolbox.get_connection() arthur = Arthur(conn) print(json.dumps(arthur.get_tenancy(str(117903))))
def main_update(): conn = toolbox.get_connection() arthur = Arthur(conn) arthur.update_tenancies_status() arthur.update_tenant_information()