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


Python Ticket.delete方法代码示例

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


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

示例1: test_ticket_delete

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import delete [as 别名]
    def test_ticket_delete(self):
        ticket = Ticket(self.env)
        ticket['summary'] = 'ticket summary'
        ticket.insert()
        self.hours_thp.add_ticket_hours(ticket.id, 'user', 160)
        self.hours_thp.add_ticket_hours(ticket.id, 'user', 1200)

        ticket.delete()

        hours = self.hours_thp.get_ticket_hours(ticket.id)
        self.assertEqual([], hours)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:13,代码来源:ticket.py

示例2: _delete_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import delete [as 别名]
 def _delete_ticket(self, id):
     """Delete the given ticket ID."""
     major, minor = self._get_trac_version()
     if major > 0 or minor >= 10:
         ticket = Ticket(self.env,id)
         ticket.delete()
     else:
         db = self.env.get_db_cnx()
         cursor = db.cursor()
         cursor.execute("DELETE FROM ticket WHERE id=%s", (id,))
         cursor.execute("DELETE FROM ticket_change WHERE ticket=%s", (id,))
         cursor.execute("DELETE FROM attachment WHERE type='ticket' and id=%s", (id,))
         cursor.execute("DELETE FROM ticket_custom WHERE ticket=%s", (id,))
         db.commit()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:16,代码来源:web_ui.py

示例3: process_request

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import delete [as 别名]
    def process_request(self, req):
        id = int(req.args.get('id'))
        req.perm('ticket', id).require('TICKET_ADMIN')
        ticket = Ticket(self.env, id)
        action = req.args['action']
        cnum = req.args.get('cnum')
        if req.method == 'POST':
            if 'cancel' in req.args:
                href = req.href.ticket(id)
                if action == 'delete-comment':
                    href += '#comment:%s' % cnum
                req.redirect(href)

            if action == 'delete':
                ticket.delete()
                add_notice(req, _('The ticket #%(id)s has been deleted.',
                                  id=ticket.id))
                req.redirect(req.href())

            elif action == 'delete-comment':
                cdate = from_utimestamp(long(req.args.get('cdate')))
                ticket.delete_change(cdate=cdate)
                add_notice(req, _('The ticket comment %(num)s on ticket '
                                  '#%(id)s has been deleted.',
                                  num=cnum, id=ticket.id))
                req.redirect(req.href.ticket(id))

        tm = TicketModule(self.env)
        data = tm._prepare_data(req, ticket)
        tm._insert_ticket_data(req, ticket, data,
                               get_reporter_id(req, 'author'), {})
        data.update(action=action, cdate=None)

        if action == 'delete-comment':
            data['cdate'] = req.args.get('cdate')
            cdate = from_utimestamp(long(data['cdate']))
            for change in data['changes']:
                if change.get('date') == cdate:
                    data['change'] = change
                    data['cnum'] = change.get('cnum')
                    break
            else:
                raise TracError(_('Comment %(num)s not found', num=cnum))
        elif action == 'delete':
            attachments = Attachment.select(self.env, ticket.realm, ticket.id)
            data.update(attachments=list(attachments))

        add_stylesheet(req, 'common/css/ticket.css')
        return 'ticket_delete.html', data, None
开发者ID:pkdevbox,项目名称:trac,代码行数:51,代码来源:deleter.py

示例4: StructuredMilestone

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import delete [as 别名]
class StructuredMilestone(object):
    """The model for structured milestone."""
    __proxy_attrs__ = ['name', 'due', 'completed', 'description', 'resource', 'exists', 'is_completed', 'is_late']
    _kids = None
    _level = None
    def __init__(self, env, milestone=None, db=None):
        self.env = env
        if not isinstance(milestone, Milestone):
            milestone = Milestone(env, milestone)
            
        self.milestone = milestone
        self.ticket = Ticket(self.env)
        self.ticket.fields = MilestoneSystem(self.env).get_milestone_fields()
        self.ticket.values = {}
        self.ticket['summary'] = milestone.name        
        self.ticket['type'] = milestone_ticket_type
        self.ticket._old={}
        
        if self.exists:
            self._fetch(milestone.name, db)
    
    def __getattribute__(self, name):
        if name in object.__getattribute__(self, "__proxy_attrs__"):
            return getattr(object.__getattribute__(self, "milestone"), name)
        return object.__getattribute__(self, name)
    
    def __setattr__(self, name, value):
        if name in object.__getattribute__(self, "__proxy_attrs__"):
            setattr(object.__getattribute__(self, "milestone"), name, value)
        else:
            self.__dict__[name]=value
    
    parent = property(fget= lambda self: self.ticket.values.get('milestone'))
    is_started = property(fget=lambda self: self.ticket.values.get('started') is not None)
    level = property(fget = lambda self: self._get_level(), fset = lambda self, val: self._set_level(val))
    can_be_closed = property(lambda self: self._can_be_closed())
    kids = property (lambda self: self._get_kids())
    
    def _fetch(self, name, db=None):
        if not db:
            db = self.env.get_db_cnx()
            
        cursor = db.cursor()
        cursor.execute("SELECT id"
                        " FROM ticket"
                       " WHERE summary=%s"
                         " AND type=%s", (name, milestone_ticket_type))
        row = cursor.fetchone()
        if not row:
            raise ResourceNotFound('Associated Ticket %s does not exist.' % name,
                                   'Invalid Milestone State')
        self.ticket._fetch_ticket(row[0], db)

    def _get_kids(self):
        if self._kids is None:
            db = self.env.get_db_cnx()
            cursor = db.cursor()
            cursor.execute("SELECT m.name "
                            " FROM milestone m,"
                                 " ticket t"
                           " WHERE m.name=t.summary"
                             " AND t.milestone=%s"
                             " AND t.type=%s", (self.name, milestone_ticket_type))
            self._kids = [StructuredMilestone(self.env, name) for name, in cursor]
        return self._kids

    
    def _can_be_closed(self):
        kids = self.kids
        if kids:
            for kid in kids:
                if not kid.is_completed:
                    return False
        return True

    def _get_level(self):
        if self._level:
            return self._level
        lev = 0
        if self.parent:
            parent_milestone = StructuredMilestone(self.env, self.parent)
            if parent_milestone.exists:
                lev = parent_milestone.level['index'] +1
        self._level = {'index':lev, 'label': self._get_level_label(lev)}
        return self._level
    
    def _set_level(self, lev):
        int_lev = int(lev)
        self._level = {'index':int_lev, 'label': self._get_level_label(int_lev)}
        
    def _get_level_label(self, idx):
        label = 'undefined'
        levels = IttecoEvnSetup(self.env).milestone_levels
        if levels and idx < len(levels):
            label = levels[idx]
        return label

    def delete(self, retarget_to=None, author=None, db=None):
        handle_commit = False
        if not db:
#.........这里部分代码省略.........
开发者ID:esogs,项目名称:IttecoTracPlugin,代码行数:103,代码来源:model.py

示例5: _delete_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import delete [as 别名]
 def _delete_ticket(self, id):
     """Delete the given ticket ID."""
     ticket = Ticket(self.env, id)
     ticket.delete()
     self.log.debug("Deleted ticket #%s" % id)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:web_ui.py


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