当前位置: 首页>>代码示例>>Python>>正文


Python Ticket.populate方法代码示例

本文整理汇总了Python中trac.ticket.Ticket.populate方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.populate方法的具体用法?Python Ticket.populate怎么用?Python Ticket.populate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.Ticket的用法示例。


在下文中一共展示了Ticket.populate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_request

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def process_request(self, req):
        req.perm.assert_permission('TICKET_VIEW')

        action = req.args.get('action', 'view')

        if not req.args.has_key('id'):
            req.redirect(self.env.href.wiki())

        db = self.env.get_db_cnx()
        id = int(req.args.get('id'))

        ticket = Ticket(self.env, id, db=db)
        reporter_id = util.get_reporter_id(req)

        if req.method == 'POST':
            if not req.args.has_key('preview'):
                self._do_save(req, db, ticket)
            else:
                # Use user supplied values
                ticket.populate(req.args)
                req.hdf['ticket.action'] = action
                req.hdf['ticket.ts'] = req.args.get('ts')
                req.hdf['ticket.reassign_owner'] = req.args.get('reassign_owner') \
                                                   or req.authname
                req.hdf['ticket.resolve_resolution'] = req.args.get('resolve_resolution')
                reporter_id = req.args.get('author')
                comment = req.args.get('comment')
                if comment:
                    req.hdf['ticket.comment'] = comment
                    # Wiki format a preview of comment
                    req.hdf['ticket.comment_preview'] = wiki_to_html(comment,
                                                                     self.env,
                                                                     req, db)
        else:
            req.hdf['ticket.reassign_owner'] = req.authname
            # Store a timestamp in order to detect "mid air collisions"
            req.hdf['ticket.ts'] = ticket.time_changed

        self._insert_ticket_data(req, db, ticket, reporter_id)

        # If the ticket is being shown in the context of a query, add
        # links to help navigate in the query result set
        if 'query_tickets' in req.session:
            tickets = req.session['query_tickets'].split()
            if str(id) in tickets:
                idx = tickets.index(str(ticket.id))
                if idx > 0:
                    add_link(req, 'first', self.env.href.ticket(tickets[0]),
                             'Ticket #%s' % tickets[0])
                    add_link(req, 'prev', self.env.href.ticket(tickets[idx - 1]),
                             'Ticket #%s' % tickets[idx - 1])
                if idx < len(tickets) - 1:
                    add_link(req, 'next', self.env.href.ticket(tickets[idx + 1]),
                             'Ticket #%s' % tickets[idx + 1])
                    add_link(req, 'last', self.env.href.ticket(tickets[-1]),
                             'Ticket #%s' % tickets[-1])
                add_link(req, 'up', req.session['query_href'])

        add_stylesheet(req, 'common/css/ticket.css')
        return 'ticket.cs', None
开发者ID:lkraav,项目名称:trachacks,代码行数:62,代码来源:web_ui.py

示例2: _handle_ripe_save

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _handle_ripe_save(self, req):
        """ hander for save  """
        # TODO: workflow

        # get ticket id
        ticket_id = req.args.get("ticket_id")
        value = req.args.get("value", "").strip()
        field = req.args.get("field")
        old_value = req.args.get("old_value")

        # ticket
        ticket = Ticket(self.env, ticket_id)
        current_value = ticket.values.get(field)

        # validation
        if current_value != old_value and (old_value or current_value):
            self.log.info("Field value should be %s, got %s" % (repr(current_value), repr(old_value)))
            raise TracError("field value inconsistant.")

        # set params
        params = {}
        params[field] = value
        ticket.populate(params)

        # save ticket
        comment = "Updated from report"
        author = get_reporter_id(req, 'author')
        ticket.save_changes(author, comment)

        return value
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:32,代码来源:web_ui.py

