def creat_idea(self): behavior = None try: behavior = self.behaviors_instances['Create_an_idea'] values = {'title': self.params('title'), 'text': self.params('text')} idea = Idea() idea.set_data(values) appstruct = {'_object_data': idea, 'keywords': self.params('keywords')} behavior.execute(self.context, self.request, appstruct) oid = get_oid(idea) localizer = self.request.localizer user = get_current() time = to_localized_time(datetime.datetime.today()) new_title = localizer.translate(_('Idea by'))+' '+\ getattr(user, 'title', user.name)+' '+\ localizer.translate(_('the'))+' '+\ time+' (UTC)' data = {'title': idea.title, 'oid': str(oid), 'body': renderers.render(self.idea_template, {'idea':idea}, self.request), 'new_title': new_title } result = data return result except Exception: return {}
def creat_idea(self): behavior = None try: tree = self.params('tree') tree = json.loads(tree) if tree else DEFAULT_TREE behavior = self.behaviors_instances['Create_an_idea'] values = { 'title': self.params('title'), 'text': self.params('text'), 'tree': tree } challenge = self.params('challenge') if challenge: try: challenge = get_obj(int(challenge)) values['challenge'] = challenge except: pass idea = Idea() idea.set_data(values) appstruct = {'_object_data': idea} behavior.execute(self.context, self.request, appstruct) oid = get_oid(idea) new_title = '' #self._get_new_title(user) data = { 'title': idea.title, 'oid': str(oid), 'body': renderers.render(self.idea_template, {'idea': idea}, self.request), 'new_title': new_title } result = data return result except Exception as error: log.warning(error) return {}
def creat_idea(self): behavior = None try: behavior = self.behaviors_instances['Create_an_idea'] values = {'title': self.params('title'), 'text': self.params('text')} keywords = self.params('keywords') if not isinstance(keywords, (list, tuple)): keywords = [keywords] values['keywords'] = keywords challenge = self.params('challenge') if challenge: try: challenge = get_obj(int(challenge)) values['challenge'] = challenge except: pass idea = Idea() idea.set_data(values) appstruct = {'_object_data': idea} behavior.execute(self.context, self.request, appstruct) oid = get_oid(idea) new_title = ''#self._get_new_title(user) data = {'title': idea.title, 'oid': str(oid), 'body': renderers.render(self.idea_template, {'idea': idea}, self.request), 'new_title': new_title } result = data return result except Exception as error: log.warning(error) return {}