コード例 #1
0
ファイル: web_ui.py プロジェクト: thimalk/bloodhound-789
 def remove_relations(self, req, rellist):
     relsys = RelationsSystem(self.env)
     for relid in rellist:
         relation = Relation.load_by_relation_id(self.env, relid)
         resource = ResourceIdSerializer.get_resource_by_id(
             relation.destination)
         if 'TICKET_MODIFY' in req.perm(resource):
             relsys.delete(relid)
         else:
             add_warning(req,
                 _('Not enough permissions to remove relation "%s"' % relid))
コード例 #2
0
ファイル: web_ui.py プロジェクト: mohsadki/dargest
 def remove_relations(self, req, rellist):
     relsys = RelationsSystem(self.env)
     for relid in rellist:
         relation = Relation.load_by_relation_id(self.env, relid)
         resource = \
             ResourceIdSerializer.get_resource_by_id(relation.destination)
         if 'TICKET_MODIFY' in req.perm(resource):
             relsys.delete(relid)
         else:
             add_warning(req, _('Insufficient permissions to remove '
                                'relation "%(relation)s"', relation=relid))
コード例 #3
0
ファイル: relations.py プロジェクト: thimalk/bloodhound
    def render_widget(self, name, context, options):
        """Gather list of relations and render data in compact view
        """
        req = context.req
        title = _('Related tickets')
        params = ('tid', 'max')
        tid, max_ = self.bind_params(name, options, *params)

        ticket = Ticket(self.env, tid)
        data = {
            'ticket': ticket,
            'relations': \
                RelationManagementModule(self.env).get_ticket_relations(ticket),
            'get_resource_shortname': get_resource_shortname,
            'get_resource_summary': get_resource_summary,
        }
        return 'widget_relations.html', \
            {'title': title, 'data': data, }, context
コード例 #4
0
ファイル: relations.py プロジェクト: tsanov/bloodhound
    def render_widget(self, name, context, options):
        """Gather list of relations and render data in compact view
        """
        title = _('Related tickets')
        params = ('tid', 'max')
        tid, max_ = self.bind_params(name, options, *params)

        ticket = Ticket(self.env, tid)
        data = {
            'ticket': ticket,
            'relations': \
                RelationManagementModule(self.env).get_ticket_relations(ticket),
            'get_resource_shortname': get_resource_shortname,
            'get_resource_summary': get_resource_summary,
        }
        return 'widget_relations.html', {
            'title': title,
            'data': data,
        }, context
コード例 #5
0
ファイル: web_ui.py プロジェクト: thimalk/bloodhound-789
    def process_request(self, req):
        tid = req.args.get('id')
        if not tid:
            raise TracError(_('No ticket id provided.'))

        try:
            ticket = Ticket(self.env, tid)
        except ValueError:
            raise TracError(_('Invalid ticket id.'))

        req.perm.require('TICKET_VIEW')
        relsys = RelationsSystem(self.env)

        data = {
            'relation': {},
        }
        if req.method == 'POST':
            # for modifying the relations TICKET_MODIFY is required for
            # both the source and the destination tickets
            req.perm.require('TICKET_MODIFY')

            if 'remove' in req.args:
                rellist = req.args.get('sel')
                if rellist:
                    if isinstance(rellist, basestring):
                        rellist = [rellist, ]
                    self.remove_relations(req, rellist)
            elif 'add' in req.args:
                relation = dict(
                    destination=req.args.get('dest_tid', ''),
                    type=req.args.get('reltype', ''),
                    comment=req.args.get('comment', ''),
                )
                try:
                    trs = TicketRelationsSpecifics(self.env)
                    dest_ticket = trs.find_ticket(relation['destination'])
                except NoSuchTicketError:
                    data['error'] = _('Invalid ticket ID.')
                else:
                    req.perm.require('TICKET_MODIFY', Resource(dest_ticket.id))

                    try:
                        dbrel = relsys.add(ticket, dest_ticket,
                            relation['type'],
                            relation['comment'],
                            req.authname)
                    except NoSuchTicketError:
                        data['error'] = _('Invalid ticket ID.')
                    except UnknownRelationType:
                        data['error'] = _('Unknown relation type.')
                    except ValidationError as ex:
                        data['error'] = ex.message
                    else:
                        # Notify
                        try:
                            self.notify_relation_changed(dbrel)
                        except Exception, e:
                            self.log.error("Failure sending notification on"
                                           "creation of relation: %s",
                                           exception_to_unicode(e))
                            add_warning(req, _("The relation has been added, but an "
                                               "error occurred while sending"
                                               "notifications: " "%(message)s",
                                               message=to_unicode(e)))

                if 'error' in data:
                    data['relation'] = relation
            else:
                raise TracError(_('Invalid operation.'))
コード例 #6
0
ファイル: web_ui.py プロジェクト: tsanov/bloodhound
    def process_request(self, req):
        tid = req.args.get('id')
        if not tid:
            raise TracError(_('No ticket id provided.'))

        try:
            ticket = Ticket(self.env, tid)
        except ValueError:
            raise TracError(_('Invalid ticket id.'))

        # For access to the relation management, TICKET_MODIFY is required.
        req.perm.require('TICKET_MODIFY')
        relsys = RelationsSystem(self.env)

        data = {
            'relation': {},
        }
        if req.method == 'POST':
            # for modifying the relations TICKET_MODIFY is required for
            # both the source and the destination tickets

            if 'remove' in req.args:
                rellist = req.args.get('sel')
                if rellist:
                    if isinstance(rellist, basestring):
                        rellist = [
                            rellist,
                        ]
                    self.remove_relations(req, rellist)
            elif 'add' in req.args:
                relation = dict(
                    destination=req.args.get('dest_tid', ''),
                    type=req.args.get('reltype', ''),
                    comment=req.args.get('comment', ''),
                )
                try:
                    trs = TicketRelationsSpecifics(self.env)
                    dest_ticket = trs.find_ticket(relation['destination'])
                except NoSuchTicketError:
                    data['error'] = _('Invalid ticket ID.')
                else:
                    req.perm.require('TICKET_MODIFY', Resource(dest_ticket.id))

                    try:
                        dbrel = relsys.add(ticket, dest_ticket,
                                           relation['type'],
                                           relation['comment'], req.authname)
                    except NoSuchTicketError:
                        data['error'] = _('Invalid ticket ID.')
                    except UnknownRelationType:
                        data['error'] = _('Unknown relation type.')
                    except ValidationError as ex:
                        data['error'] = ex.message
                    else:
                        # Notify
                        try:
                            self.notify_relation_changed(dbrel)
                        except Exception, e:
                            self.log.error(
                                "Failure sending notification on"
                                "creation of relation: %s",
                                exception_to_unicode(e))
                            add_warning(
                                req,
                                _(
                                    "The relation has been added, "
                                    "but an error occurred while "
                                    "sending notifications: "
                                    "%(message)s",
                                    message=to_unicode(e)))

                if 'error' in data:
                    data['relation'] = relation
            else:
                raise TracError(_('Invalid operation.'))