示例3: _save_ticket_changes

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _save_ticket_changes(self, req, env, log, selectedTickets, tickets,
                             values, comment, modify_changetime, send_notifications):
        for id in selectedTickets:
            if id in tickets:
                t = Ticket(env, int(id))
                new_changetime = datetime.now(utc)
                
                log_msg = ""
                if not modify_changetime:
                    original_changetime = to_timestamp(t.time_changed)
                
                _values = values.copy()
                for field in [f for f in values.keys() \
                              if f in self._fields_as_list]:
                    _values[field] = self._merge_keywords(t.values[field], 
                                                          values[field],
                                                          log)
                
                t.populate(_values)
                t.save_changes(req.authname, comment, when=new_changetime)
  
                if send_notifications:
                    tn = TicketNotifyEmail(env)
                    tn.notify(t, newticket=0, modtime=new_changetime)

                if not modify_changetime:
                    self._reset_changetime(env, original_changetime, t)
                    log_msg = "(changetime not modified)"

                log.debug('BatchModifyPlugin: saved changes to #%s %s' % 
                          (id, log_msg))
开发者ID:lkraav,项目名称:trachacks,代码行数:33,代码来源:web_ui.py

示例4: _implementation

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
 def _implementation(db):
     """Apply each change to the ticket and save it."""
     for change in changes.strip(',').split(','):
         change_items = change.split(':')
         self.log.debug('WhiteboardModule: change_items=%s', change_items)
         t = Ticket(self.env, int(change_items[0]))
         values = {}
         values[field] = change_items[1]
         
         t.populate(values)
         t.save_changes(req.authname)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:13,代码来源:web_ui.py

示例5: test_remove_all

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
 def test_remove_all(self):
     test_name = sys._getframe().f_code.co_name
     expected = self.expected_results[test_name]
     ticket = Ticket(self.env)
     ticket.populate({'reporter': 'santa', 'summary': 'Summary line',
                      'description': 'Lorem ipsum dolor sit amet',
                      })
     ticket.insert()
     self.assertEqual(1, len(self._get_docs()))
     rv, output = self._execute('fulltext remove')
     self.assertEqual(expected, output)
     self.assertEqual(0, len(self._get_docs()))
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-solr,代码行数:14,代码来源:admin.py

示例6: _batch_modify

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _batch_modify(self, req):
        tickets = req.session["query_tickets"].split(" ")
        comment = req.args.get("comment", "")
        values = {}

        for field in TicketSystem(self.env).get_ticket_fields():
            name = field["name"]
            if name not in ("summary", "reporter", "description", "type", "status", "resolution", "owner"):
                if req.args.has_key("bm_" + name):
                    values[name] = req.args.get(name)

        for id in tickets:
            t = Ticket(self.env, id)
            t.populate(values)
            t.save_changes(req.authname, comment)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:17,代码来源:web_ui.py

示例7: run

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
def run(options):

  #
  # defualt value
  #
  
  T_STATUS = 'new'
  T_MILESTONE = ''
  
  #
  # begin to create new  ticket
  #
  
  TRAC_ENV = os.environ.get('TRAC_ENV') or os.path.expanduser('/home/trac/glue')
  if not os.path.isdir(TRAC_ENV):
    print >>sys.stderr, "Set TRAC_ENV to the Trac project directory."
    #sys.exit(2)
    return {
      "status": 2
    }
  
  from trac.env import open_environment
  from trac.ticket import Ticket
  t = Ticket(open_environment(TRAC_ENV))
  
  info = dict(
    status=T_STATUS, 
    owner=options["owner"], reporter=options["reporter"], cc=options["cc"],
    milestone=T_MILESTONE, type=options["type"],
    summary=options["summary"].decode(sys.getfilesystemencoding()),
    description = options["description"].decode(sys.getfilesystemencoding())
  )
  
  t.populate(info)
  num = t.insert()
  if not num:
    print >>sys.stderr, "Ticket not created"
    print >>sys.stderr, vals
    #sys.exit(1)
    return {
      "status": 1
    }
  
  #print "Ticket #%d" % (num)
  return {
    "status": 0,
    "id": num
  }
开发者ID:xxd3vin,项目名称:xxutils,代码行数:50,代码来源:newticket.py

示例8: _process_request

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _process_request(self, req):
        field = req.args.get("whiteboard_group_by")
        changes = req.args.get("whiteboard_changes")

        self.log.debug("WhiteboardModule: field=%s", field)
        self.log.debug("WhiteboardModule: changes=%s", changes)

        db = self.env.get_db_cnx()
        for change in changes.strip(",").split(","):
            change_items = change.split(":")
            self.log.debug("WhiteboardModule: change_items=%s", change_items)
            t = Ticket(self.env, int(change_items[0]))
            values = {}
            values[field] = change_items[1]

            t.populate(values)
            t.save_changes(req.authname, "")
        db.commit()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:20,代码来源:web_ui.py

