Пример #1
0
    def __call__(self):
        site = get_site_folder(True, self.request)
        if not getattr(site, 'activate_improve', False):
            return {'improve': None}

        resources = deepcopy(
            getattr(self.request, 'resources', {
                'js_links': [],
                'css_links': []
            }))
        result = {'css_links': [], 'js_links': []}
        root = self.request.root
        actions = getBusinessAction(context=root,
                                    request=self.request,
                                    process_id='lacviewmanager',
                                    node_id='improve')
        result['improve'] = None

        if actions:
            actions_result = update_actions(root, self.request, actions)
            #actions_result = (action_updated, action_alert_messages,
            #                  action_resources, action_informations)
            if actions_result[3]:
                result['improve'] = actions_result[3][0]
                result['css_links'] = [
                    c for c in actions_result[2].get('css_links', [])
                    if c not in resources['css_links']
                ]
                result['js_links'] = [
                    c for c in actions_result[2].get('js_links', [])
                    if c not in resources['js_links']
                ]

        update_resources(self.request, result)
        return result
Пример #2
0
    def __call__(self):
        root = getSite()
        options = {}
        options['locations'] = {}
        options['show_all'] = True
        resources = deepcopy(getattr(
            self.request, 'resources', {'js_links': [], 'css_links': []}))
        search_view_instance = GeoSearchForm(self.context, self.request)
        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_body = search_view_result['coordinates'][search_view_instance.coordinates][0]['body']
            result['css_links'] = [c for c in search_view_result['css_links']
                                   if c not in resources['css_links']]
            result['js_links'] = [c for c in search_view_result['js_links']
                                  if c not in resources['js_links']]

        result['search_body'] = search_body
        result['options'] = json.dumps(options)
        result['url'] = self.request.resource_url(
            root, '@@creationculturelapi',
            query={'op': 'find_geo_cultural_event'})

        update_resources(self.request, result)
        return result
Пример #3
0
    def __call__(self):
        site = get_site_folder(True, self.request)
        if not getattr(site, 'activate_improve', False):
            return {'improve': None}

        resources = deepcopy(getattr(
            self.request, 'resources', {'js_links': [], 'css_links': []}))
        result = {'css_links': [], 'js_links': []}
        root = self.request.root
        actions = getBusinessAction(
            context=root, request=self.request,
            process_id='lacviewmanager', node_id='improve')
        result['improve'] = None

        if actions:
            actions_result = update_actions(root, self.request, actions)
            #actions_result = (action_updated, action_alert_messages,
            #                  action_resources, action_informations)
            if actions_result[3]:
                result['improve'] = actions_result[3][0]
                result['css_links'] = [c for c in actions_result[2].get('css_links', [])
                                       if c not in resources['css_links']]
                result['js_links'] = [c for c in actions_result[2].get('js_links', [])
                                      if c not in resources['js_links']]

        update_resources(self.request, result)
        return result
Пример #4
0
    def __call__(self):
        is_homepage = self.request.view_name in ('index', '')
        if not is_homepage or 'challenge' not in self.request.content_to_manage:
            return {'condition': False}

        challenges_view = SeeChallengesHomeView(self.context, self.request)
        try:
            challenges_view_result = challenges_view()
            if getattr(challenges_view, 'no_challenges', False):
                return {'condition': False}

        except Exception as error:
            log.warning(error)
            return {'condition': False}

        challenges = ''
        result = {'condition': True, 'css_links': [], 'js_links': []}
        if isinstance(challenges_view_result, dict) and \
           'coordinates' in challenges_view_result:
            search_render = challenges_view_result['coordinates'][challenges_view.coordinates][0]
            result['css_links'] = [c for c in challenges_view_result['css_links']
                                   if c not in resources['css_links']]
            result['js_links'] = [c for c in challenges_view_result['js_links']
                                  if c not in resources['js_links']]
            challenges = challenges_view.render_item(
                search_render,
                challenges_view.coordinates,
                None)

        result['challenges'] = challenges
        result['view'] = self
        update_resources(self.request, result)
        return result
