def bind(self): bindings = {} bindings['navbars'] = None bindings['vote_actions'] = None vote_actions = get_vote_actions_body(self.context, self.request) try: navbars = generate_navbars(self.request, self.context, text_action=vote_actions['activators']) bindings['navbars'] = navbars bindings['vote_actions'] = vote_actions except ObjectRemovedException: return bindings['user'] = get_current() bindings['root'] = getSite() bindings['is_participant'] = has_role(user=bindings['user'], role=('Participant', self.context)) bindings['is_censored'] = 'censored' in self.context.state bindings['to_hide'] = bindings['is_censored'] and not has_any_roles( user=bindings['user'], roles=(('Participant', self.context), 'Moderator')) bindings['corrections'] = [ c for c in self.context.corrections if 'in process' in c.state ] bindings['enable_corrections'] = self._enable_corrections( bindings['is_participant'], bindings['corrections']) bindings['content_data'] = self._get_adapted_text( bindings['user'], bindings['is_participant'], bindings['corrections'], bindings['enable_corrections']) setattr(self, '_bindings', bindings)
def bind(self): bindings = {} bindings['navbars'] = None bindings['vote_actions'] = None vote_actions = get_vote_actions_body( self.context, self.request) try: navbars = generate_navbars( self.request, self.context, text_action=vote_actions['activators']) bindings['navbars'] = navbars bindings['vote_actions'] = vote_actions except ObjectRemovedException: return bindings['user'] = get_current() bindings['root'] = getSite() bindings['is_participant'] = has_role( user=bindings['user'], role=('Participant', self.context)) bindings['is_censored'] = 'censored' in self.context.state bindings['to_hide'] = bindings['is_censored'] and not has_any_roles( user=bindings['user'], roles=(('Participant', self.context), 'Moderator')) bindings['corrections'] = [c for c in self.context.corrections if 'in process' in c.state] bindings['enable_corrections'] = self._enable_corrections( bindings['is_participant'], bindings['corrections']) bindings['content_data'] = self._get_adapted_text( bindings['user'], bindings['is_participant'], bindings['corrections'], bindings['enable_corrections']) setattr(self, '_bindings', bindings)
def update(self): self.execute(None) vote_actions = get_vote_actions_body(self.context, self.request) try: navbars = generate_navbars(self.request, self.context, text_action=vote_actions['activators']) except ObjectRemovedException: return HTTPFound(self.request.resource_url(getSite(), '')) resources = merge_dicts(navbars['resources'], vote_actions['resources'], ('js_links', 'css_links')) resources['js_links'] = list(set(resources['js_links'])) resources['css_links'] = list(set(resources['css_links'])) messages = vote_actions['messages'] if not messages: messages = navbars['messages'] values = { 'registration': self.context, 'footer_body': navbars['footer_body'], 'navbar_body': navbars['navbar_body'], 'vote_actions_body': vote_actions['body'] } result = {} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['messages'] = messages item['isactive'] = vote_actions['isactive'] or navbars['isactive'] result.update(resources) result['coordinates'] = {self.coordinates: [item]} result = merge_dicts(self.requirements_copy, result) return result
def bind(self): bindings = {} bindings['navbars'] = None bindings['vote_actions'] = None vote_actions = get_vote_actions_body(self.context, self.request) try: navbars = generate_navbars(self.request, self.context, text_action=vote_actions['activators']) bindings['navbars'] = navbars bindings['vote_actions'] = vote_actions except ObjectRemovedException: return bindings['user'] = get_current() bindings['root'] = getSite() bindings['is_censored'] = 'censored' in self.context.state bindings['to_hide'] = bindings['is_censored'] and not has_any_roles( user=bindings['user'], roles=(('Owner', self.context), 'Moderator')) setattr(self, '_bindings', bindings)
def update(self): self.execute(None) vote_actions = get_vote_actions_body(self.context, self.request, ballot_ids=['vote_moderation']) try: navbars = generate_navbars(self.request, self.context, process_id='reportsmanagement', descriminators=['plus-action'], flatten=True, text_action=vote_actions['activators']) except ObjectRemovedException: return HTTPFound(self.request.resource_url(getSite(), '')) resources = merge_dicts(navbars['resources'], vote_actions['resources'], ('js_links', 'css_links')) resources['js_links'] = list(set(resources['js_links'])) resources['css_links'] = list(set(resources['css_links'])) messages = vote_actions['messages'] if not messages: messages = navbars['messages'] result = {} values = { 'navbar_body': navbars['navbar_body'], 'object': self.context, 'vote_actions_body': vote_actions['body'] } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['messages'] = messages item['isactive'] = vote_actions['isactive'] or navbars['isactive'] result.update(resources) result['coordinates'] = {self.coordinates: [item]} return result
def update(self): self.execute(None) vote_actions = get_vote_actions_body(self.context, self.request) try: navbars = generate_navbars(self.request, self.context, text_action=vote_actions['activators']) except ObjectRemovedException: return HTTPFound(self.request.resource_url(getSite(), '')) resources = merge_dicts(navbars['resources'], vote_actions['resources'], ('js_links', 'css_links')) resources['js_links'] = list(set(resources['js_links'])) resources['css_links'] = list(set(resources['css_links'])) messages = vote_actions['messages'] if not messages: messages = navbars['messages'] user = get_current() is_censored = 'censored' in self.context.state dace_catalog = find_catalog('dace') container_oid = dace_catalog['containers_oids'] answers = find_entities(interfaces=[IAnswer], user=user, add_query=container_oid.any( [get_oid(self.context)])) len_answers = len(answers.ids) index = str(len_answers) if len_answers > 1: index = '*' answers_title = _(CONTENTS_MESSAGES[index], mapping={'number': len_answers}) answer_body = None if self.context.answer: answer_body = render_listing_obj(self.request, self.context.answer, user) result = {} values = { 'object': self.context, 'state': get_states_mapping(user, self.context, self.context.state[0]), 'current_user': user, 'answers_title': answers_title, 'navbar_body': navbars['navbar_body'], 'actions_bodies': navbars['body_actions'], 'footer_body': navbars['footer_body'], 'support_actions_body': navbars['support_actions_body'], 'vote_actions_body': vote_actions['body'], 'answer_body': answer_body, 'is_censored': is_censored, 'to_hide': is_censored and not has_any_roles(user=user, roles=(('Owner', self.context), 'Moderator')) } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['messages'] = messages item['isactive'] = vote_actions['isactive'] or navbars['isactive'] result.update(resources) result['coordinates'] = {self.coordinates: [item]} return result