示例#1
0
文件: shop.py 项目: hforge/shop
 def _make_resource(cls, folder, name, *args, **kw):
     root = ShopFolder._make_resource(cls, folder, name, **kw)
     # Payments module
     cls.payments_class._make_resource(cls.payments_class, folder,
                             '%s/payments' % name,
                             title={'en': u'Payment module'})
     # Modules
     Modules._make_resource(Modules, folder,
                   '%s/modules' % name, title={'en': u'Modules'})
     # Suppliers
     Suppliers._make_resource(Suppliers, folder,
                   '%s/suppliers' % name, title={'en': u'Suppliers'})
     # Customers
     Customers._make_resource(Customers, folder,
                   '%s/customers' % name, title={'en': u'Customers'})
     # Product Models
     ProductModels._make_resource(ProductModels, folder, '%s/products-models' % name,
                                 title={'en': u'Product Models'})
     # Orders
     Orders._make_resource(Orders, folder, '%s/orders' % name,
                           title={'en': u'Orders'})
     # ShopUser_Groups
     ShopUser_Groups._make_resource(ShopUser_Groups, folder, '%s/groups' % name,
                                     title={'en': u'User groups'})
     # Addresses
     Addresses._make_resource(Addresses, folder, '%s/addresses' % name,
                              title={'en': u'Addresses'})
     # Countries
     Countries._make_resource(Countries, folder, '%s/countries' % name,
                              title={'en': u'countries'})
     # Countries zone
     CountriesZones._make_resource(CountriesZones, folder,
             '%s/countries-zones' % name, title={'en': u'Countries Zones'})
     # EnumeratesFolder
     EnumeratesFolder._make_resource(EnumeratesFolder, folder,
                                 '%s/enumerates' % name, title={'en': u'Enumerates'})
     # Shipping
     Shippings._make_resource(Shippings, folder, '%s/shippings' % name,
                              title={'en': u'Shipping'})
     # Conditions of users
     WebPage._make_resource(WebPage, folder, '%s/terms-and-conditions-of-use' % name,
                             **{'title': {'fr': u'Conditions Générales de ventes',
                                          'en': u'Terms and conditions of user'},
                                'state': 'public'})
     # Default cross Selling configuration
     CrossSellingTable._make_resource(CrossSellingTable, folder,
                                      '%s/cross-selling' % name,
                                      title={'en': u'Cross selling'})
     # Taxes
     Taxes_TableResource._make_resource(Taxes_TableResource, folder, '%s/taxes' % name,
                             **{'title': {'fr': u'TVA',
                                          'en': u'Taxes'}})
     table = Taxes_TableHandler()
     table.add_record({'value': '19.6'})
     folder.set_handler('%s/taxes' % name, table)
示例#2
0
key_errors = 0

for email in emails:
    try:
        kw = {
            Emails.key_by_label[label]: value
            for label, value in email.items()
        }
        dt = parser.parse(kw.pop('sent_datetime'))
        emails_row = Emails(sent_datetime=dt, **kw)
        for address_type, column_name in Addresses.key_by_address_type.items():
            addresses = kw.get(column_name)
            if addresses:
                for address in addresses.split(','):
                    addresses_row = Addresses(sent_datetime=dt,
                                              sender=emails_row.message_from,
                                              send_type=address_type,
                                              sent_to=address.strip())
                    emails_row.addresses.append(addresses_row)
        session.add(emails_row)
        session.commit()
    except KeyError as k:
        print('KeyError in message {}: {}'.format(email, k))
        key_errors += 1
    except ValueError as v:
        print('ValueError in message {}: {}'.format(email, v))
    except SQLAlchemyError as e:
        print(e)
    finally:
        session.close()

print('Count of KeyErrors: {}'.format(key_errors))
示例#3
0
 def _make_resource(cls, folder, name, *args, **kw):
     root = ShopFolder._make_resource(cls, folder, name, **kw)
     # Payments module
     cls.payments_class._make_resource(cls.payments_class,
                                       folder,
                                       '%s/payments' % name,
                                       title={'en': u'Payment module'})
     # Modules
     Modules._make_resource(Modules,
                            folder,
                            '%s/modules' % name,
                            title={'en': u'Modules'})
     # Suppliers
     Suppliers._make_resource(Suppliers,
                              folder,
                              '%s/suppliers' % name,
                              title={'en': u'Suppliers'})
     # Customers
     Customers._make_resource(Customers,
                              folder,
                              '%s/customers' % name,
                              title={'en': u'Customers'})
     # Product Models
     ProductModels._make_resource(ProductModels,
                                  folder,
                                  '%s/products-models' % name,
                                  title={'en': u'Product Models'})
     # Orders
     Orders._make_resource(Orders,
                           folder,
                           '%s/orders' % name,
                           title={'en': u'Orders'})
     # ShopUser_Groups
     ShopUser_Groups._make_resource(ShopUser_Groups,
                                    folder,
                                    '%s/groups' % name,
                                    title={'en': u'User groups'})
     # Addresses
     Addresses._make_resource(Addresses,
                              folder,
                              '%s/addresses' % name,
                              title={'en': u'Addresses'})
     # Countries
     Countries._make_resource(Countries,
                              folder,
                              '%s/countries' % name,
                              title={'en': u'countries'})
     # Countries zone
     CountriesZones._make_resource(CountriesZones,
                                   folder,
                                   '%s/countries-zones' % name,
                                   title={'en': u'Countries Zones'})
     # EnumeratesFolder
     EnumeratesFolder._make_resource(EnumeratesFolder,
                                     folder,
                                     '%s/enumerates' % name,
                                     title={'en': u'Enumerates'})
     # Shipping
     Shippings._make_resource(Shippings,
                              folder,
                              '%s/shippings' % name,
                              title={'en': u'Shipping'})
     # Conditions of users
     WebPage._make_resource(
         WebPage, folder, '%s/terms-and-conditions-of-use' % name, **{
             'title': {
                 'fr': u'Conditions Générales de ventes',
                 'en': u'Terms and conditions of user'
             },
             'state': 'public'
         })
     # Default cross Selling configuration
     CrossSellingTable._make_resource(CrossSellingTable,
                                      folder,
                                      '%s/cross-selling' % name,
                                      title={'en': u'Cross selling'})
     # Taxes
     Taxes_TableResource._make_resource(
         Taxes_TableResource, folder, '%s/taxes' % name,
         **{'title': {
             'fr': u'TVA',
             'en': u'Taxes'
         }})
     table = Taxes_TableHandler()
     table.add_record({'value': '19.6'})
     folder.set_handler('%s/taxes' % name, table)
示例#4
0
def new_addr():
	resp = helpers.get_response(request) 
	loginmanager.verify_token(resp)
	addresse = Addresses().new(resp)
	addresse.save()
	return jsonify({'status':'New addresse ok', 'addresse':addresse._to_json()}), 200