def create_or_update_business(self, alias_name, import_data): business = self.businessDao.query_by_alias(alias_name) if business is not None: business_key = business.key import_data.business_id = business_key logger.info('Business Already Exist with Key %s' % str(business_key)) else: try: business = Business() business.name = import_data.name business.description = import_data.description business.alias = import_data.alias business.contact_info = import_data.contact_info business_key = self.businessDao.persist( business, self.user_info) import_data.business_id = business_key logger.info('New Business Created for %s with key %s' % (alias_name, str(business_key))) except StandardError as e: #Skip the error and continue logger.error('Error occured, %s, for %s' % (str(e), alias_name)) raise return business_key
def form_to_dao_business(self, **update): business = Business() business.name = update['name'] #Create an automatic alias for the business business.alias = utils.slugify(update['name']) business.description = update['description'] business = self.form_to_dao_contact_info_import(business, **update) return business
def create_or_update_business(self, playground): if playground.business_id is not None: business = self.businessDao.get_record(long(playground.business_id.id())) else: business = Business() business.name = playground.name business.description = playground.description business.alias = playground.alias business.contact_info = playground.contact_info return business
def create_or_update_business(self, event): if event.business_id is not None: business = self.businessDao.get_record(long(event.business_id.id())) else: business = Business() business.name = event.name business.description = event.description business.alias = event.alias business.contact_info = event.contact_info return business
def create_or_update_business(self, trainingcentre): if trainingcentre.business_id is not None: business = self.businessDao.get_record(long(trainingcentre.business_id.id())) else: business = Business() business.name = trainingcentre.name business.description = trainingcentre.description business.alias = trainingcentre.alias business.contact_info = trainingcentre.contact_info return business
def form_to_dao(self, business_id): business = None if business_id is not None and len(business_id) > 1: business = self.businessDao.get_record(long(business_id)) logger.debug('business ' + str(business)) else: business = Business() logger.debug('business 2 ' + str(business)) business.name = self.form.name.data #Create an automatic alias for the business business.alias = utils.slugify(self.form.name.data) business.description = self.form.description.data return cms_utils.form_to_dao_contact_info(self.form, business)