예제 #1
0
    def process_request(self, req):
        req.perm.assert_permission('STRACTISTICS_VIEW')
        add_stylesheet(req, 'hw/css/stractistics.css')
        add_script(req, 'hw/javascript/swfobject.js')
        add_script(req, 'hw/javascript/prototype.js')
        add_script(req, 'hw/javascript/js-ofc-library/ofc.js')
        add_script(req, 'hw/javascript/js-ofc-library/data.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/area.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/bar.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/line.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/pie.js')
        add_script(req, 'hw/javascript/chart_reports.js')

        add_ctxtnav(req, 'Project Reports', req.href.stractistics("/project_reports"))
        add_ctxtnav(req, 'User Reports', req.href.stractistics("/user_reports"))

        #Reading options from trac.ini
        config = read_config_options(self.env.config)

        db = self.env.get_db_cnx()
        module = req.args.get('module', None)
        if module is not None and module == 'user_reports':
            template, data = user_reports(req, config, db)
        else:
            template, data = global_reports(req, config, db)
        data['json'] = {
            'repository_activity': json.dumps(data['repository_activity'].get_data()),
            'ticket_activity': json.dumps(data['ticket_activity'].get_data()),
            'wiki_activity': json.dumps(data['wiki_activity'].get_data()),
        }
        return template, data, None
예제 #2
0
    def _process_list(self, req, query, data, start_date, period):
        calendar = TicketCalendar(self.env, req)
        events = calendar.get_list_events(data['tickets'], start_date, period)
        data['ticketcalendar'] = {
            'events': events,
            'last_week': calendar.get_list_href(query,
                                                start_date - timedelta(days=7),
                                                period + 7),
            'next_week': calendar.get_list_href(query, start_date, period + 7),
            'create_ticket': calendar._create_ticket_item,
            'create_milestone': calendar._create_milestone_item,
        }
        data['title'] = _('Ticket Calendar (List view)')
        data['macro'] = \
            '[[TicketCalendar(type=list,duration=%s,query=%s,order=%s%s)]]' % (
            '%s/P%dD' % (start_date.strftime('%Y-%m-%d'), period),
            calendar.build_query_string(query.constraints),
            query.order,
            query.desc and ',desc=1' or '')

        add_ctxtnav(req, _('Calendar view'),
                    calendar.get_box_href(query, get_today(req.tz)))
        add_ctxtnav(req, _('List view'))

        return 'ticketcalendar_calendar.html', data, None
예제 #3
0
    def render_bookmarker(self, req):
        if 'action' in req.args and \
                req.args['action'] in self.nonbookmarkable_actions:
            return

        resource = self._get_resource_uri(req)
        bookmark = self.get_bookmark(req, resource)

        if bookmark:
            class_ = 'bookmark_on'
            title = 'Delete Bookmark'
            href = req.href.bookmark('delete', resource)
        else:
            class_ = 'bookmark_off'
            title = 'Bookmark this page'
            href = req.href.bookmark('add', resource)
        anchor = tag.a(u'\u200b', id='bookmark_this', class_=class_,
                       title=title, href=href, data_list=req.href.bookmark())
        req.chrome.setdefault('ctxtnav', []).insert(0, anchor)

        add_script(req, 'bookmark/js/tracbookmark.js')
        add_stylesheet(req, 'bookmark/css/tracbookmark.css')

        menu = self._get_bookmarks_menu(req)
        item = tag.span(tag.a('Bookmarks', href=req.href.bookmark()),
                        menu, id='bookmark_menu')
        add_ctxtnav(req, item)
예제 #4
0
파일: web_ui.py 프로젝트: pkdevbox/trac
    def _render_history(self, req, page):
        """Extract the complete history for a given page.

        This information is used to present a changelog/history for a given
        page.
        """
        if not page.exists:
            raise TracError(_("Page %(name)s does not exist", name=page.name))

        data = self._page_data(req, page, 'history')

        history = []
        for version, date, author, comment, ipnr in page.get_history():
            history.append({
                'version': version,
                'date': date,
                'author': author,
                'comment': comment,
                'ipnr': ipnr
            })
        data.update({
            'history': history,
            'resource': page.resource,
            'can_edit_comment': 'WIKI_ADMIN' in req.perm(page.resource)
        })
        add_ctxtnav(req, _("Back to %(wikipage)s", wikipage=page.name),
                    req.href.wiki(page.name))
        return 'history_view.html', data, None
예제 #5
0
    def render_reviewlink(self, req):
        #add_stylesheet(req, 'icucodetools/css/icuxtn.css')

        els = []

        ticket_mgr = TicketManager(self.compmgr)

        db = self.env.get_db_cnx()
        repos = self.env.get_repository()
        if not repos:
            raise TracError("Could not get repository for %s" % (req.authname))

        revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket'])

        if not revs:
            str = 'No commits.'
            li = tag.li(str)
            els.append(li)
        else:
            str = ' %d commits.' % len(revs)
            href = req.href.review(req.args['ticket'])
            a = tag.a('Review', href=href)
            li = tag.li(a + str)
            els.append(li)            
        
        ul = tag.ul(els, class_='review')
        className = ''
        title = "Reviews"
        add_ctxtnav(req, tag.span(tag.object(ul), id='icureview', title=title, class_=className))
예제 #6
0
    def post_process_request(self, req, template, data, content_type):
        if 'BROWSER_VIEW' in req.perm and re.match(r'^/browser', req.path_info):
            rm = RepositoryManager(self.env)
            path = req.args.get('path', '/')
            reponame, repo, path = rm.get_repository_by_path(path)
            if repo:
                if path == '/':
                    try:
                        convert_managed_repository(self.env, repo)
                        if 'REPOSITORY_FORK' in req.perm and repo.is_forkable:
                            href = req.href.repository('fork', repo.reponame)
                            add_ctxtnav(req, _("Fork"), href)
                        if (repo.owner == req.authname or
                            'REPOSITORY_ADMIN' in req.perm):
                            href = req.href.repository('modify', repo.reponame)
                            add_ctxtnav(req, _("Modify"), href)
                            href = req.href.repository('remove', repo.reponame)
                            add_ctxtnav(req, _("Remove"), href)
                        if repo.is_fork:
                            origin = repo.origin.reponame
                            add_ctxtnav(req, _("Forked from %(origin)s",
                                               origin=origin),
                                        req.href.browser(origin))
                    except:
                        pass
            else:
                if 'REPOSITORY_CREATE' in req.perm:
                    add_ctxtnav(req, _("Create Repository"),
                                req.href.repository('create'))

        return template, data, content_type
예제 #7
0
    def process_request(self, req):
        """Process the request."""

        id = int(req.args.get('id'))

        req.perm('ticket', id).require('TICKET_VIEW')

        if 'TICKET_REMINDER_MODIFY' not in req.perm and \
                'TICKET_ADMIN' not in req.perm:
            raise PermissionError('TICKET_REMINDER_MODIFY', req.perm._resource,
                                  self.env)

        ticket = Ticket(self.env, id)

        if 'cancel' in req.args:
            req.redirect(get_resource_url(self.env, ticket.resource, req.href))

        ticket_name = get_resource_name(self.env, ticket.resource)
        ticket_url = get_resource_url(self.env, ticket.resource, req.href)
        add_link(req, 'up', ticket_url, ticket_name)
        add_ctxtnav(req, _('Back to %(ticket)s', ticket=ticket_name),
                    ticket_url)

        add_stylesheet(req, 'ticketreminder/css/ticketreminder.css')

        if req.args['action'] == "addreminder":
            return self._process_add(req, ticket)
        elif req.args['action'] == "deletereminder":
            return self._process_delete(req, ticket)
        else:
            raise ValueError('Unknown action "%s"' % (req.args['action'], ))
