Esempio n. 1
0
    def get_user_permissions(self, username):
        for policy in instance_for_every_env(self.env, AuthzPolicy):
            product = get_product(policy.env).prefix
            self.refresh_config(policy)

            for doc_type, doc_id, perm, denied in self.get_relevant_permissions(policy, username):
                yield product, doc_type, doc_id, perm, denied
Esempio n. 2
0
    def build_doc(self, trac_doc):
        ticket = trac_doc
        searchable_name = '#%(ticket.id)s %(ticket.id)s' %\
                          {'ticket.id': ticket.id}
        doc = {
            IndexFields.ID: str(ticket.id),
            IndexFields.NAME: searchable_name,
            '_stored_' + IndexFields.NAME: str(ticket.id),
            IndexFields.TYPE: TICKET_TYPE,
            IndexFields.TIME: ticket.time_changed,
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }
        # TODO: Add support for moving tickets between products.

        for field, index_field in self.optional_fields.iteritems():
            if field in ticket.values:
                field_content = ticket.values[field]
                if field in self.text_area_fields:
                    field_content = self.wiki_formatter.format(field_content)
                doc[index_field] = field_content

        doc[TicketFields.CHANGES] = u'\n\n'.join([
            self.wiki_formatter.format(x[4]) for x in ticket.get_changelog()
            if x[2] == u'comment'
        ])
        return doc
Esempio n. 3
0
    def get_user_permissions(self, username):
        for policy in instance_for_every_env(self.env, AuthzPolicy):
            product = get_product(policy.env).prefix
            self.refresh_config(policy)

            for doc_type, doc_id, perm, denied in self.get_relevant_permissions(policy, username):
                yield product, doc_type, doc_id, perm, denied
Esempio n. 4
0
    def build_doc(self, trac_doc):
        ticket = trac_doc
        searchable_name = '#%(ticket.id)s %(ticket.id)s' %\
                          {'ticket.id': ticket.id}
        doc = {
            IndexFields.ID: str(ticket.id),
            IndexFields.NAME: searchable_name,
            '_stored_' + IndexFields.NAME: str(ticket.id),
            IndexFields.TYPE: TICKET_TYPE,
            IndexFields.TIME: ticket.time_changed,
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }
        # TODO: Add support for moving tickets between products.


        for field, index_field in self.optional_fields.iteritems():
            if field in ticket.values:
                field_content = ticket.values[field]
                if field in self.text_area_fields:
                    field_content = self.wiki_formatter.format(field_content)
                doc[index_field] = field_content

        doc[TicketFields.CHANGES] = u'\n\n'.join(
            [self.wiki_formatter.format(x[4]) for x in ticket.get_changelog()
             if x[2] == u'comment'])
        return doc
Esempio n. 5
0
 def _get_all_user_permissions(self, context):
     username = context.req.authname
     permissions = []
     for perm in instance_for_every_env(self.env, PermissionSystem):
         prefix = get_product(perm.env).prefix
         for action in self._required_permissions.itervalues():
             if perm.check_permission(action, username):
                 permissions.append((prefix, action))
     return permissions
Esempio n. 6
0
 def _get_all_user_permissions(self, context):
     username = context.req.authname
     permissions = []
     for perm in instance_for_every_env(self.env, PermissionSystem):
         prefix = get_product(perm.env).prefix
         for action in self._required_permissions.itervalues():
             if perm.check_permission(action, username):
                 permissions.append((prefix, action))
     return permissions
Esempio n. 7
0
 def resource_deleted(self, resource, context):
     # pylint: disable=unused-argument
     try:
         search_api = BloodhoundSearchApi(self.env)
         search_api.delete_doc(
             get_product(self.env).prefix, MILESTONE_TYPE, resource.name)
     except Exception, e:
         if self.silence_on_error:
             self.log.error("Error occurs during milestone indexing. \
                 The error will not be propagated. Exception: %s", e)
         else:
             raise