示例9: _do_create

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _do_create(self, req, db):
        if not req.args.get('summary'):
            raise TracError(u'Les tickets doivent contenir un intitulé.')

        ticket = Ticket(self.env, db=db)
        ticket.populate(req.args)
        ticket.values['reporter'] = get_reporter_id(req, 'reporter')
        self._validate_ticket(req, ticket)

        ticket.insert(db=db)
        db.commit()

        # Notify
        try:
            tn = TicketNotifyEmail(self.env)
            tn.notify(ticket, newticket=True)
        except Exception, e:
            self.log.exception(u"Impossible d'envoyer une notification sur la création du "
                               u"ticket #%s: %s" % (ticket.id, e))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:21,代码来源:web_ui.py

示例10: _do_create

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _do_create(self, req, db):
        if not req.args.get('summary'):
            raise TracError('Tickets must contain a summary.')

        ticket = Ticket(self.env, db=db)
        ticket.populate(req.args)
        ticket.values['reporter'] = get_reporter_id(req, 'reporter')
        self._validate_ticket(req, ticket)

        ticket.insert(db=db)
        db.commit()

        # Notify
        try:
            tn = TicketNotifyEmail(self.env)
            tn.notify(ticket, newticket=True)
        except Exception, e:
            self.log.exception("Failure sending notification on creation of "
                               "ticket #%s: %s" % (ticket.id, e))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:21,代码来源:web_ui.py

示例11: _do_create

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def _do_create(self, req, db):
        if not req.args.get('summary'):
            raise TracError('Tickets must contain a summary.')

        ticket = Ticket(self.env, db=db)
        ticket.values.setdefault('reporter', util.get_reporter_id(req))
        ticket.populate(req.args)
        
        #Check for required fields
        ticket.validate_required_fields(req.args)
        
        ticket.insert(db=db)
        db.commit()

        # Notify
        try:
            tn = TicketNotifyEmail(self.env)
            tn.notify(ticket, newticket=True)
        except Exception, e:
            self.log.exception("Failure sending notification on creation of "
                               "ticket #%s: %s" % (ticket.id, e))
开发者ID:lkraav,项目名称:trachacks,代码行数:23,代码来源:web_ui.py

示例12: createTicket

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
 def createTicket(self, ticket_fields, env):
     """
     Creates the ticket in trac.
     
     Keyword arguments:
     ticket_fields -- A dictionary with the ticket fields.
     
     Returns: 
     The ticket number.
     """
     
     ticket = Ticket(env)
     
     # Lets populate the ticket with our fields.
     # The ticket has already set all default values for us from trac.ini
     # in it's init, nice huh. 
     # Don't write to ticket.values[] unless you know what you are doing
     ticket.populate(ticket_fields)
     
     # create the ticket
     return ticket.insert()
开发者ID:davideuler,项目名称:ticket2trac,代码行数:23,代码来源:ticket2trac.py

示例13: _save_ticket_changes

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
 def _save_ticket_changes(self, req, selected_tickets,
                          new_values, comment, action):
     """Save all of the changes to tickets."""
     when = datetime.now(utc)
     list_fields = self._get_list_fields()
     with self.env.db_transaction as db:
         for id in selected_tickets:
             t = Ticket(self.env, int(id))
             _values = new_values.copy()
             for field in list_fields:
                 if field in new_values:
                     old = t[field] if field in t else ''
                     new = new_values[field]
                     mode = req.args.get('batchmod_value_' + field +
                                         '_mode')
                     new2 = req.args.get('batchmod_value_' + field +
                                         '_secondary', '')
                     _values[field] = self._change_list(old, new, new2,
                                                        mode)
             controllers = list(self._get_action_controllers(req, t,
                                                             action))
             for controller in controllers:
                 _values.update(controller.get_ticket_changes(req, t,
                                                              action))
             t.populate(_values)
             t.save_changes(req.authname, comment, when=when)
             for controller in controllers:
                 controller.apply_action_side_effects(req, t, action)
     event = BatchTicketChangeEvent(selected_tickets, when,
                                    req.authname, comment, new_values,
                                    action)
     try:
         NotificationSystem(self.env).notify(event)
     except Exception as e:
         self.log.error("Failure sending notification on ticket batch"
                        "change: %s", exception_to_unicode(e))
         add_warning(req, tag_("The changes have been saved, but an "
                               "error occurred while sending "
                               "notifications: %(message)s",
                               message=to_unicode(e)))