예제 #8
0
    def process_request(self, req):
        #Retrieve the information needed to display in the /modifiedfiles/ page
        (ticket_id, files, deletedfiles, ticketsperfile, filestatus,
         conflictingtickets, ticketisclosed, revisions,
         ticketsdescription) = self.__process_ticket_request(req)
        #Pack the information to send to the html file
        data = {
            'ticketid': ticket_id,
            'files': files,
            'deletedfiles': deletedfiles,
            'ticketsperfile': ticketsperfile,
            'filestatus': filestatus,
            'conflictingtickets': conflictingtickets,
            'ticketisclosed': ticketisclosed,
            'revisions': revisions,
            'ticketsdescription': ticketsdescription
        }

        add_ctxtnav(req, 'Back to Ticket #%s' % ticket_id,
                    req.href.ticket(ticket_id))

        #Add the custom stylesheet
        add_stylesheet(req, 'common/css/timeline.css')
        add_stylesheet(req, 'tmf/css/ticketmodifiedfiles.css')
        add_script(req, 'tmf/js/ticketmodifiedfiles.js')
        return 'ticketmodifiedfiles.html', data, None
예제 #9
0
    def post_process_request(self, req, template, data, content_type):
        if 'BLOG_VIEW' not in req.perm:
            return (template, data, content_type)

        if '_blog_watch_message_' in req.session:
            add_notice(req, req.session['_blog_watch_message_'])
            del req.session['_blog_watch_message_']

        if req.authname == "anonymous":
            return (template, data, content_type)

        # FullBlogPlugin sets the blog_path arg in pre_process_request
        name = req.args.get('blog_path')
        if not name:
            return (template, data, content_type)

        klass = self.__class__.__name__

        attrs = SubscriptionAttribute.find_by_sid_class_and_target(
            self.env, req.session.sid, req.session.authenticated, klass, name)
        if attrs:
            add_ctxtnav(
                req, tag.a(_('Unwatch This'), href=req.href.blog_watch(name)))
        else:
            add_ctxtnav(req,
                        tag.a(_('Watch This'), href=req.href.blog_watch(name)))

        return (template, data, content_type)
예제 #10
0
파일: web_ui.py 프로젝트: starworldx/trac
    def _render_history(self, req, page):
        """Extract the complete history for a given page.

        This information is used to present a changelog/history for a given
        page.
        """
        if not page.exists:
            raise TracError(_("Page %(name)s does not exist", name=page.name))

        data = self._page_data(req, page, 'history')

        history = []
        for version, date, author, comment in page.get_history():
            history.append({
                'version': version,
                'date': date,
                'author': author,
                'comment': comment or ''
            })
        data.update({
            'history': history,
            'resource': page.resource,
            'can_edit_comment': 'WIKI_ADMIN' in req.perm(page.resource)
        })
        add_ctxtnav(req, _("Back to %(wikipage)s", wikipage=page.name),
                    req.href.wiki(page.name))
        return 'history_view.html', data
예제 #11
0
    def process_request(self, req):
        if req.method == 'POST' and req.args.get('leave'):
            group = Buildgroup(self.env, req.args.get('group'))
            group.leave(req)
            req.redirect(req.href.buildgroups())

        if req.method == 'POST' and req.args.get('join') and req.args.get(
                'group') and req.args.get('priority'):
            group = Buildgroup(self.env, req.args.get('group'))
            group.setPriority(req.args.get('priority'))
            group.join(req)
            req.redirect(req.href.buildgroups())

        add_stylesheet(req, 'redports/redports.css')
        add_ctxtnav(req, _('Environments'), req.href.buildgroups())
        add_ctxtnav(req, _('Statistics'), req.href.buildstats())

        if req.args.get('group'):
            filter = 'for %s' % req.args.get('group')
        else:
            filter = ''

        return ('buildgroups.html', {
            'buildgroups': BuildgroupsIterator(self.env, req),
            'availablegroups': AvailableBuildgroupsIterator(self.env, req),
            'buildqueue': GlobalBuildqueueIterator(self.env, req),
            'queuefilter': filter,
            'authenticated': (req.authname and req.authname != 'anonymous'),
            'authname': req.authname
        }, None)
예제 #12
0
    def render_voter(self, req):
        resource = self.normalise_resource(req.path_info)

        count = self.get_vote_counts(resource)

        add_stylesheet(req, 'fivestarvote/css/fivestarvote.css')

        names = ['', 'one', 'two', 'three', 'four', 'five']
        els = []
        percent = 0
        if count[2] > 0:
            percent = count[2] * 20

        str = "Currently %s/5 stars." % count[2]
        sign = '%'
        style = "width: %s%s" % (percent, sign)
        li = tag.li(str, class_='current-rating', style=style)
        els.append(li)
        for i in range(1, 6):
            className = "item %s-star" % names[i]
            href = "#"
            if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
                href = req.href.fivestarvote(i, resource)
                add_script(req, 'fivestarvote/js/fivestarvote.js', mimetype='text/javascript')
            a = tag.a(i, href=href, class_=className)
            li = tag.li(a)
            els.append(li)
        
        ul = tag.ul(els, class_='star-rating')
        className = ''
        if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
            className = 'active'
        title = "Current Vote: %s users voted for a total of %s" % (count[1], count[0]) 
        add_ctxtnav(req, tag.span(tag.object(ul), id='fivestarvotes', title=title, class_=className))
예제 #13
0
    def render_reviewlink(self, req):
        """Render the "143 commits." box that shows in the topnav."""
        #add_stylesheet(req, 'icucodetools/css/icuxtn.css')

        els = []

        ticket_mgr = TicketManager(self.compmgr)

        db = self.env.get_db_cnx()
        repos = self.env.get_repository()
        if not repos:
            raise TracError("Could not get repository for %s" % (req.authname))

        revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket'])

        if not revs:
            str = 'No commits.'
            li = tag.li(str)
            els.append(li)
        else:
            str = ' %d commits.' % len(revs)
            href = req.href.review(req.args['ticket'])
            a = tag.a('Review' + str, href=href)
            li = tag.li(a)
            els.append(li)            
        
        ul = tag.ul(els, class_='review')
        className = ''
        title = "Reviews"
        add_ctxtnav(req, tag.span(ul, id='icureview', title=title, class_=className))
예제 #14
0
    def _process_list(self, req, query, data, start_date, period):
        calendar = TicketCalendar(self.env, req)
        events = calendar.get_list_events(data['tickets'], start_date, period)
        data['ticketcalendar'] = {
            'events':
            events,
            'last_week':
            calendar.get_list_href(query, start_date - timedelta(days=7),
                                   period + 7),
            'next_week':
            calendar.get_list_href(query, start_date, period + 7),
            'create_ticket':
            calendar._create_ticket_item,
            'create_milestone':
            calendar._create_milestone_item,
        }
        data['title'] = _('Ticket Calendar (List view)')
        data['macro'] = \
            '[[TicketCalendar(type=list,duration=%s,query=%s,order=%s%s)]]' % (
            '%s/P%dD' % (start_date.strftime('%Y-%m-%d'), period),
            calendar.build_query_string(query.constraints),
            query.order,
            query.desc and ',desc=1' or '')

        add_ctxtnav(req, _('Calendar view'),
                    calendar.get_box_href(query, date.today()))
        add_ctxtnav(req, _('List view'))

        return 'ticketcalendar_calendar.html', data, None