Esempio n. 8
0
 def wiki_page_deleted(self, page):
     """Called when a ticket is deleted."""
     try:
         search_api = BloodhoundSearchApi(self.env)
         search_api.delete_doc(
             get_product(self.env).prefix, WIKI_TYPE, page.name)
     except Exception, e:
         if self.silence_on_error.lower() == "true":
             self.log.error("Error occurs during wiki indexing. \
                 The error will not be propagated. Exception: %s", e)
         else:
             raise
Esempio n. 9
0
 def wiki_page_deleted(self, page):
     """Called when a ticket is deleted."""
     try:
         search_api = BloodhoundSearchApi(self.env)
         search_api.delete_doc(
             get_product(self.env).prefix, WIKI_TYPE, page.name)
     except Exception, e:
         if self.silence_on_error.lower() == "true":
             self.log.error(
                 "Error occurs during wiki indexing. \
                 The error will not be propagated. Exception: %s", e)
         else:
             raise
Esempio n. 10
0
 def resource_deleted(self, resource, context):
     # pylint: disable=unused-argument
     try:
         search_api = BloodhoundSearchApi(self.env)
         search_api.delete_doc(
             get_product(self.env).prefix, MILESTONE_TYPE, resource.name)
     except Exception, e:
         if self.silence_on_error:
             self.log.error(
                 "Error occurs during milestone indexing. \
                 The error will not be propagated. Exception: %s", e)
         else:
             raise
Esempio n. 11
0
    def build_doc(self, trac_doc):
        page = trac_doc
        #This is very naive prototype implementation
        #TODO: a lot of improvements must be added here!!!
        searchable_name = page.name + ' ' + \
            WikiSystem(self.env).format_page_name(page.name, split=True)

        doc = {
            IndexFields.ID: page.name,
            IndexFields.NAME: searchable_name,
            '_stored_' + IndexFields.NAME: page.name,
            IndexFields.TYPE: WIKI_TYPE,
            IndexFields.TIME: page.time,
            IndexFields.AUTHOR: page.author,
            IndexFields.CONTENT: self.wiki_formatter.format(page.text),
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }
        return doc
Esempio n. 12
0
    def build_doc(self, trac_doc):
        page = trac_doc
        #This is very naive prototype implementation
        #TODO: a lot of improvements must be added here!!!
        searchable_name = page.name + ' ' + \
            WikiSystem(self.env).format_page_name(page.name, split=True)

        doc = {
            IndexFields.ID: page.name,
            IndexFields.NAME: searchable_name,
            '_stored_' + IndexFields.NAME: page.name,
            IndexFields.TYPE: WIKI_TYPE,
            IndexFields.TIME: page.time,
            IndexFields.AUTHOR: page.author,
            IndexFields.CONTENT: self.wiki_formatter.format(page.text),
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }
        return doc
Esempio n. 13
0
    def build_doc(self, trac_doc):
        milestone = trac_doc
        #TODO: a lot of improvements must be added here.
        if milestone.is_completed:
            status = 'completed'
        else:
            status = 'open'
        doc = {
            IndexFields.ID: milestone.name,
            IndexFields.NAME: milestone.name,
            IndexFields.TYPE: MILESTONE_TYPE,
            IndexFields.STATUS: status,
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }

        for field, index_field in self.optional_fields.iteritems():
            value = getattr(milestone, field, None)
            if value is not None:
                doc[index_field] = value

        return doc
Esempio n. 14
0
    def build_doc(self, trac_doc):
        milestone = trac_doc
        #TODO: a lot of improvements must be added here.
        if milestone.is_completed:
            status = 'completed'
        else:
            status = 'open'
        doc = {
            IndexFields.ID: milestone.name,
            IndexFields.NAME: milestone.name,
            IndexFields.TYPE: MILESTONE_TYPE,
            IndexFields.STATUS: status,
            IndexFields.PRODUCT: get_product(self.env).prefix,
        }

        for field, index_field in self.optional_fields.iteritems():
            value = getattr(milestone, field, None)
            if value is not None:
                doc[index_field] = value

        return doc