开发者ID:pkdevbox,项目名称:trac,代码行数:42,代码来源:batch.py

示例14: test_ticket

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def test_ticket(self):
        self.env.config.set('ticket-custom', 'foo', 'text')
        ticket = Ticket(self.env)
        ticket.populate({'reporter': 'santa', 'summary': 'Summary line',
                         'description': 'Lorem ipsum dolor sit amet',
                         'foo': 'This is a custom field',
                         'keywords': 'alpha bravo charlie',
                         'cc': '[email protected], [email protected]',
                         })
        ticket.insert()
        so = self._get_so()
        self.assertEquals('%s:ticket:1' % self.basename, so.doc_id)
        self.assertEquals('ticket', so.realm)
        self.assertEquals('1', so.id)
        self.assertTrue('#1' in so.title)
        self.assertTrue('Summary line' in so.title)
        self.assertEquals('santa', so.author)
        self.assertEquals(ticket['time'], so.created)
        self.assertEquals(ticket['changetime'], so.changed)
        self.assertTrue('[email protected]' in so.involved)
        self.assertTrue('[email protected]' in so.involved)
        self.assertTrue('bravo' in so.tags)
        self.assertTrue('Lorem ipsum' in so.oneline)
        self.assertTrue('Lorem ipsum' in so.body)

        original_time = ticket['time']
        ticket['description'] = 'No latin filler here'
        ticket.save_changes('Jack Sprat', 'Could eat no fat')
        so = self._get_so()
        self.assertEquals('%s:ticket:1' % self.basename, so.doc_id)
        self.assertEquals('ticket', so.realm)
        self.assertEquals('1', so.id)
        self.assertEquals(original_time, so.created)
        self.assertEquals(ticket['changetime'], so.changed)
        self.assertFalse('Lorem ipsum' in so.body)
        self.assertTrue('No latin filler here' in so.body)
        self.assertTrue('Could eat no fat' in so.comments)
开发者ID:getpenelope,项目名称:fulltextsearchplugin,代码行数:39,代码来源:fulltextsearch.py

示例15: process_request

# 需要导入模块: from trac.ticket import Ticket [as 别名]
# 或者: from trac.ticket.Ticket import populate [as 别名]
    def process_request(self, req, env, log):
        tickets = req.session["query_tickets"].split(" ")
        comment = req.args.get("batchmod_value_comment", "")
        modify_changetime = bool(req.args.get("batchmod_modify_changetime", False))

        values = self._get_new_ticket_values(req, env)
        self._check_for_resolution(values)
        self._remove_resolution_if_not_closed(values)

        selectedTickets = req.args.get("selectedTickets")
        log.debug("BatchModifyPlugin: selected tickets: %s", selectedTickets)
        selectedTickets = isinstance(selectedTickets, list) and selectedTickets or selectedTickets.split(",")
        if not selectedTickets:
            raise TracError, "No tickets selected"

        for id in selectedTickets:
            if id in tickets:
                t = Ticket(env, int(id))

                log_msg = ""
                if not modify_changetime:
                    original_changetime = to_timestamp(t.time_changed)

                _values = values.copy()
                for field in [f for f in values.keys() if f in self._fields_as_list]:
                    _values[field] = self._merge_keywords(t.values[field], values[field], log)

                t.populate(_values)
                t.save_changes(req.authname, comment)

                if not modify_changetime:
                    log_msg = "(changetime not modified)"
                    db = env.get_db_cnx()
                    db.cursor().execute("UPDATE ticket set changetime=%s where id=%s" % (original_changetime, t.id))
                    db.commit()

                log.debug("BatchModifyPlugin: saved changes to #%s %s" % (id, log_msg))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:39,代码来源:web_ui.py


注:本文中的trac.ticket.Ticket.populate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。