예제 #15
0
    def process_request(self, req):
        parent_id = None
        parent_realm = req.args.get('realm')
        path = req.args.get('path')
        filename = None

        if not parent_realm or not path:
            raise HTTPBadRequest(_('Bad request'))
        if parent_realm == 'attachment':
            raise TracError(tag_("%(realm)s is not a valid parent realm",
                                 realm=tag.code(parent_realm)))

        parent_realm = Resource(parent_realm)
        action = req.args.get('action', 'view')
        if action == 'new':
            parent_id = path.rstrip('/')
        else:
            last_slash = path.rfind('/')
            if last_slash == -1:
                parent_id, filename = path, ''
            else:
                parent_id, filename = path[:last_slash], path[last_slash + 1:]

        parent = parent_realm(id=parent_id)
        if not resource_exists(self.env, parent):
            raise ResourceNotFound(
                _("Parent resource %(parent)s doesn't exist",
                  parent=get_resource_name(self.env, parent)))

        # Link the attachment page to parent resource
        parent_name = get_resource_name(self.env, parent)
        parent_url = get_resource_url(self.env, parent, req.href)
        add_link(req, 'up', parent_url, parent_name)
        add_ctxtnav(req, _('Back to %(parent)s', parent=parent_name),
                    parent_url)

        if not filename: # there's a trailing '/'
            if req.args.get('format') == 'zip':
                self._download_as_zip(req, parent)
            elif action != 'new':
                return self._render_list(req, parent)

        attachment = Attachment(self.env, parent.child(self.realm, filename))

        if req.method == 'POST':
            if action == 'new':
                data = self._do_save(req, attachment)
            elif action == 'delete':
                self._do_delete(req, attachment)
            else:
                raise HTTPBadRequest(_("Invalid request arguments."))
        elif action == 'delete':
            data = self._render_confirm_delete(req, attachment)
        elif action == 'new':
            data = self._render_form(req, attachment)
        else:
            data = self._render_view(req, attachment)

        add_stylesheet(req, 'common/css/code.css')
        return 'attachment.html', data, None
예제 #16
0
    def render_bookmarker(self, req):
        if 'action' in req.args and \
                req.args['action'] in self.nonbookmarkable_actions:
            return

        resource = self._get_resource_uri(req)
        bookmark = self.get_bookmark(req, resource)

        if bookmark:
            class_ = 'bookmark_on'
            title = _('Delete Bookmark')
            href = req.href.bookmark('delete', resource)
        else:
            class_ = 'bookmark_off'
            title = _('Bookmark this page')
            href = req.href.bookmark('add', resource)
        anchor = tag.a(u'\u200b',
                       id='bookmark_this',
                       class_=class_,
                       title=title,
                       href=href,
                       data_list=req.href.bookmark())
        req.chrome.setdefault('ctxtnav', []).insert(0, anchor)

        add_script(req, 'bookmark/js/tracbookmark.js')
        add_stylesheet(req, 'bookmark/css/tracbookmark.css')

        menu = self._get_bookmarks_menu(req)
        item = tag.span(tag.a(_('Bookmarks'), href=req.href.bookmark()),
                        menu,
                        id='bookmark_menu')
        add_ctxtnav(req, item)
예제 #17
0
	def post_process_request(self, req, template, data, content_type):
		from mastertickets.model import TicketLinks
		if req.path_info.startswith('/ticket'):
			ticket_id = req.path_info[8:]
			links = TicketLinks(self.env, ticket_id)
			if len(links.blocked_by) > 0:
				depgraph_href = req.href.depgraph(ticket_id)
			else:
				depgraph_href = None
			add_ctxtnav(req, "Dependency Graph", depgraph_href,
						"Dependency Graph")
		if req.path_info.startswith('/query'):
			query = {}
			percent_enc = re.compile('\%[0-9a-fA-F]')
			for line in data['query'].to_string().splitlines():
				if '=' in line:
					if line.startswith('query:?'):
						line = line[7:]
					line = re.sub(percent_enc, self._unescape, line)
					key, value = line.split('=')
					if key in query:
						query[key].append(value)
					else:
						query[key] = [value]

			add_ctxtnav(req, tag.a('Dependency Graph',
							href=req.href('depgraph', **query)))

		return template, data, content_type
예제 #18
0
 def post_process_request(self, req, template, data, content_type):
     env = self.env
     page = req.path_info
     realm, resource_id = resource_from_page(env, page)
     # break (recursive) search for form in forms realm
     if tfpageRE.match(page) == None and resource_id is not None:
         if page == '/wiki' or page == '/wiki/':
             page = '/wiki/WikiStart'
         form = Form(env, realm, resource_id)
         if 'FORM_VIEW' in req.perm(form.resource):
             if len(form.siblings) == 0:
                 # no form record found for this parent resource
                 href = req.href.form()
                 return (template, data, content_type)
             elif form.resource.id is not None:
                 # single form record found
                 href = req.href.form(form.resource.id)
             else:
                 # multiple form records found
                 href = req.href.form(action='select', realm=realm,
                                      resource_id=resource_id)
             add_ctxtnav(req, _("Form details"), href=href,
                         title=_("Review form data"))
     elif page.startswith('/form') and not resource_id == '':
         form = Form(env, form_id=resource_id)
         parent = form.resource.parent
         if len(form.siblings) > 1:
             href = req.href.form(action='select', realm=parent.realm,
                                  resource_id=parent.id)
             add_ctxtnav(req, _("Back to forms list"), href=href)
     return (template, data, content_type)
예제 #19
0
    def post_process_request(self, req, template, data, content_type):
        """Adds a 'Lint' context navigation menu item in source view and
           links to the annotation in report summary.
        """
        if not 'BUILD_VIEW' in req.perm:
            return template, data, content_type
        resource = data and data.get('context') \
                        and data.get('context').resource or None
        if not resource or not isinstance(resource, Resource):
            pass
        elif resource.realm == 'source' and data.get('file') \
                    and not req.args.get('annotate') == 'lint':
            add_ctxtnav(req, 'Lint',
                    title='Annotate file with lint result '
                          'data (if available)',
                    href=req.href.browser(resource.id,
                        annotate='lint', rev=data.get('rev')))

        elif resource.realm == 'build' and data.get('build', {}).get('steps'):
            # in report summary, set link to lint annotation
            steps = data['build']['steps']
            rev = data['build']['rev']
            for step in steps:
                for report in step.get('reports', []):
                    if report.get('category') != 'lint':
                        continue
                    for item in report.get('data', {}).get('data', []):
                        href = item.get('href')
                        if not href or 'annotate' in href:
                            continue
                        sep = ('?' in href) and '&' or '?'
                        param = {'rev': rev, 'annotate': 'lint'}
                        href = href + sep + unicode_urlencode(param)
                        item['href'] = href + '#Lint1'
        return template, data, content_type
예제 #20
0
 def post_process_request(self, req, template, data, content_type):
     if req.perm.has_permission('REVTREE_VIEW'):
         url_parts = filter(None, req.path_info.split(u'/'))
         if url_parts and (url_parts[0] in self.contexts):
             add_ctxtnav(req, 'Revtree' % self.contexts, 
                         href=req.href.revtree())
     return (template, data, content_type)
