Example #1
0
    def __call__(self):
        root = getSite()
        try:
            navbars = generate_listing_menu(
                self.request, root,
                descriminators=['lateral-action'],
                template='novaideo:views/templates/lateral_menu.pt')
        except ObjectRemovedException:
            return {'menu_body': None}

        result = {
            'css_links': [],
            'js_links': [],
            'menu_body': navbars['menu_body']}
        return result
Example #2
0
    def __call__(self):
        root = getSite()
        try:
            navbars = generate_listing_menu(
                self.request,
                root,
                descriminators=['lateral-action'],
                template='novaideo:views/templates/lateral_menu.pt')
        except ObjectRemovedException:
            return {'menu_body': None}

        result = {
            'css_links': [],
            'js_links': [],
            'menu_body': navbars['menu_body']
        }
        return result
Example #3
0
    def _rendre_comments(self,
                         comments,
                         current_user,
                         origin=False,
                         batch=None,
                         unread_comments=[],
                         filtered=False):
        all_comments = []
        resources = {'css_links': [], 'js_links': []}
        for obj in comments:
            try:
                navbars = generate_listing_menu(
                    self.request,
                    obj,
                    template='novaideo:views/templates/comment_menu.pt')
            except ObjectRemovedException:
                continue

            resources = merge_dicts(navbars['resources'], resources)
            object_values = {
                'context': obj,
                'menu_body': navbars['menu_body'],
                'primary_menu_body': navbars['primary_menu_body'],
                'footer_actions_body': navbars['footer_actions_body'],
                'footer_body': navbars['footer_body']
            }
            all_comments.append(object_values)

        all_comments = sorted(all_comments,
                              key=lambda e: e['context'].created_at)
        values = {
            'comments': all_comments,
            'unread_comments': unread_comments,
            'filtered': filtered,
            'current_user': current_user,
            'view': self,
            'origin': origin,
            'batch': batch,
            'level': COMMENT_LEVEL
        }
        body = self.content(args=values, template=self.template)['body']
        return body, resources
Example #4
0
    def get_entity_popover(self):
        oid_str = self.params('oid')
        from novaideo.utilities.util import (
            generate_listing_menu, DEFAUL_LISTING_FOOTER_ACTIONS_TEMPLATE,
            ObjectRemovedException)
        if oid_str:
            try:
                obj = get_obj(int(oid_str))
                user = get_current()
                if obj and can_access(user, obj):
                    try:
                        navbars = generate_listing_menu(
                            self.request,
                            obj,
                            descriminators=[
                                'communication-action', 'access-action'
                            ],
                            footer_template=
                            DEFAUL_LISTING_FOOTER_ACTIONS_TEMPLATE,
                            view_type='popover')
                    except ObjectRemovedException:
                        return {'body': ''}

                    user = get_current()
                    render_dict = {
                        'object': obj,
                        'oid': oid_str,
                        'current_user': user,
                        'footer_body': navbars['footer_body'],
                        'access_body': navbars['access_body'],
                    }
                    body = self.content(
                        args=render_dict,
                        template=obj.templates.get('popover'))['body']
                    return {'body': body}
            except:
                pass

        return {'body': ''}
Example #5
0
    def _rendre_comments(
        self, comments, current_user,
        origin=False, batch=None, unread_comments=[],
        filtered=False):
        all_comments = []
        resources = {'css_links': [], 'js_links': []}
        for obj in comments:
            try:
                navbars = generate_listing_menu(
                    self.request, obj,
                    template='novaideo:views/templates/comment_menu.pt')
            except ObjectRemovedException:
                continue

            resources = merge_dicts(navbars['resources'], resources)
            object_values = {
                'context': obj,
                'menu_body': navbars['menu_body'],
                'primary_menu_body': navbars['primary_menu_body'],
                'footer_actions_body': navbars['footer_actions_body'],
                'footer_body': navbars['footer_body']}
            all_comments.append(object_values)

        all_comments = sorted(all_comments,
                              key=lambda e: e['context'].created_at)
        values = {
            'comments': all_comments,
            'unread_comments': unread_comments,
            'filtered': filtered,
            'current_user': current_user,
            'view': self,
            'origin': origin,
            'batch': batch,
            'level': COMMENT_LEVEL
        }
        body = self.content(args=values, template=self.template)['body']
        return body, resources
Example #6
0
    def update(self):
        self.execute(None)
        try:
            navbars = generate_listing_menu(
                self.request, self.context,
                template=DEFAUL_LISTING_ACTIONS_TEMPLATE)
        except ObjectRemovedException:
            #Log in if the invitation is accepted
            if hasattr(self.context, 'person'):
                person = self.context.person
                headers = remember(self.request, get_oid(person))
                self.request.registry.notify(
                    LoggedIn(person.email, person,
                             self.context, self.request))
                root = getSite()
                return HTTPFound(
                    location=self.request.resource_url(root),
                    headers=headers)

            return HTTPFound(self.request.resource_url(getSite(), ''))

        user = get_current()
        values = {
            'invitation': self.context,
            'menu_body': navbars['menu_body'],
            'primary_menu_body': navbars['primary_menu_body'],
            'state': get_states_mapping(
                user, self.context, self.context.state[0]),}
        result = {}
        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.update(navbars['resources'])
        result['coordinates'] = {self.coordinates: [item]}
        return result
Example #7
0
    def update(self):
        self.execute(None)
        try:
            navbars = generate_listing_menu(
                self.request,
                self.context,
                template=DEFAUL_LISTING_ACTIONS_TEMPLATE)
        except ObjectRemovedException:
            #Log in if the invitation is accepted
            if hasattr(self.context, 'person'):
                person = self.context.person
                headers = remember(self.request, get_oid(person))
                self.request.registry.notify(
                    LoggedIn(person.email, person, self.context, self.request))
                root = getSite()
                return HTTPFound(location=self.request.resource_url(root),
                                 headers=headers)

            return HTTPFound(self.request.resource_url(getSite(), ''))

        user = get_current()
        values = {
            'invitation': self.context,
            'menu_body': navbars['menu_body'],
            'primary_menu_body': navbars['primary_menu_body'],
            'state': get_states_mapping(user, self.context,
                                        self.context.state[0]),
        }
        result = {}
        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.update(navbars['resources'])
        result['coordinates'] = {self.coordinates: [item]}
        return result
Example #8
0
    def get_entity_popover(self):
        oid_str = self.params('oid')
        from novaideo.utilities.util import (
            generate_listing_menu,
            DEFAUL_LISTING_FOOTER_ACTIONS_TEMPLATE,
            ObjectRemovedException)
        if oid_str:
            try:
                obj = get_obj(int(oid_str))
                user = get_current()
                if obj and can_access(user, obj):
                    try:
                        navbars = generate_listing_menu(
                            self.request, obj,
                            descriminators=['communication-action', 'access-action'],
                            footer_template=DEFAUL_LISTING_FOOTER_ACTIONS_TEMPLATE,
                            view_type='popover')
                    except ObjectRemovedException:
                        return {'body': ''}

                    user = get_current()
                    render_dict = {
                        'object': obj,
                        'oid': oid_str,
                        'current_user': user,
                        'footer_body': navbars['footer_body'],
                        'access_body': navbars['access_body'],
                    }
                    body = self.content(
                        args=render_dict,
                        template=obj.templates.get('popover'))['body']
                    return {'body': body}
            except:
                pass

        return {'body': ''}