Пример #1
0
    def update(self):
        self.execute(None)
        root = getSite()
        try:
            navbars = generate_navbars(
                self.request, self.context)
        except ObjectRemovedException:
            return HTTPFound(self.request.resource_url(root, ''))

        user = self.get_binding('user')
        is_censored = 'censored' in self.context.state
        to_hide = is_censored and not has_any_roles(
            user=user,
            roles=(('Owner', self.context), 'Moderator'))
        evaluation_chart = render_object_evaluation_stat(self.context, self.request)
        examination_chart = render_object_examination_stat(self.context, self.request)
        result = {}
        values = {
            'challenge': self.context,
            'to_hide': to_hide,
            'is_censored': is_censored,
            'text': self.context.text,
            'current_user': user,
            'navbar_body': navbars['navbar_body'],
            'footer_body': navbars['footer_body'],
            'evaluation_chart': evaluation_chart,
            'examination_chart': examination_chart
        }
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        item['isactive'] = True
        result['coordinates'] = {self.coordinates: [item]}
        # result.update(resources)
        return result
Пример #2
0
    def update(self):
        self.execute(None)
        try:
            navbars = generate_navbars(self.request, self.context)
        except ObjectRemovedException:
            return HTTPFound(self.request.resource_url(getSite(), ''))

        organization = self.context
        current_user = get_current()
        evaluation_chart = render_object_evaluation_stat(self.context, self.request)
        examination_chart = render_object_examination_stat(self.context, self.request)
        values = {
            'organization': organization,
            'state': get_states_mapping(
                current_user, organization,
                getattr(organization, 'state_or_none', [None])[0]),
            'navbar_body': navbars['navbar_body'],
            'actions_bodies': navbars['body_actions'],
            'footer_body': navbars['footer_body'],
            'is_portal_manager': has_role(role=('PortalManager',)),
            'evaluation_chart': evaluation_chart,
            'examination_chart': examination_chart,
        }
        result = {}
        result = merge_dicts(navbars['resources'], result, ('css_links', 'js_links'))
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        item['messages'] = navbars['messages']
        item['isactive'] = navbars['isactive']
        result['coordinates'] = {self.coordinates: [item]}
        return result
Пример #3
0
    def update(self):
        self.execute(None)
        try:
            navbars = generate_navbars(self.request, self.context)
        except ObjectRemovedException:
            return HTTPFound(self.request.resource_url(getSite(), ''))

        user = self.context
        current_user = get_current()
        details = {}
        stats = get_object_stat(self.context, self.request)
        stats['nb_other'] = stats.get('nb_other', 0) + len(
            user.evaluated_objs_ids())
        stas_len = sum(stats.values())
        evaluation_chart = render_object_evaluation_stat(
            self.context, self.request)
        examination_chart = render_object_examination_stat(
            self.context, self.request)
        values = {
            'user':
            user,
            'proposals':
            None,
            'state':
            get_states_mapping(current_user, user,
                               getattr(user, 'state_or_none', [None])[0]),
            'navbar_body':
            navbars['navbar_body'],
            'actions_bodies':
            navbars['body_actions'],
            'footer_body':
            navbars['footer_body'],
            'is_portal_manager':
            has_role(role=('PortalManager', )),
            'contributions_len':
            stas_len,
            'details':
            stats,
            'evaluation_chart':
            evaluation_chart,
            'examination_chart':
            examination_chart,
        }
        result = {}
        result = merge_dicts(navbars['resources'], result,
                             ('css_links', 'js_links'))
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        item['messages'] = navbars['messages']
        item['isactive'] = navbars['isactive']
        result['coordinates'] = {self.coordinates: [item]}
        return result
Пример #4
0
    def update(self):
        self.execute(None)
        try:
            navbars = generate_navbars(self.request, self.context)
        except ObjectRemovedException:
            return HTTPFound(self.request.resource_url(getSite(), ''))

        user = self.context
        current_user = get_current()
        details = {}
        stats = get_object_stat(self.context, self.request)
        stats['nb_other'] = stats.get('nb_other', 0) + len(user.evaluated_objs_ids())
        stas_len = sum(stats.values())
        evaluation_chart = render_object_evaluation_stat(self.context, self.request)
        examination_chart = render_object_examination_stat(self.context, self.request)
        values = {
            'user': user,
            'proposals': None,
            'state': get_states_mapping(
                current_user, user,
                getattr(user, 'state_or_none', [None])[0]),
            'navbar_body': navbars['navbar_body'],
            'actions_bodies': navbars['body_actions'],
            'footer_body': navbars['footer_body'],
            'is_portal_manager': has_role(role=('PortalManager',)),
            'contributions_len': stas_len,
            'details': stats,
            'evaluation_chart': evaluation_chart,
            'examination_chart': examination_chart,
        }
        result = {}
        result = merge_dicts(navbars['resources'], result, ('css_links', 'js_links'))
        body = self.content(args=values, template=self.template)['body']
        item = self.adapt_item(body, self.viewid)
        item['messages'] = navbars['messages']
        item['isactive'] = navbars['isactive']
        result['coordinates'] = {self.coordinates: [item]}
        return result