當前位置: 首頁>>代碼示例>>Python>>正文


Python ticket.Milestone類代碼示例

本文整理匯總了Python中trac.ticket.Milestone的典型用法代碼示例。如果您正苦於以下問題:Python Milestone類的具體用法?Python Milestone怎麽用?Python Milestone使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Milestone類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process_request

    def process_request(self, req):
        milestone_id = req.args.get('id')
        req.perm('milestone', milestone_id).require('MILESTONE_VIEW')
        
        add_link(req, 'up', req.href.roadmap(), _('Roadmap'))

        action = req.args.get('action', 'view')
        try:
            milestone = Milestone(self.env, milestone_id)
        except ResourceNotFound:
            if 'MILESTONE_CREATE' not in req.perm('milestone', milestone_id):
                raise
            milestone = Milestone(self.env, None)
            milestone.name = milestone_id
            action = 'edit' # rather than 'new' so that it works for POST/save

        if req.method == 'POST':
            if req.args.has_key('cancel'):
                if milestone.exists:
                    req.redirect(req.href.milestone(milestone.name))
                else:
                    req.redirect(req.href.roadmap())
            elif action == 'edit':
                return self._do_save(req, milestone)
            elif action == 'delete':
                self._do_delete(req, milestone)
        elif action in ('new', 'edit'):
            return self._render_editor(req, milestone)
        elif action == 'delete':
            return self._render_confirm(req, milestone)

        if not milestone.name:
            req.redirect(req.href.roadmap())

        return self._render_view(req, milestone)
開發者ID:moreati,項目名稱:trac-gitsvn,代碼行數:35,代碼來源:roadmap.py

示例2: change_milestone

 def change_milestone(self, name_to_change, name=None, description=None):
     milestone = Milestone(self.env, name_to_change)
     if name is not None:
         milestone.name = name
     if description is not None:
         milestone.description = description
     milestone.update()
     return milestone
開發者ID:domaemon,項目名稱:bloodhound-qa,代碼行數:8,代碼來源:base.py

示例3: test_milestone

    def test_milestone(self):
        milestone = Milestone(self.env)
        milestone.name = 'New target date'
        milestone.description = 'Lorem ipsum dolor sit amet'
        milestone.insert()
        so = self._get_so()
        self.assertEquals('%s:milestone:New target date' % self.basename,
                          so.doc_id)
        self.assertEquals('milestone', so.realm),
        self.assertEquals('New target date', so.id)
        self.assertTrue('New target date' in so.title)
        self.assertTrue('Lorem ipsum' in so.title)
        self.assertTrue('Lorem ipsum' in so.oneline)
        self.assertTrue('Lorem ipsum' in so.body)

        milestone.description = 'No latin filler here'
        milestone.due = datetime(2001, 01, 01, tzinfo=utc)
        milestone.update()
        so = self._get_so()
        self.assertEquals('%s:milestone:New target date' % self.basename,
                          so.doc_id)
        self.assertEquals('milestone', so.realm),
        self.assertEquals('New target date', so.id)
        self.assertEquals(milestone.due, so.changed)
        self.assertFalse('Lorem ipsum' in so.body)
        self.assertTrue('No latin filler here' in so.body)
開發者ID:getpenelope,項目名稱:fulltextsearchplugin,代碼行數:26,代碼來源:fulltextsearch.py

示例4: _get_options

 def _get_options(self, field_name):
     """Return a list of options for the given [dynvars] field:
     
      [dynvars]
      myfield.options = value1|value2|value3
     
     If no [dynvars] field is found, a select field is searched
     and its options returned.  For the milestone field, completed
     milestones are omitted.  If no select field is found, then an
     empty list is returned."""
     # look for [dynvars] field
     for key,val in self.env.config.options('dynvars'):
         if key == field_name+'.options':
             return val.split('|')
     
     # handle milestone special - skip completed milestones
     if field_name == 'milestone':
         return [''] + [m.name for m in
                 Milestone.select(self.env, include_completed=False)]
     
     # lookup select field
     for field in TicketSystem(self.env).get_ticket_fields():
         if field['name'] == field_name and 'options' in field:
             return field['options']
     return []
開發者ID:nyuhuhuu,項目名稱:trachacks,代碼行數:25,代碼來源:web_ui.py