예제 #21
0
    def process_request(self, req):
        """Process the request."""

        id = int(req.args.get('id'))

        req.perm('ticket', id).require('TICKET_VIEW')

        if 'TICKET_REMINDER_MODIFY' not in req.perm and \
                'TICKET_ADMIN' not in req.perm:
            raise PermissionError('TICKET_REMINDER_MODIFY',
                                  req.perm._resource, self.env)

        ticket = Ticket(self.env, id)

        if 'cancel' in req.args:
            req.redirect(get_resource_url(self.env, ticket.resource, req.href))

        ticket_name = get_resource_name(self.env, ticket.resource)
        ticket_url = get_resource_url(self.env, ticket.resource, req.href)
        add_link(req, 'up', ticket_url, ticket_name)
        add_ctxtnav(req, _('Back to %(ticket)s', ticket=ticket_name),
                    ticket_url)

        add_stylesheet(req, 'ticketreminder/css/ticketreminder.css')

        if req.args['action'] == "addreminder":
            return self._process_add(req, ticket)
        elif req.args['action'] == "deletereminder":
            return self._process_delete(req, ticket)
        else:
            raise ValueError('Unknown action "%s"' % (req.args['action'],))
예제 #22
0
    def post_process_request(self, req, template, data, content_type):
        if 'BLOG_VIEW' not in req.perm:
            return (template, data, content_type)

        if '_blog_watch_message_' in req.session:
            add_notice(req, req.session['_blog_watch_message_'])
            del req.session['_blog_watch_message_']

        if req.authname == "anonymous":
            return (template, data, content_type)

        # FullBlogPlugin sets the blog_path arg in pre_process_request
        name = req.args.get('blog_path')
        if not name:
            return (template, data, content_type)

        klass = self.__class__.__name__

        attrs = SubscriptionAttribute.find_by_sid_class_and_target(
            self.env, req.session.sid, req.session.authenticated, klass, name)
        if attrs:
            add_ctxtnav(req, tag.a(_('Unwatch This'),
                href=req.href.blog_watch(name)))
        else:
            add_ctxtnav(req, tag.a(_('Watch This'),
                href=req.href.blog_watch(name)))

        return (template, data, content_type)
예제 #23
0
    def post_process_request(self, req, template, data, content_type):
        from mastertickets.model import TicketLinks
        if req.path_info.startswith('/ticket'):
            ticket_id = req.path_info[8:]
            links = TicketLinks(self.env, ticket_id)
            if len(links.blocked_by) > 0:
                depgraph_href = req.href.depgraph(ticket_id)
            else:
                depgraph_href = None
            add_ctxtnav(req, "Dependency Graph", depgraph_href,
                        "Dependency Graph")
        if req.path_info.startswith('/query'):
            query = {}
            percent_enc = re.compile('\%[0-9a-fA-F]')
            for line in data['query'].to_string().splitlines():
                if '=' in line:
                    if line.startswith('query:?'):
                        line = line[7:]
                    line = re.sub(percent_enc, self._unescape, line)
                    key, value = line.split('=')
                    if key in query:
                        query[key].append(value)
                    else:
                        query[key] = [value]

            add_ctxtnav(
                req,
                tag.a('Dependency Graph', href=req.href('depgraph', **query)))

        return template, data, content_type
    def filter_stream(self, req, method, filename, stream, data):
        if filename == 'browser.html' and req.method == 'GET':

            # we can only work from the 'dir' view at the moment
            if data.get('file'):
                return stream

            # TODO check that contextmenu's InternalNameHolder is enabled, as our js needs it?
            add_stylesheet(req, 'sourcesharer/filebox.css')
            add_javascript(req, 'sourcesharer/filebox.js')
            # Render the filebox template for stream insertion

            # TODO introduce a new interface to allow putting extra buttons into this filebox?
            tmpl = TemplateLoader(self.get_templates_dirs()).load('filebox.html')
            filebox = tmpl.generate(href=req.href, reponame=data['reponame'] or '', rev=data['rev'], files=[])
            # Wrap and float dirlist table, add filebox div
            # TODO change the id names, left/right seems a bit generic to assume we can have to ourselves
            stream |= Transformer('//table[@id="dirlist"]').wrap(tag.div(id="outer",style="clear:both")).wrap(tag.div(id="left"))
            stream |= Transformer('//div[@id="outer"]').append(tag.div(filebox, id="right"))

            is_svn_repo = False
            if 'repos' in data:
                is_svn_repo = isinstance(data.get('repos'), 
                                    (SvnCachedRepository, 
                                    SubversionRepository)) or False
            if is_svn_repo:
                add_ctxtnav(req, tag.a(_(tag.i(class_="fa fa-envelope-o")), " Send", href="", title=_("Send selected files"), id='share-files', class_='alt-button share-files-multiple'),
                    category='ctxtnav', order=10)

        return stream
예제 #25
0
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type
            tkt = data['ticket']
            links = TicketLinks(self.env, tkt)

            for i in links.blocked_by:
                if Ticket(self.env, i)['status'] != 'closed':
                    add_script(req, 'mastertickets/disable_resolve.js')
                    break

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, 'Depgraph',
                            req.href.depgraph('ticket', tkt.id))

            for change in data.get('changes', {}):
                if not change.has_key('fields'):
                    continue
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        if field_data['new'].strip():
                            new = set(
                                [int(n) for n in field_data['new'].split(',')])
                        else:
                            new = set()
                        if field_data['old'].strip():
                            old = set(
                                [int(n) for n in field_data['old'].split(',')])
                        else:
                            old = set()
                        add = new - old
                        sub = old - new
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join(
                                    [unicode(n) for n in sorted(add)])))
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join(
                                    [unicode(n) for n in sorted(sub)])))
                            elms.append(u' removed')
                        field_data['rendered'] = elms

        #add a link to generate a dependency graph for all the tickets in the milestone
        if req.path_info.startswith('/milestone/'):
            if not data:
                return template, data, content_type
            milestone = data['milestone']
            add_ctxtnav(req, 'Depgraph',
                        req.href.depgraph('milestone', milestone.name))

        return template, data, content_type
 def post_process_request(self, req, template, data, content_type):
     ticket_id = req.args.get('id')
     if template == 'ticket.html' and ticket_id:
         ticket_url = req.abs_href('ticket', ticket_id)
         fs_url = u'http://www.freedomsponsors.org/core/issue/sponsor?trackerURL=%s' % ticket_url
         text = u'Sponsor #%s in FreedomSponsors.org!' % ticket_id
         add_ctxtnav(req, tag.a(text, href=fs_url, target='_blank'))
     return template, data, content_type
예제 #27
0
    def post_process_request(self, req, template, data, content_type):
        add_script(req, 'datasaver/datasaver.js')
        if req.locale is not None: 
 	    add_script(req, 'datasaver/lang_js/%s.js' % req.locale)
        add_stylesheet(req, 'datasaver/datasaver.css')
        add_ctxtnav(req, tag.a(_('Restore Form') , id='datasaver_restorer',
                    href='javascript:datasaver_restore()'))
        return (template, data, content_type)
예제 #28
0
 def post_process_request(self, req, template, data, content_type):
     if req.perm.has_permission('REVTREE_VIEW'):
         url_parts = filter(None, req.path_info.split(u'/'))
         if url_parts and (url_parts[0] in self.contexts):
             add_ctxtnav(req,
                         'Revtree' % self.contexts,
                         href=req.href.revtree())
     return (template, data, content_type)
