Exemplo n.º 1
0
    def post(self):
        tdc = TestDataCreationHandler()
        tdc.create_member(self['owner_email'], self['owner_name'], self['owner_phone'], 'owner')
        tdc.create_member(self['manager_email'], self['manager_name'], self['manager_phone'], 'manager')

        store_obj = Store()
        store_obj.name = self['store_name']
        store_obj.owner = self['owner_email']
        store_obj.manager = self['manager_email']
        store_obj.location = db.GeoPt(self['store_lat'],self['store_long'])
        store_obj.address = " ".join(self['store_address'].split("\n"))
        store_obj.billing_address = " ".join(self['store_billing_address'].split("\n"))
        store_obj.put()

        appliances_csv = self['appliances_csv']
        appliances = appliances_csv.splitlines()
        appliance_index = [index.strip("\"") for index in str(appliances[0]).split(',')]
        for appliance in appliances[1:]:
            appliance = [detail.strip("\"") for detail in str(appliance).split(',')]
            appliance_obj = Appliance()
            appliance_obj.name = appliance[appliance_index.index("Name of Appliance")]
            appliance_obj.serial_num = appliance[appliance_index.index("Serial #")]
            appliance_obj.model = appliance[appliance_index.index("Model #")]
            appliance_obj.manufacturer = appliance[appliance_index.index("Manufacturer Name")]
            appliance_obj.last_repair_date = self.get_appliance_form_date("Last Repair Date (if you know it)", appliance, appliance_index)
            appliance_obj.installed_on = self.get_appliance_form_date("Installed on (if known)", appliance, appliance_index)
            appliance_obj.warranty = self.get_appliance_form_date("Is it in warranty (if known)", appliance, appliance_index)
            appliance_obj.store = store_obj
            appliance_obj.put()
Exemplo n.º 2
0
 def post(self):
     loc = self['location'].split(',')
     store = Store()
     store.name = self['name']
     store.location = db.GeoPt(loc[0], loc[1])
     store.manager = self['manager']
     store.owner = self['owner']
     store.put()
Exemplo n.º 3
0
def store_mapper(member, role_name):
    fields = member['fields']
    store_obj = Store.all().filter('airtable_id =', fields['Store ID']).get()
    if not store_obj:
        store_obj = Store()
    store_obj.name = fields['Store Name']
    store_obj.location = db.GeoPt(fields['Latitude'],fields['Longitude'])
    store_obj.address = fields['Store Address']
    store_obj.billing_address = fields['Billing Address']
    store_obj.owner = obj_map[fields['Store Owner'][0]].key().name()
    store_obj.manager = obj_map[fields['Store Manager'][0]].key().name()
    store_obj.airtable_id = fields['Store ID']
    store_obj.put()
    obj_map[member['id']] = store_obj