Пример #5
0
    def __call__(self, has_admin_nav=False):
        result = {
            'condition': False
        }
        if self.request.user:
            channels_view = SeeChannels(self.context, self.request)
            try:
                channels_view_result = channels_view()
            except Exception as error:
                log.warning(error)
                return {'condition': False}

            channels = ''
            result = {
                'condition': True, 'css_links': [],
                'js_links': [], 'has_admin_nav':has_admin_nav}
            if isinstance(channels_view_result, dict) and \
               'coordinates' in channels_view_result:
                search_render = channels_view_result['coordinates'][channels_view.coordinates][0]
                result['css_links'] = [c for c in channels_view_result['css_links']
                                       if c not in resources['css_links']]
                result['js_links'] = [c for c in channels_view_result['js_links']
                                      if c not in resources['js_links']]
                channels = channels_view.render_item(
                    search_render,
                    channels_view.coordinates,
                    None)

            result['channels'] = channels
            update_resources(self.request, result)

        return result
Пример #6
0
    def __call__(self):
        user = get_current(self.request)
        resources = deepcopy(
            getattr(self.request, 'resources', {
                'js_links': [],
                'css_links': []
            }))
        search_view_instance = SearchView(self.context, self.request)
        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_body = search_view_result['coordinates'][
                search_view_instance.coordinates][0]['body']
            result['css_links'] = [
                c for c in search_view_result['css_links']
                if c not in resources['css_links']
            ]
            result['js_links'] = [
                c for c in search_view_result['js_links']
                if c not in resources['js_links']
            ]

        result['search_body'] = search_body
        result['view'] = self
        result['alerts'] = []
        if hasattr(user, 'get_alerts'):
            site = get_site_folder(True, self.request)
            result['alerts'] = user.get_alerts(site=site)

        result['login_action'] = None
        if self.request.user is None:
            root = self.request.root
            actions = getBusinessAction(context=root,
                                        request=self.request,
                                        process_id='usermanagement',
                                        node_id='login')
            if actions:
                actions_result = update_actions(root, self.request, actions)
                #actions_result = (action_updated, action_alert_messages,
                #                  action_resources, action_informations)
                if actions_result[3]:
                    result['login_action'] = actions_result[3][0]

        update_resources(self.request, result)
        return result
Пример #7
0
    def __call__(self):
        site = get_site_folder(True, self.request)
        if self.request.view_name in ('@@resetpassword', '@@registration',
                                      'login', '@@login') or \
           not getattr(site, 'activate_questionnaire', False):
            return {'questionnaire': None}

        user = get_current()
        email = getattr(user, 'email', '')
        if email:
            db = arango_server.db("lac")
            collection = create_collection(db, CURRENT_QUEST)
            doc = collection.get_first_example({"email": email})
            if doc:
                return {'questionnaire': None}

        resources = deepcopy(
            getattr(self.request, 'resources', {
                'js_links': [],
                'css_links': []
            }))
        result = {'css_links': [], 'js_links': []}
        root = self.request.root
        actions = getBusinessAction(context=root,
                                    request=self.request,
                                    process_id='lacviewmanager',
                                    node_id='questionnaire')
        result['questionnaire'] = None
        result['current_questionnaire'] = CURRENT_QUEST
        if actions:
            actions_result = update_actions(root, self.request, actions)
            #actions_result = (action_updated, action_alert_messages,
            #                  action_resources, action_informations)
            if actions_result[3]:
                result['questionnaire'] = actions_result[3][0]
                result['css_links'] = [
                    c for c in actions_result[2].get('css_links', [])
                    if c not in resources['css_links']
                ]
                result['js_links'] = [
                    c for c in actions_result[2].get('js_links', [])
                    if c not in resources['js_links']
                ]

        update_resources(self.request, result)
        return result