예제 #29
0
    def process_ticket(self, req):
        """process a request to /hours/<ticket number>"""

        # get the ticket
        path = req.path_info.rstrip('/')
        ticket_id = int(path.split('/')[-1])  # matches a ticket number
        ticket = Ticket(self.env, ticket_id)

        if req.method == 'POST':
            if 'addhours' in req.args:
                return self.do_ticket_change(req, ticket)
            if 'edithours' in req.args:
                return self.edit_ticket_hours(req, ticket)

        # XXX abstract date stuff as this is used multiple places
        now = datetime.now()
        months = [(i, calendar.month_name[i], i == now.month)
                  for i in range(1, 13)]
        years = range(now.year, now.year - 10, -1)
        days = [(i, i == now.day) for i in range(1, 32)]

        time_records = self.get_ticket_hours(ticket.id)
        time_records.sort(key=lambda x: x['time_started'], reverse=True)

        # add additional data for the template
        total = 0
        for record in time_records:
            record['date_started'] = self.format_date(record['time_started'])
            record['hours_worked'], record[
                'minutes_worked'] = self.format_hours_and_minutes(
                    record['seconds_worked'])
            total += record['seconds_worked']
        total = self.format_hours(total)

        data = {
            'can_add_hours': req.perm.has_permission('TICKET_ADD_HOURS'),
            'can_add_others_hours': req.perm.has_permission('TRAC_ADMIN'),
            'days': days,
            'months': months,
            'years': years,
            'users': get_all_users(self.env),
            'total': total,
            'ticket': ticket,
            'time_records': time_records
        }

        # return the rss, if requested
        if req.args.get('format') == 'rss':
            return self.tickethours2rss(req, data)

        # add rss link
        rss_href = req.href(req.path_info, format='rss')
        add_link(req, 'alternate', rss_href, _('RSS Feed'),
                 'application/rss+xml', 'rss')
        add_ctxtnav(req, 'Back to Ticket #%s' % ticket_id,
                    req.href.ticket(ticket_id))

        return ('hours_ticket.html', data, 'text/html')
예제 #30
0
 def post_process_request(self, req, template, data, content_type):
     if (req.path_info.startswith('/wiki') or req.path_info == '/') and \
             data and 'page' in data:
         page = data['page']
         perm = req.perm(page.resource)
         if 'WIKI_CREATE' in perm or 'WIKI_ADMIN' in perm:
             href = req.href('wikicreate')
             add_ctxtnav(req, _('Create'), href)
     return template, data, content_type
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type
            tkt = data['ticket']
            links = TicketLinks(self.env, tkt)
            
            for i in links.blocked_by:
                if Ticket(self.env, i)['status'] != 'closed':
                    add_script(req, 'mastertickets/disable_resolve.js')
                    break

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))
            
            for change in data.get('changes', {}):
                if not change.has_key('fields'):
                    continue
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        if field_data['new'].strip():
                            new = set([int(n) for n in field_data['new'].split(',')])
                        else:
                            new = set()
                        if field_data['old'].strip():
                            old = set([int(n) for n in field_data['old'].split(',')])
                        else:
                            old = set()
                        add = new - old
                        sub = old - new
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(add)]))
                            )
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
                            )
                            elms.append(u' removed')
                        field_data['rendered'] = elms
            
        #add a link to generate a dependency graph for all the tickets in the milestone
        if req.path_info.startswith('/milestone/'):
            if not data:
                return template, data, content_type
            milestone=data['milestone']
            add_ctxtnav(req, 'Depgraph', req.href.depgraph('milestone', milestone.name))


        return template, data, content_type
예제 #32
0
 def render_watcher(self, req):
     if not self.ctxtnav_names:
         return
     realm, target = self.path_info_to_realm_target(req.path_info)
     sess = req.session
     if self.is_watching(sess.sid, sess.authenticated, realm, target):
         action_name = len(self.ctxtnav_names) >= 2 and self.ctxtnav_names[1] or "Unwatch This"
     else:
         action_name = len(self.ctxtnav_names) and self.ctxtnav_names[0] or "Watch This"
     add_ctxtnav(req, tag.a(_(action_name), href=req.href.watch(realm, target)))
예제 #33
0
 def post_process_request(self, req, template, data, content_type):
     # ページのアドレスは/ticket/1
     if (req.path_info.startswith('/ticket/')) and data:
         # チケット表示ページの場合の処理
         # 依存ページへのリンクを作成し,このページで処理するには時間がかかるものは次のページで表示します
         href = req.href.dependency(req.path_info)
         add_ctxtnav(req, LABEL_DEPEND_PAGE, href)
         field_values = self.get_dependency_field_values(data['ticket'])
         data['tracdependency'] = {'field_values': field_values}
     return template, data, content_type
예제 #34
0
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type
            tkt = data['ticket']
            self.pm.check_component_enabled(self, pid=tkt.pid)
            links = TicketLinks(self.env, tkt)

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, _('Depgraph'), req.href.depgraph(get_resource_url(self.env, tkt.resource)))

            for change in data.get('changes', {}):
                if not change.has_key('fields'):
                    continue
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        vals = {}
                        for i in ('new', 'old'):
                            if isinstance(field_data[i], basestring):
                                val = field_data[i].strip()
                            else:
                                val = ''
                            if val:
                                vals[i] = set([int(n) for n in val.split(',')])
                            else:
                                vals[i] = set()
                        add = vals['new'] - vals['old']
                        sub = vals['old'] - vals['new']
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(add)]))
                            )
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
                            )
                            elms.append(u' removed')
                        field_data['rendered'] = elms

        #add a link to generate a dependency graph for all the tickets in the milestone
        if req.path_info.startswith('/milestone/'):
            if not data or not 'milestone' in data:
                return template, data, content_type
            milestone=data['milestone']
            self.pm.check_component_enabled(self, pid=milestone.pid)
            add_ctxtnav(req, _('Depgraph'), req.href.depgraph(get_resource_url(self.env, milestone.resource)))


        return template, data, content_type
예제 #35
0
    def process_request(self, req):
        req.perm.assert_permission('TICKET_VIEW')

        if 'id' in req.args.keys():
            try:
                ticket = int(req.args.get('id'))
            except ValueError:
                raise TracError('Need integer ticket id.')

            sql = ("SELECT 1 FROM ticket WHERE id=%s" % ticket)

            db = self.env.get_db_cnx()
            cursor = db.cursor()
            cursor.execute(sql)
            row = cursor.fetchone()
            if not row:
                raise TracError(
                    'Cannot build dependency graph for non-existent ticket %d.'
                    % ticket)

            depth = -1
            for key in req.args.keys():
                if key == 'depth':
                    depth = req.args[key]

            options = '%s,%s' % (ticket, depth)
            add_ctxtnav(req, 'Back to Ticket #%s' % ticket,
                        req.href.ticket(ticket))
            title = 'Ticket #%s Dependency Graph' % ticket
            headline = 'Dependency Graph for Ticket #%s' % ticket
        else:
            constraints = {}
            for key in req.args.keys():
                if isinstance(req.args[key], (list, tuple)):
                    constraints[key] = '|'.join(req.args[key])
                else:
                    constraints[key] = req.args[key]
            options = 'query:' + '&'.join(key + '=' + constraints[key]
                                          for key in constraints)

            title = 'Ticket query Dependency Graph'
            headline = 'Dependency Graph for Query'
            add_ctxtnav(req, 'Back to query', req.href('query', **req.args))

        data = {}

        context = Context.from_request(req, '')
        formatter = Formatter(self.env, context)
        graph = DepGraphMacro(self.env).expand_macro(formatter, 'DepGraph',
                                                     options)
        data['title'] = title
        data['headline'] = headline
        data['depgraph'] = Markup(graph)

        return 'depgraph.html', data, None
