def update_stores(model, session, form_dict, files):
     """更新stores"""
     is_true = True
     try:
         group_name = GetName._get_group(form_dict)
         form_dict["group"] = group_name
         brand_name = GetName._get_brand(form_dict)
         form_dict["brand"] = brand_name
         model.update(**form_dict)
         session.commit()
         pictures = files.getlist("pictures")
         is_true = StoresService.update_stores_pictures(session, model, pictures)
     except Exception, ex:
         flash(gettext("Failed to update model. %(error)s", error=str(ex)), "error")
         session.rollback()
         is_true = False
Ejemplo n.º 2
0
 def get_dictionary(self, form_dict, args, special_args=None):
     '''获取所有实体的属性key和value'''
     dictionary = {}
     for arg in args:
         dictionary[str(arg)] = form_dict[str(arg)]
     if special_args != None:
         for arg in special_args:
             if arg == 'group':
                 dictionary[str(arg)] = GetName._get_group(form_dict)
             if arg == 'brand':
                 dictionary[str(arg)] = GetName._get_brand(form_dict)
             if arg == 'stores':
                 dictionary[str(arg)] = GetName._get_stores(form_dict)
             if arg == 'dish_sort':
                 dictionary[str(arg)] = GetName._get_dish_sort(form_dict)
             if arg == 'dish_sort_id':
                 dictionary[str(arg)] = GetName._get_dish_sort_id(form_dict)
     return dictionary
Ejemplo n.º 3
0
 def get_dictionary(self, form_dict, args, special_args=None):
     '''获取所有实体的属性key和value'''
     dictionary = {}
     for arg in args:
         dictionary[str(arg)] = form_dict[str(arg)]
     if special_args != None:
         for arg in special_args:
             if arg == 'group':
                 dictionary[str(arg)] = GetName._get_group(form_dict)
             if arg == 'brand':
                 dictionary[str(arg)] = GetName._get_brand(form_dict)
             if arg == 'stores':
                 dictionary[str(arg)] = GetName._get_stores(form_dict)
             if arg == 'dish_sort':
                 dictionary[str(arg)] = GetName._get_dish_sort(form_dict)
             if arg == 'dish_sort_id':
                 dictionary[str(arg)] = GetName._get_dish_sort_id(form_dict)
     return dictionary
Ejemplo n.º 4
0
 def update_stores(model, session, form_dict, files):
     '''更新stores'''
     is_true = True
     try:
         group_name = GetName._get_group(form_dict)
         form_dict['group'] = group_name
         brand_name = GetName._get_brand(form_dict)
         form_dict['brand'] = brand_name
         model.update(**form_dict)
         session.commit()
         pictures = files.getlist('pictures')
         is_true = StoresService.update_stores_pictures(
             session, model, pictures)
     except Exception, ex:
         flash(gettext('Failed to update model. %(error)s', error=str(ex)),
               'error')
         session.rollback()
         is_true = False
Ejemplo n.º 5
0
 def get_stores(form_dict):
     group_name = GetName._get_group(form_dict)
     brand_name = GetName._get_brand(form_dict)
     stores = Stores(name=form_dict['name'],
                     address=form_dict['address'],
                     description=form_dict['description'],
                     longitude=form_dict['longitude'],
                     latitude=form_dict['latitude'],
                     brand_id=form_dict['brand_id'],
                     brand=brand_name,
                     manager=form_dict['manager'],
                     tel=form_dict['tel'],
                     group_id=form_dict['group_id'],
                     group=group_name,
                     province_id=form_dict['province_id'],
                     city_id=form_dict['city_id'],
                     country_id=form_dict['country_id'],
                     stars=form_dict['stars'])
     return stores
 def get_stores(form_dict):
     group_name = GetName._get_group(form_dict)
     brand_name = GetName._get_brand(form_dict)
     stores = Stores(
         name=form_dict["name"],
         address=form_dict["address"],
         description=form_dict["description"],
         longitude=form_dict["longitude"],
         latitude=form_dict["latitude"],
         brand_id=form_dict["brand_id"],
         brand=brand_name,
         manager=form_dict["manager"],
         tel=form_dict["tel"],
         group_id=form_dict["group_id"],
         group=group_name,
         province_id=form_dict["province_id"],
         city_id=form_dict["city_id"],
         country_id=form_dict["country_id"],
         stars=form_dict["stars"],
     )
     return stores