Пример #8
0
    def __call__(self):
        root = getSite()
        resources = deepcopy(
            getattr(self.request, 'resources', {
                'js_links': [],
                'css_links': []
            }))
        search_action, search_view = get_action_view('novaideoviewmanager',
                                                     'search', self.request)
        search_view_instance = search_view(root,
                                           self.request,
                                           behaviors=[search_action])
        posted_formid = None
        if self.request.POST:
            if '__formid__' in self.request.POST:
                posted_formid = self.request.POST['__formid__']

            if posted_formid and \
              posted_formid.startswith(search_view_instance.viewid):
                search_view_instance.postedform = self.request.POST.copy()
                self.request.POST.clear()

        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_render = search_view_result['coordinates'][
                search_view_instance.coordinates][0]
            result['css_links'] = [
                c for c in search_view_result['css_links']
                if c not in resources['css_links']
            ]
            result['js_links'] = [
                c for c in search_view_result['js_links']
                if c not in resources['js_links']
            ]
            search_body = search_view_instance.render_item(
                search_render, search_view_instance.coordinates, None)

        result['search_body'] = search_body
        result['view'] = self
        update_resources(self.request, result)
        return result
Пример #9
0
    def __call__(self):
        user = get_current(self.request)
        resources = deepcopy(getattr(
            self.request, 'resources', {'js_links': [], 'css_links': []}))
        search_view_instance = SearchView(self.context, self.request)
        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_body = search_view_result['coordinates'][search_view_instance.coordinates][0]['body']
            result['css_links'] = [c for c in search_view_result['css_links']
                                   if c not in resources['css_links']]
            result['js_links'] = [c for c in search_view_result['js_links']
                                  if c not in resources['js_links']]

        result['search_body'] = search_body
        result['view'] = self
        result['alerts'] = []
        if hasattr(user, 'get_alerts'):
            site = get_site_folder(True, self.request)
            result['alerts'] = user.get_alerts(site=site)

        result['login_action'] = None
        if self.request.user is None:
            root = self.request.root
            actions = getBusinessAction(
                context=root, request=self.request,
                process_id='usermanagement', node_id='login')
            if actions:
                actions_result = update_actions(root, self.request, actions)
                #actions_result = (action_updated, action_alert_messages,
                #                  action_resources, action_informations)
                if actions_result[3]:
                    result['login_action'] = actions_result[3][0]

        update_resources(self.request, result)
        return result
Пример #10
0
    def __call__(self):
        site = get_site_folder(True, self.request)
        if self.request.view_name in ('@@resetpassword', '@@registration',
                                      'login', '@@login') or \
           not getattr(site, 'activate_questionnaire', False):
            return {'questionnaire': None}

        user = get_current()
        email = getattr(user, 'email', '')
        if email:
            db = arango_server.db("lac")
            collection = create_collection(db, CURRENT_QUEST)
            doc = collection.get_first_example({"email": email})
            if doc:
                return {'questionnaire': None}

        resources = deepcopy(getattr(
            self.request, 'resources', {'js_links': [], 'css_links': []}))
        result = {'css_links': [], 'js_links': []}
        root = self.request.root
        actions = getBusinessAction(
            context=root, request=self.request,
            process_id='lacviewmanager', node_id='questionnaire')
        result['questionnaire'] = None
        result['current_questionnaire'] = CURRENT_QUEST
        if actions:
            actions_result = update_actions(root, self.request, actions)
            #actions_result = (action_updated, action_alert_messages,
            #                  action_resources, action_informations)
            if actions_result[3]:
                result['questionnaire'] = actions_result[3][0]
                result['css_links'] = [c for c in actions_result[2].get('css_links', [])
                                       if c not in resources['css_links']]
                result['js_links'] = [c for c in actions_result[2].get('js_links', [])
                                      if c not in resources['js_links']]

        update_resources(self.request, result)
        return result
Пример #11
0
    def __call__(self):
        root = getSite()
        resources = deepcopy(getattr(
            self.request, 'resources', {'js_links': [], 'css_links': []}))
        search_action, search_view = get_action_view('novaideoviewmanager',
                                                'search',
                                                self.request)
        search_view_instance = search_view(root, self.request,
                                           behaviors=[search_action])
        posted_formid = None
        if self.request.POST:
            if '__formid__' in self.request.POST:
                posted_formid = self.request.POST['__formid__']

            if posted_formid and \
              posted_formid.startswith(search_view_instance.viewid):
                search_view_instance.postedform = self.request.POST.copy()
                self.request.POST.clear()

        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_render = search_view_result['coordinates'][search_view_instance.coordinates][0]
            result['css_links'] = [c for c in search_view_result['css_links']
                                   if c not in resources['css_links']]
            result['js_links'] = [c for c in search_view_result['js_links']
                                  if c not in resources['js_links']]
            search_body = search_view_instance.render_item(
                search_render,
                search_view_instance.coordinates,
                None)

        result['search_body'] = search_body
        result['view'] = self
        update_resources(self.request, result)
        return result