예제 #36
0
    def post_process_request(self, req, template, data, content_type):

        if req.path_info.startswith('/wiki') or req.path_info == '/':
            action = req.args.get('action', 'view')

            if action == 'view' and data and 'page' in data:
                page = data['page']
                if 'WIKI_MODIFY' in req.perm:
                    href = req.href.wiki(page.name, action='edit')
                    add_ctxtnav(req, _('Edit'), href)
        return template, data, content_type
예제 #37
0
 def post_process_request(self, req, template, data, content_type):
     add_script(req, 'datasaver/datasaver.js')
     if req.locale is not None:
         add_script(req, 'datasaver/lang_js/%s.js' % req.locale)
     add_stylesheet(req, 'datasaver/datasaver.css')
     add_ctxtnav(
         req,
         tag.a(_('Restore Form'),
               id='datasaver_restorer',
               href='javascript:datasaver_restore()'))
     return (template, data, content_type)
예제 #38
0
 def post_process_request(self, req, template, data, content_type):
     if (req.path_info.startswith('/wiki') or req.path_info == '/') and data:
         page = data.get('page')
         if not page:
             return template, data, content_type
         perm = req.perm(page.resource)
         if 'WIKI_RENAME' in perm or 'WIKI_ADMIN' in perm:
             href = req.href.admin('general','wikirename', 
                                   redirect='1', src_page=page.name)
             add_ctxtnav(req, 'Rename page', href)
     return template, data, content_type
예제 #39
0
파일: hours.py 프로젝트: nyuhuhuu/trachacks
    def process_ticket(self, req):
        """process a request to /hours/<ticket number>"""

        # get the ticket
        path = req.path_info.rstrip("/")
        ticket_id = int(path.split("/")[-1])  # matches a ticket number
        ticket = Ticket(self.env, ticket_id)

        if req.method == "POST":
            if "addhours" in req.args:
                return self.do_ticket_change(req, ticket)
            if "edithours" in req.args:
                return self.edit_ticket_hours(req, ticket)

        # XXX abstract date stuff as this is used multiple places
        now = datetime.now()
        months = [(i, calendar.month_name[i], i == now.month) for i in range(1, 13)]
        years = range(now.year, now.year - 10, -1)
        days = [(i, i == now.day) for i in range(1, 32)]

        time_records = self.get_ticket_hours(ticket.id)
        time_records.sort(key=lambda x: x["time_started"], reverse=True)

        # add additional data for the template
        total = 0
        for record in time_records:
            record["date_started"] = self.format_date(record["time_started"])
            record["hours_worked"], record["minutes_worked"] = self.format_hours_and_minutes(record["seconds_worked"])
            total += record["seconds_worked"]
        total = self.format_hours(total)

        data = {
            "can_add_hours": req.perm.has_permission("TICKET_ADD_HOURS"),
            "can_add_others_hours": req.perm.has_permission("TRAC_ADMIN"),
            "days": days,
            "months": months,
            "years": years,
            "users": get_all_users(self.env),
            "total": total,
            "ticket": ticket,
            "time_records": time_records,
        }

        # return the rss, if requested
        if req.args.get("format") == "rss":
            return self.tickethours2rss(req, data)

        # add rss link
        rss_href = req.href(req.path_info, format="rss")
        add_link(req, "alternate", rss_href, _("RSS Feed"), "application/rss+xml", "rss")
        add_ctxtnav(req, "Back to Ticket #%s" % ticket_id, req.href.ticket(ticket_id))

        return ("hours_ticket.html", data, "text/html")
예제 #40
0
 def post_process_request(self, req, template, data, content_type):
     # ページのアドレスは/ticket/1
     if (req.path_info.startswith('/ticket/')) and data:
         # チケット表示ページの場合の処理
         # 依存ページへのリンクを作成し,このページで処理するには時間がかかるものは次のページで表示します
         href = req.href.dependency(req.path_info)
         add_ctxtnav(req, LABEL_DEPEND_PAGE, href)
         field_values = self.get_dependency_field_values(data['ticket'])
         data['tracdependency'] = {
             'field_values': field_values
         }
     return template, data, content_type
예제 #41
0
	def process_request(self, req):
		req.perm.assert_permission('TICKET_VIEW')

		if 'id' in req.args.keys():
			try:
				ticket = int(req.args.get('id'))
			except ValueError:
				raise TracError('Need integer ticket id.')

			sql = ("SELECT 1 FROM ticket WHERE id=%s" %ticket)
		
			db = self.env.get_db_cnx()
			cursor = db.cursor()
			cursor.execute(sql)
			row = cursor.fetchone()
			if not row:
				raise TracError('Cannot build dependency graph for non-existent ticket %d.' % ticket)

			depth  = -1
			for key in req.args.keys():
				if key == 'depth':
					depth = req.args[key]

			options = '%s,%s' %(ticket, depth)
			add_ctxtnav(req, 'Back to Ticket #%s'%ticket,
							req.href.ticket(ticket))
			title = 'Ticket #%s Dependency Graph' %ticket
			headline = 'Dependency Graph for Ticket #%s' %ticket
		else:
			constraints = {}
			for key in req.args.keys():
				if isinstance(req.args[key], (list, tuple)):
					constraints[key] = '|'.join(req.args[key])
				else:
					constraints[key] = req.args[key]
			options = 'query:' + '&'.join(key + '=' +
						constraints[key] for key in constraints)

			title = 'Ticket query Dependency Graph'
			headline = 'Dependency Graph for Query'
			add_ctxtnav(req, 'Back to query', req.href('query', **req.args))
		
		data = {}

		context = Context.from_request(req, '')
		formatter = Formatter(self.env, context)
		graph = DepGraphMacro(self.env).expand_macro(formatter,
					'DepGraph', options)
		data['title'] = title
		data['headline'] = headline
		data['depgraph'] = Markup(graph)

		return 'depgraph.html', data, None
예제 #42
0
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            tkt = data['ticket']
            links = TicketLinks(self.env, tkt)

            for i in links.blocked_by:
                if Ticket(self.env, i)['status'] != 'closed':
                    add_script(req, 'mastertickets/disable_resolve.js')
                    break

            data['mastertickets'] = {
                'field_values': {
                    'blocking': linkify_ids(self.env, req, links.blocking),
                    'blockedby': linkify_ids(self.env, req, links.blocked_by),
                },
            }

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))

            for change in data.get('changes', []):
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        if field_data['new'].strip():
                            new = set(
                                [int(n) for n in field_data['new'].split(',')])
                        else:
                            new = set()
                        if field_data['old'].strip():
                            old = set(
                                [int(n) for n in field_data['old'].split(',')])
                        else:
                            old = set()
                        add = new - old
                        sub = old - new
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join(
                                    [unicode(n) for n in sorted(add)])))
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join(
                                    [unicode(n) for n in sorted(sub)])))
                            elms.append(u' removed')
                        field_data['rendered'] = elms

        return template, data, content_type