示例5: test_remove_milestone

 def test_remove_milestone(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()
     milestone = Milestone(self.env)
     milestone.name = 'New target date'
     milestone.description = 'Lorem ipsum dolor sit amet'
     milestone.insert()
     self.assertEqual(2, len(self._get_docs()))
     rv, output = self._execute('fulltext remove milestone')
     self.assertEqual(expected, output)
     self.assertEqual(1, len(self._get_docs()))
開發者ID:CGI-define-and-primeportal,項目名稱:trac-plugin-solr,代碼行數:16,代碼來源:admin.py

示例6: _render_editor

    def _render_editor(self, req, db, milestone):
        # Suggest a default due time of 18:00 in the user's timezone
        default_due = datetime.now(req.tz).replace(hour=18, minute=0, second=0,
                                                   microsecond=0)
        if default_due <= datetime.now(utc):
            default_due += timedelta(days=1)
        
        data = {
            'milestone': milestone,
            'datetime_hint': get_datetime_format_hint(),
            'default_due': default_due,
            'milestone_groups': [],
        }

        if milestone.exists:
            req.perm(milestone.resource).require('MILESTONE_MODIFY')
            milestones = [m for m in Milestone.select(self.env, db=db)
                          if m.name != milestone.name
                          and 'MILESTONE_VIEW' in req.perm(m.resource)]
            data['milestone_groups'] = group_milestones(milestones,
                'TICKET_ADMIN' in req.perm)
        else:
            req.perm(milestone.resource).require('MILESTONE_CREATE')

        Chrome(self.env).add_wiki_toolbars(req)
        return 'milestone_edit.html', data, None
開發者ID:wiraqutra,項目名稱:photrackjp,代碼行數:26,代碼來源:roadmap.py

示例7: _render_milestone_list

 def _render_milestone_list(self, req):
     project_id = req.data['project_id']
     milestones = Milestone.select(self.env, project_id, include_completed=True)
     data = {
         'milestones': milestones,
     }
     return 'mdashboard.html', data, None
開發者ID:lexqt,項目名稱:EduTracMetrix,代碼行數:7,代碼來源:mdashboard.py

示例8: create_milestone

 def create_milestone(self, name, due=None, duration=20, db=None):
     """
     Creates a milestone with the given name and due
     date, the latter should be a datetime object
     """
     db, handle_ta = get_db_for_write(self.env, db)
     # Try to load the milestone first
     try:
         m = Milestone(self.env, name=name, db=db)
     except ResourceNotFound:
         # than we create it
         m = Milestone(self.env, db=db)
         m.name = name
         if due is not None and isinstance(due, datetime):
             dueo = due.toordinal() + duration
             m.due = mktime(datetime.fromordinal(dueo).timetuple())
         m.insert()
         if handle_ta:
             try:
                 db.commit()
                 # workaround for the fact that trac in 0.11.1 doesn't set exists correctly...
                 m._old_name = m.name
             except Exception, e:
                 self.env.log.warning(exception_to_unicode(e))
                 db.rollback()
開發者ID:djangsters,項目名稱:agilo,代碼行數:25,代碼來源:test_env_helper.py

示例9: _find_milestones

	def _find_milestones(self):
		"""Return a string list of Milestone names
		
		A smarter approach would return a dictionary of milestones:
		key = name
		value = tuple (name, due, completed, description)
		"""

		return [ "%s" % m.name for m in Milestone.select(self.env) ]
開發者ID:nyuhuhuu,項目名稱:trachacks,代碼行數:9,代碼來源:qatracker.py

示例10: process

    def process(self, commit, status, branch):
        self.closestatus = status

        milestones = [m.name for m in Milestone.select(self.env) if m.name != "unknown"]
        if branch.startswith("fixes/"):
            branch = branch[6:]
            milestones = [m for m in milestones if m.startswith(branch)]
        self.milestone = sorted(milestones)[-1]

        msg = commit["message"]
        self.env.log.debug("Processing Commit: %s", msg)
        msg = "%s \n Branch:    %s \n Changeset: %s" % (msg, branch, commit["id"])
        #        author = commit['author']['name']
        author = "Github"
        timestamp = datetime.now(utc)

        cmd_groups = command_re.findall(msg)
        self.env.log.debug("Function Handlers: %s" % cmd_groups)

        tickets = {}
        for cmd, tkts in cmd_groups:
            funcname = self.__class__._supported_cmds.get(cmd.lower(), "")
            self.env.log.debug("Function Handler: %s" % funcname)
            if funcname:
                for tkt_id in ticket_re.findall(tkts):
                    if (branch == "master") or branch.startswith("fixes/"):
                        tickets.setdefault(tkt_id, []).append(getattr(self, funcname))
        #                    disable this stuff for now, it causes duplicates on merges
        #                    proper implementation of this will require tracking commit hashes
        #                    else:
        #                        tickets.setdefault(tkt_id, []).append(self._cmdRefs)

        for tkt_id, cmds in tickets.iteritems():
            try:
                db = self.env.get_db_cnx()

                ticket = Ticket(self.env, int(tkt_id), db)
                for cmd in cmds:
                    cmd(ticket)

                # determine sequence number...
                cnum = 0
                tm = TicketModule(self.env)
                for change in tm.grouped_changelog_entries(ticket, db):
                    if change["permanent"]:
                        cnum += 1

                ticket.save_changes(author, msg, timestamp, db, cnum + 1)
                db.commit()

                tn = TicketNotifyEmail(self.env)
                tn.notify(ticket, newticket=0, modtime=timestamp)
            except Exception, e:
                import traceback

                traceback.print_exc(file=sys.stderr)
開發者ID:nilknarf0,項目名稱:extras,代碼行數:56,代碼來源:hook.py

示例11: _get_milestone

 def _get_milestone(self, req):
     """Extract the milestone from the referer url.  If not found then
     return the current milestone."""
     path = req.environ.get('HTTP_REFERER','')
     milestone_re = re.compile(r"/milestone/(?P<milestone>[^?]+)")
     match = milestone_re.search(path)
     if match:
         name = urllib.unquote(match.groupdict()['milestone'])
         for m in Milestone.select(self.env, include_completed=True):
             if m.name == name:
                 return m
         else:
             raise Exception("Milestone %s not found" % name)
     else:
         # milestone not found in url, so assume current milestone
         for m in Milestone.select(self.env, include_completed=False):
             return m
         else:
             raise Exception("No provided or current milestone")
     return None
開發者ID:svn2github,項目名稱:sumstatsplugin,代碼行數:20,代碼來源:web_ui.py

示例12: _render_confirm

    def _render_confirm(self, req, db, milestone):
        req.perm.assert_permission('MILESTONE_DELETE')

        req.hdf['title'] = 'Jalon %s' % milestone.name
        req.hdf['milestone'] = milestone_to_hdf(self.env, db, req, milestone)
        req.hdf['milestone.mode'] = 'delete'

        for idx,other in enumerate(Milestone.select(self.env, False, db)):
            if other.name == milestone.name:
                continue
            req.hdf['milestones.%d' % idx] = other.name
開發者ID:nyuhuhuu,項目名稱:trachacks,代碼行數:11,代碼來源:roadmap.py

示例13: _render_confirm

    def _render_confirm(self, req, db, milestone):
        req.perm(milestone.resource).require('MILESTONE_DELETE')

        milestones = [m for m in Milestone.select(self.env, db=db)
                      if m.name != milestone.name
                      and 'MILESTONE_VIEW' in req.perm(m.resource)]
        data = {
            'milestone': milestone,
            'milestone_groups': group_milestones(milestones,
                'TICKET_ADMIN' in req.perm)
        }
        return 'milestone_delete.html', data, None
開發者ID:wiraqutra,項目名稱:photrackjp,代碼行數:12,代碼來源:roadmap.py

示例14: _create_milestone

	def _create_milestone(self, name, duedate, description):
		m = Milestone(self.env)
		m.name = name
		m.description = description
		if duedate:
			if isinstance(duedate, type("")):
				m.due = parse_date(duedate)
			else:
				m.due = duedate
		m.insert()
開發者ID:nyuhuhuu,項目名稱:trachacks,代碼行數:10,代碼來源:qatracker.py

示例15: test_can_save_due_date

 def test_can_save_due_date(self):
     # Added when Trac 0.12 was released as the format of the timestamp has changed in 0.12
     milestone = Milestone(self.env)
     milestone.name = 'fnord'
     milestone.insert()
     # in trac 0.11.1, milestone._old_name is not set to "fnord" at
     # insert() time, only on init() or update()
     # so we need to reload the object to be able to run update() on it
     milestone = Milestone(self.env, name='fnord')
     
     expected_time = now().replace(microsecond=0)
     milestone.due = expected_time
     milestone.completed = expected_time
     milestone.update()
     
     loaded_milestone = Milestone(self.env, name='fnord')
     self.assert_equals(expected_time, loaded_milestone.due)
     self.assert_equals(expected_time, loaded_milestone.completed)
開發者ID:djangsters,項目名稱:agilo,代碼行數:18,代碼來源:agilomilestone_test.py


注:本文中的trac.ticket.Milestone類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。