Пример #12
0
    def __call__(self, has_admin_nav=False):
        result = {'condition': False}
        if self.request.user:
            channels_view = SeeChannels(self.context, self.request)
            try:
                channels_view_result = channels_view()
            except Exception as error:
                log.warning(error)
                return {'condition': False}

            channels = ''
            result = {
                'condition': True,
                'css_links': [],
                'js_links': [],
                'has_admin_nav': has_admin_nav
            }
            if isinstance(channels_view_result, dict) and \
               'coordinates' in channels_view_result:
                search_render = channels_view_result['coordinates'][
                    channels_view.coordinates][0]
                result['css_links'] = [
                    c for c in channels_view_result['css_links']
                    if c not in resources['css_links']
                ]
                result['js_links'] = [
                    c for c in channels_view_result['js_links']
                    if c not in resources['js_links']
                ]
                channels = channels_view.render_item(search_render,
                                                     channels_view.coordinates,
                                                     None)

            result['channels'] = channels
            update_resources(self.request, result)

        return result
Пример #13
0
    def __call__(self):
        root = getSite()
        options = {}
        options['locations'] = {}
        options['show_all'] = True
        resources = deepcopy(
            getattr(self.request, 'resources', {
                'js_links': [],
                'css_links': []
            }))
        search_view_instance = GeoSearchForm(self.context, self.request)
        search_view_result = search_view_instance()
        search_body = ''
        result = {'css_links': [], 'js_links': []}
        if isinstance(search_view_result, dict) and \
           'coordinates' in search_view_result:
            search_body = search_view_result['coordinates'][
                search_view_instance.coordinates][0]['body']
            result['css_links'] = [
                c for c in search_view_result['css_links']
                if c not in resources['css_links']
            ]
            result['js_links'] = [
                c for c in search_view_result['js_links']
                if c not in resources['js_links']
            ]

        result['search_body'] = search_body
        result['options'] = json.dumps(options)
        result['url'] = self.request.resource_url(
            root,
            '@@creationculturelapi',
            query={'op': 'find_geo_cultural_event'})

        update_resources(self.request, result)
        return result
Пример #14
0
    def __call__(self):
        is_homepage = self.request.view_name in ('index', '')
        if not is_homepage or 'challenge' not in self.request.content_to_manage:
            return {'condition': False}

        challenges_view = SeeChallengesHomeView(self.context, self.request)
        try:
            challenges_view_result = challenges_view()
            if getattr(challenges_view, 'no_challenges', False):
                return {'condition': False}

        except Exception as error:
            log.warning(error)
            return {'condition': False}

        challenges = ''
        result = {'condition': True, 'css_links': [], 'js_links': []}
        if isinstance(challenges_view_result, dict) and \
           'coordinates' in challenges_view_result:
            search_render = challenges_view_result['coordinates'][
                challenges_view.coordinates][0]
            result['css_links'] = [
                c for c in challenges_view_result['css_links']
                if c not in resources['css_links']
            ]
            result['js_links'] = [
                c for c in challenges_view_result['js_links']
                if c not in resources['js_links']
            ]
            challenges = challenges_view.render_item(
                search_render, challenges_view.coordinates, None)

        result['challenges'] = challenges
        result['view'] = self
        update_resources(self.request, result)
        return result
Пример #15
0
    def __call__(self):
        result = None
        try:
            self.validate()
            self.before_update()
            result = self.update()
            self.after_update()
        except ViewError as error:
            log.warning(error)
            raise error
        except Exception as http_error:
            log.exception(http_error)
            raise exc.HTTPInternalServerError()

        if isinstance(result, dict):
            if 'js_links' not in result:
                result['js_links'] = []

            if 'css_links' not in result:
                result['css_links'] = []

            update_resources(self.request, result)

        return result