예제 #43
0
 def post_process_request(self, req, template, data, content_type):
     if req.perm.has_permission('QUIET_MODE') and \
             (req.path_info.startswith('/ticket') or
              req.path_info.startswith('/newticket') or
              req.path_info.startswith('/query') or
              req.path_info.startswith('/report')):
         href = req.href(MODE, 'toggle')
         a = tag.a(_(self._get_label(req)), href=href, id=MODE)
         add_ctxtnav(req, a)
         add_script(req, 'quiet/quiet.js')
         add_stylesheet(req, 'quiet/quiet.css')
         add_script_data(req, {'quiet': {'toggle': MODE, 'listen': LISTEN}})
     return template, data, content_type
예제 #44
0
    def _process_box(self, req, query, data, month):
        calendar = TicketCalendar(self.env, req)
        content = calendar.gen_calendar(data['tickets'], query, month)

        data['title'] = _('Ticket Calendar (Calendar view)')
        data['month'] = month.strftime('%Y-%m')
        data['content'] = content
        data['ticketcalendar'] = {'mode': 'calendar'}

        add_ctxtnav(req, _('Calendar view'))
        add_ctxtnav(req, _('List view'), calendar.get_list_href(query))

        return 'ticketcalendar_calendar.html', data, None
예제 #45
0
 def render_watcher(self, req):
     if not self.ctxtnav_names:
         return
     resource = self.normalise_resource(req.path_info)
     parts = resource.split("/", 1)
     if len(parts) < 2:
         return
     realm, resource = parts
     if self.is_watching(req.session.sid, not req.authname == "anonymous", realm, resource):
         action_name = len(self.ctxtnav_names) >= 2 and self.ctxtnav_names[1] or "Unwatch This"
     else:
         action_name = len(self.ctxtnav_names) and self.ctxtnav_names[0] or "Watch This"
     add_ctxtnav(req, tag.a(action_name, href=req.href.watch(realm, resource)))
예제 #46
0
 def post_process_request(self, req, template, data, content_type):
     """ Adds a 'Coverage' context navigation menu item. """
     resource = data and data.get('context') \
                     and data.get('context').resource or None
     if resource and isinstance(resource, Resource) \
                 and resource.realm=='source' and data.get('file') \
                 and not req.args.get('annotate'):
         add_ctxtnav(req, 'Coverage',
                 title='Annotate file with test coverage '
                       'data (if available)',
                 href=req.href.browser(resource.id, 
                     annotate='coverage', rev=data.get('rev')))
     return template, data, content_type
예제 #47
0
    def process_request(self, req):
        #Retrieve the information needed to display in the /modifiedfiles/ page
        (id, files, deletedfiles, ticketsperfile, filestatus, conflictingtickets, ticketisclosed, revisions, ticketsdescription) = self.__process_ticket_request(req)
        #Pack the information to send to the html file
        data = {'ticketid':id, 'files':files, 'deletedfiles':deletedfiles, 'ticketsperfile':ticketsperfile, 'filestatus':filestatus, 'conflictingtickets':conflictingtickets, 'ticketisclosed':ticketisclosed, 'revisions':revisions, 'ticketsdescription':ticketsdescription}

        add_ctxtnav(req, 'Back to Ticket #%s' % id, req.href.ticket(id))

        #Add the custom stylesheet
        add_stylesheet(req, 'common/css/timeline.css')
        add_stylesheet(req, 'tmf/css/ticketmodifiedfiles.css')
        add_script(req, 'tmf/js/ticketmodifiedfiles.js')
        return 'ticketmodifiedfiles.html', data, None
예제 #48
0
    def _process_box(self, req, query, data, month):
        calendar = TicketCalendar(self.env, req)
        content = calendar.gen_calendar(data['tickets'], query, month)

        data['title'] = _('Ticket Calendar (Calendar view)')
        data['month'] = month.strftime('%Y-%m')
        data['content'] = content
        data['ticketcalendar'] = {'mode': 'calendar'}

        add_ctxtnav(req, _('Calendar view'))
        add_ctxtnav(req, _('List view'), calendar.get_list_href(query))

        return 'ticketcalendar_calendar.html', data, None
예제 #49
0
 def render_watcher(self, req):
     if not self.ctxtnav_names:
         return
     realm, target = self.path_info_to_realm_target(req.path_info)
     sess = req.session
     if self.is_watching(sess.sid, sess.authenticated, realm, target):
         action_name = len(self.ctxtnav_names) >= 2 and \
                 self.ctxtnav_names[1] or 'Unwatch This'
     else:
         action_name = len(self.ctxtnav_names) and \
                 self.ctxtnav_names[0] or 'Watch This'
     add_ctxtnav(req,
                 tag.a(_(action_name), href=req.href.watch(realm, target)))
예제 #50
0
 def post_process_request(self, req, template, data, content_type):
     if req.perm.has_permission('QUIET_MODE') and \
        (req.path_info.startswith('/ticket') or \
         req.path_info.startswith('/newticket') or \
         req.path_info.startswith('/changeset') or \
         req.path_info.startswith('/query') or \
         req.path_info.startswith('/report')):
         href = req.href(MODE,'toggle')
         a = tag.a(self._get_label(req), href=href, id=MODE)
         add_ctxtnav(req, a)
         add_script(req, '/quiet/quiet.html')
         add_script(req, 'quiet/quiet.js')
         add_stylesheet(req, 'quiet/quiet.css')
     return template, data, content_type
예제 #51
0
    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            tkt = data['ticket']
            links = TicketLinks(self.env, tkt)
            
            for i in links.blocked_by:
                if Ticket(self.env, i)['status'] != 'closed':
                    add_script(req, 'mastertickets/disable_resolve.js')
                    break

            data['mastertickets'] = {
                'field_values': {
                    'blocking': linkify_ids(self.env, req, links.blocking),
                    'blockedby': linkify_ids(self.env, req, links.blocked_by),
                },
            }
            
            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))
            
            for change in data.get('changes', []):
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        if field_data['new'].strip():
                            new = set([int(n) for n in field_data['new'].split(',')])
                        else:
                            new = set()
                        if field_data['old'].strip():
                            old = set([int(n) for n in field_data['old'].split(',')])
                        else:
                            old = set()
                        add = new - old
                        sub = old - new
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(add)]))
                            )
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
                            )
                            elms.append(u' removed')
                        field_data['rendered'] = elms
            
        return template, data, content_type
예제 #52
0
 def post_process_request(self, req, template, data, content_type):
     if (req.path_info.startswith('/wiki')
             or req.path_info == '/') and data:
         page = data.get('page')
         if not page:
             return template, data, content_type
         perm = req.perm(page.resource)
         if 'WIKI_RENAME' in perm or 'WIKI_ADMIN' in perm:
             href = req.href.admin('general',
                                   'wikirename',
                                   redirect='1',
                                   src_page=page.name)
             add_ctxtnav(req, 'Rename page', href)
     return template, data, content_type
예제 #53
0
 def _ctxt_nav(self, req):
     add_ctxtnav(req, 'Buildbot Server', self.get_buildbot_url())
     add_ctxtnav(req, 'Waterfall display',
                 self.get_buildbot_url() + '/waterfall')
     add_ctxtnav(req, 'Grid display', self.get_buildbot_url() + '/grid')
     add_ctxtnav(req, 'Latest Build',
                 self.get_buildbot_url() + '/one_box_per_builder')
예제 #54
0
    def _render_view(self, req, version):
        milestones = []
        tickets = []
        milestone_stats = []

        for name, in self.env.db_query(
                """
                SELECT name FROM milestone
                 INNER JOIN milestone_version ON (name = milestone)
                WHERE version = %s
                ORDER BY due
                """, (version.name, )):
            milestone = Milestone(self.env, name)
            milestones.append(milestone)

            mtickets = get_tickets_for_milestone(self.env, milestone.name,
                                                 'owner')
            mtickets = apply_ticket_permissions(self.env, req, mtickets)
            tickets += mtickets
            stat = get_ticket_stats(self.milestone_stats_provider, mtickets)
            milestone_stats.append(
                milestone_stats_data(self.env, req, stat, milestone.name))

        stats = get_ticket_stats(self.version_stats_provider, tickets)
        interval_hrefs = version_interval_hrefs(
            self.env, req, stats, [milestone.name for milestone in milestones])

        version.resource = Resource('version', version.name)
        context = web_context(req, version.resource)

        version.is_released = version.time \
            and version.time < datetime.now(utc)
        version.stats = stats
        version.interval_hrefs = interval_hrefs
        names = [milestone.name for milestone in milestones]
        version.stats_href = version_stats_href(self.env, req, names)
        data = {
            'version': version,
            'attachments': AttachmentModule(self.env).attachment_data(context),
            'milestones': milestones,
            'milestone_stats': milestone_stats,
            'show_milestone_description':
            self.show_milestone_description  # Not implemented yet
        }

        add_stylesheet(req, 'extendedversion/css/version.css')
        add_script(req, 'common/js/folding.js')
        add_ctxtnav(req, _("Back to Versions"), req.href.versions())
        return 'version_view.html', data, None
예제 #55
0
    def _render_view(self, req, db, version):

        db = self.env.get_db_cnx()
        sql = "SELECT name FROM milestone " \
              "INNER JOIN milestone_version ON (name = milestone) " \
              "WHERE version = %s " \
              "ORDER BY due"
        cursor = db.cursor()
        cursor.execute(sql, (version.name,))

        milestones = []
        tickets = []
        milestone_stats = []

        for row in cursor:
            milestone = Milestone(self.env, row[0])
            milestones.append(milestone)

            mtickets = get_tickets_for_milestone(self.env, db, milestone.name,
                                                 'owner')
            mtickets = apply_ticket_permissions(self.env, req, mtickets)
            tickets += mtickets
            stat = get_ticket_stats(self.milestone_stats_provider, mtickets)
            milestone_stats.append(milestone_stats_data(self.env, req, stat, milestone.name))

        stats = get_ticket_stats(self.version_stats_provider, tickets)
        interval_hrefs = version_interval_hrefs(self.env, req, stats,
                                                [milestone.name for milestone in milestones])

        version.resource = Resource('version', version.name)
        context = Context.from_request(req, version.resource)

        version.is_released = version.time and version.time.date() < date.today()
        version.stats = stats
        version.interval_hrefs = interval_hrefs
        version.stats_href = [] # Not implemented yet, see th:#10349
        data = {
            'context': context,
            'version': version,
            'attachments': AttachmentModule(self.env).attachment_data(context),
            'milestones': milestones,
            'milestone_stats': milestone_stats,
            'show_milestone_description': self.show_milestone_description # Not implemented yet
        }

        add_stylesheet(req, 'extendedversion/css/version.css')
        add_script(req, 'common/js/folding.js')
        add_ctxtnav(req, _("Back to Versions"), req.href.versions())
        return 'version_view.html', data, None
예제 #56
0
    def _process_request(self, req):
        book, page = self._process_url(req)

        data = {
            'title': self._get_title(),
        }

        # build wiki_index
        if book == 'wiki_index':
            if page:
                text = ''
                if WikiSystem(self.env).has_page(page):
                    text = WikiPage(self.env, page).text
                else:
                    text = 'GTK-Doc index page [wiki:"%s"] does not exist.' % page
                data['wiki_content'] = wiki_to_html(text, self.env, req)
                add_ctxtnav(req, "View %s page" % page, req.href.wiki(page))
                return 'gtkdoc.html', data, 'text/html'
            else:
                raise TracError("Can't read gtkdoc content: %s" % req.path_info)

        # build content
        values = self._get_values(book)
        book_path = values[0]
        book_index = values[1]
        book_encoding = values[2]

        if not page:
            redirect_href = os.path.join(req.href.gtkdoc(), book)
            redirect_href = os.path.join(redirect_href, book_index)
            req.redirect(redirect_href)

        page = page or book_index
        path = os.path.join(book_path, page)

        mimetype, encoding = mimetypes.guess_type(path)
        encoding = encoding or \
                   book_encoding or \
                   self.env.config['trac'].get('default_charset')

        # Genshi can't include an unparsed file
        # data = {'content': path}
        if (mimetype == 'text/html'):
            try:
                content = Markup(to_unicode(file(path).read(), encoding))
            except (IOError, OSError), e:
                self.log.debug("Can't read gtkdoc content: %s" % e)
                raise TracError("Can't read gtkdoc content: %s" % req.path_info)
            data['content'] = content
예제 #57
0
    def process_request(self, req):
        path_info = req.path_info[10:]

        if not path_info:
            raise TracError('No ticket specified')

        tkt_id = path_info.split('/', 1)[0]
        g = self._build_graph(req, tkt_id)
        if '/' in path_info or 'format' in req.args:

            format = req.args.get('format')
            if format == 'text':
                req.send(str(g), 'text/plain')
            elif format == 'debug':
                import pprint
                req.send(pprint.pformat(TicketLinks(self.env, tkt_id)),
                         'text/plain')
            elif format is not None:
                req.send(g.render(self.dot_path, format), 'text/plain')

            if self.use_gs:
                ps = g.render(self.dot_path, 'ps2')
                gs = subprocess.Popen([
                    self.gs_path, '-q', '-dTextAlphaBits=4',
                    '-dGraphicsAlphaBits=4', '-sDEVICE=png16m', '-o',
                    '%stdout%', '-'
                ],
                                      stdin=subprocess.PIPE,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
                img, err = gs.communicate(ps)
                if err:
                    self.log.debug('MasterTickets: Error from gs: %s', err)
            else:
                img = g.render(self.dot_path)
            req.send(img, 'image/png')
        else:
            data = {}

            tkt = Ticket(self.env, tkt_id)
            data['tkt'] = tkt
            data['graph'] = g
            data['graph_render'] = partial(g.render, self.dot_path)
            data['use_gs'] = self.use_gs

            add_ctxtnav(req, 'Back to Ticket #%s' % tkt.id,
                        req.href.ticket(tkt_id))
            return 'depgraph.html', data, None
예제 #58
0
    def post_process_request(self, req, template, data, content_type):
        match = re.match(r'^/changeset', req.path_info)
        if 'CHANGESET_DELETE' in req.perm and match:
            rev = req.args.get('new')
            path = req.args.get('new_path')

            rm = RepositoryManager(self.env)
            if rev and path:
                reponame, repos, path = rm.get_repository_by_path(path)
                convert_managed_repository(self.env, repos)
                if (path == '/' and (repos.owner == req.authname or
                                     'REPOSITORY_ADMIN' in req.perm)
                    and rm.can_delete_changesets(repos.type)):
                    add_ctxtnav(req, _("Delete Changeset"),
                                req.href.deletechangeset(rev, reponame))

        return template, data, content_type