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


Python util.get_reporter_id函数代码示例

本文整理汇总了Python中trac.util.get_reporter_id函数的典型用法代码示例。如果您正苦于以下问题:Python get_reporter_id函数的具体用法?Python get_reporter_id怎么用?Python get_reporter_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: render_voter

    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))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:34,代码来源:__init__.py

示例2: set_vote

 def set_vote(self, req, resource, vote):
     """Vote for a resource."""
     resource = self.normalise_resource(resource)
     db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.execute('DELETE FROM votes WHERE username=%s '
                    'AND resource = %s', (get_reporter_id(req), resource))
     if vote:
         cursor.execute('INSERT INTO votes (resource, username, vote) '
                        'VALUES (%s, %s, %s)',
                        (resource, get_reporter_id(req), vote))
     db.commit()
开发者ID:eleddy,项目名称:dev.plone.org,代码行数:12,代码来源:__init__.py

示例3: _do_save

    def _do_save(self, req, page):
        if not page.exists:
            req.perm(page.resource).require('WIKI_CREATE')
        else:
            req.perm(page.resource).require('WIKI_MODIFY')

        if 'WIKI_ADMIN' in req.perm(page.resource):
            # Modify the read-only flag if it has been changed and the user is
            # WIKI_ADMIN
            page.readonly = int('readonly' in req.args)

        try:
            page.save(get_reporter_id(req, 'author'), req.args.get('comment'),
                      req.remote_addr)
            href = req.href.wiki(page.name, action='diff',
                                 version=page.version)
            add_notice(req, tag_("Your changes have been saved in version "
                                 "%(version)s (%(diff)s).",
                                 version=page.version,
                                 diff=tag.a(_("diff"), href=href)))
            req.redirect(get_resource_url(self.env, page.resource, req.href,
                                          version=None))
        except TracError:
            add_warning(req, _("Page not modified, showing latest version."))
            return self._render_view(req, page)
开发者ID:pkdevbox,项目名称:trac,代码行数:25,代码来源:web_ui.py

示例4: _create_attachment

    def _create_attachment(self, req, tid, upload, description):
        attachment = Attachment(self.env, "ticket", tid)

        if hasattr(upload.file, "fileno"):
            size = os.fstat(upload.file.fileno())[6]
        else:
            upload.file.seek(0, 2)
            size = upload.file.tell()
            upload.file.seek(0)
        if size == 0:
            raise TracError(_("Can't upload empty file"))

        max_size = self.env.config.get("attachment", "max_size")
        if 0 <= max_size < size:
            raise TracError(_("Maximum attachment size: %(num)s bytes", num=max_size), _("Upload failed"))

        filename = _normalized_filename(upload.filename)
        if not filename:
            raise TracError(_("No file uploaded"))

        attachment.description = description
        attachment.author = get_reporter_id(req, "author")
        attachment.ipnr = req.remote_addr

        attachment.insert(filename, upload.file, size)
开发者ID:kzhamaji,项目名称:AwesomeAttachmentPlugin,代码行数:25,代码来源:awesomeattachments.py

示例5: _do_uploadPicture

    def _do_uploadPicture(self, req, userProfile, teamRosterData, req_arg_picture = 'tr_userProfile_picture' ):
        
        upload = req.args.get(req_arg_picture, None)
        if upload == None or not hasattr(upload, 'filename') or not upload.filename:
            return userProfile.picture_href
        
        if hasattr(upload.file, 'fileno'):
            size = os.fstat(upload.file.fileno())[6]
        else:
            upload.file.seek(0, 2) # seek to end of file
            size = upload.file.tell()
            upload.file.seek(0)
        if size == 0:
            raise TracError(_("Can't upload empty file"))

        filename = upload.filename
        filename = filename.replace('\\', '/').replace(':', '/')        
        filename = os.path.basename(filename)
        
        if not filename:
            raise TracError(_('No file uploaded'))
        
        page = WikiPage(self.env,  self.teamRoster_wikiPage)
        if not page.exists:
            page.text="= Team Roster Pictures ="
            page.save( 'trac', 'Page created by tracteamroster component',  req.remote_addr)
       
              
        attachment = Attachment(self.env, 'wiki', self.teamRoster_wikiPage)
        attachment.author = get_reporter_id(req, 'author')
        attachment.ipnr = req.remote_addr
        attachment.insert('_'.join([userProfile.id, filename]), upload.file, size)
        
        return req.href('/'.join(['raw-attachment', 'wiki',self.teamRoster_wikiPage,attachment.filename]))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:34,代码来源:admin.py

示例6: end_process_row

    def end_process_row(self):
        try:
            # 'when' is a datetime in 0.11, and an int in 0.10.
            # if we have trac.util.datefmt.to_datetime, we're likely with 0.11
            from trac.util.datefmt import to_datetime
            tickettime = to_datetime(self.tickettime)
        except ImportError:
            tickettime = self.tickettime
                
        if self.ticket.id == None:
            for f in self.missingemptyfields:
                if self.ticket.values.has_key(f) and self.ticket[f] == None:
                    self.ticket[f] = ''
            for f in self.computedfields:
                 if self.computedfields[f] != None and self.computedfields[f]['set']:
                     self.ticket[f] = self.computedfields[f]['value']

            self.added += 1
            self.ticket.insert(when=tickettime, db=self.db)
        else: 
            message = "Batch update from file " + self.filename
            if self.ticket.is_modified():
                self.modifiedcount += 1
                self.ticket.save_changes(get_reporter_id(self.req), message, when=tickettime, db=self.db) # TODO: handle cnum, cnum = ticket.values['cnum'] + 1)
            else:
                self.notmodifiedcount += 1

        self.ticket = None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:28,代码来源:processors.py

示例7: _handle_ripe_save

    def _handle_ripe_save(self, req):
        """ hander for save  """
        # TODO: workflow

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

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

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

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

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

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

示例8: _process_add

    def _process_add(self, req, ticket):
        if req.method == "POST" and self._validate_add(req):
            if req.args.get('reminder_type') == 'interval':
                time = clear_time(to_datetime(None))
                delta = _time_intervals[req.args.get('unit')](req.args.get('interval'))
                time += delta
                time = to_utimestamp(time)
            else:
                time = to_utimestamp(parse_date(req.args.get('date')))
            origin = to_utimestamp(to_datetime(None))

            self.env.db_transaction("""
                INSERT INTO ticketreminder
                 (ticket, time, author, origin, reminded, description)
                VALUES (%s, %s, %s, %s, 0, %s)
                """, (ticket.id, time, get_reporter_id(req, 'author'),
                      origin, req.args.get('description')))

            add_notice(req, "Reminder has been added.")
            req.redirect(get_resource_url(self.env, ticket.resource, req.href) + "#reminders")

        add_script(req, 'ticketreminder/js/ticketreminder.js')

        data = {
            'ticket': ticket,
            'date_hint': get_date_format_hint(),
        }

        return ("ticket_reminder_add.html", data, None)
开发者ID:trac-hacks,项目名称:trac-ticketreminder,代码行数:29,代码来源:api.py

示例9: createTestPlan

        def createTestPlan(self, req, catalog_id, name):
            """ Creates a new test plan, on the catalog specified, with the 
            specified name.
            Returns the generated object ID, or '-1' if an error occurs. """

            result = "-1"
            try:
                # Check catalog really exists, and get its page_name
                tcat = TestCatalog(self.env, catalog_id)
                if not tcat.exists:
                    self.env.log.error("Input test catalog with ID %s not found." % catalog_id)
                    return result

                author = get_reporter_id(req, "author")

                id = self.testmanagersys.get_next_id("testplan")
                pagename = tcat["page_name"]

                new_tp = TestPlan(self.env, id, catalog_id, pagename, name, author)
                new_tp.insert()
                result = id

            except:
                self.env.log.error("Error adding test plan with name '%s' for catalog with ID %s!" % (name, catalog_id))
                self.env.log.error(formatExceptionInfo())

            return result
开发者ID:CoRfr,项目名称:testman4trac,代码行数:27,代码来源:rpcsupport.py

示例10: set_resource_tags

 def set_resource_tags(self, req, ticket_or_resource, tags, comment=u'',
                       when=None):
     try:
         resource = ticket_or_resource.resource
     except AttributeError:
         resource = ticket_or_resource
         assert resource.realm == self.realm
         if not self._check_permission(req, resource, 'modify'):
             raise PermissionError(resource=resource, env=self.env)
         tag_set = set(tags)
         # Processing a call from TracTags, try to alter the ticket.
         tkt = Ticket(self.env, resource.id)
         all = self._ticket_tags(tkt)
         # Avoid unnecessary ticket changes, considering comments below.
         if tag_set != all:
             # Will only alter tags in 'keywords' ticket field.
             keywords = split_into_tags(tkt['keywords'])
             # Assume, that duplication is depreciated and consolitation
             # wanted to primarily affect 'keywords' ticket field.
             # Consequently updating ticket tags and reducing (tag)
             # 'ticket_fields' afterwards may result in undesired tag loss.
             tag_set.difference_update(all.difference(keywords))
             tkt['keywords'] = u' '.join(sorted(map(to_unicode, tag_set)))
             tkt.save_changes(get_reporter_id(req), comment)
     else:
         # Processing a change listener event.
         tags = self._ticket_tags(ticket_or_resource)
         super(TicketTagProvider,
               self).set_resource_tags(req, resource, tags)
开发者ID:kzhamaji,项目名称:TracTagsPlugin,代码行数:29,代码来源:ticket.py

示例11: render_voter

 def render_voter(self, req):
     resource = self.normalise_resource(req.path_info)
     vote = self.get_vote(req, resource)
     up = tag.img(src=req.href.chrome('vote/' + self.image_map[vote][0]), 
                  alt='Up-vote')
     down = tag.img(src=req.href.chrome('vote/' + self.image_map[vote][1]), 
                  alt='Down-vote')         
     if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
         down = tag.a(down, id='downvote',
                      href=req.href.vote('down', resource),
                      title='Down-vote')
         up = tag.a(up, id='upvote', href=req.href.vote('up', resource),
                    title='Up-vote')
         add_script(req, 'vote/js/tracvote.js')
         shown = req.session.get('shown_vote_message')
         if not shown:
             add_notice(req, 'You can vote for resources on this Trac '
                        'install by clicking the up-vote/down-vote arrows '
                        'in the context navigation bar.')
             req.session['shown_vote_message'] = '1'
     body, title = self.format_votes(resource)
     votes = tag.span(body, id='votes')
     add_stylesheet(req, 'vote/css/tracvote.css')
     elm = tag.span(up, votes, down, id='vote', title=title)
     req.chrome.setdefault('ctxtnav', []).insert(0, elm)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:__init__.py

示例12: process_request

    def process_request(self, req):
        req.perm.assert_permission('TICKET_VIEW')

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

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

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

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

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

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

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

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

示例13: _do_save

    def _do_save(self, req, db, page):
        if page.readonly:
            req.perm.assert_permission('WIKI_ADMIN')
        elif not page.exists:
            req.perm.assert_permission('WIKI_CREATE')
        else:
            req.perm.assert_permission('WIKI_MODIFY')

        page.text = req.args.get('text')
        if req.perm.has_permission('WIKI_ADMIN'):
            # Modify the read-only flag if it has been changed and the user is
            # WIKI_ADMIN
            page.readonly = int(req.args.has_key('readonly'))

        # Give the manipulators a pass at post-processing the page
        for manipulator in self.page_manipulators:
            for field, message in manipulator.validate_wiki_page(req, page):
                if field:
                    raise InvalidWikiPage("The Wiki page field %s is invalid: %s"
                                          % (field, message))
                else:
                    raise InvalidWikiPage("Invalid Wiki page: %s" % message)

        page.save(get_reporter_id(req, 'author'), req.args.get('comment'),
                  req.remote_addr)
        req.redirect(req.href.wiki(page.name))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:26,代码来源:web_ui.py

示例14: post_new_spec

def post_new_spec(request, dbp, obj, resource):
    require_permission(request.req, resource, dbp.env, operation="CREATE")

    if obj is Entity: # instantiating Entity (i.e., creating a spec)
        pass
    elif obj is Instance or isinstance(obj, Entity): # instantiating an existing spec
        return post_new_artifact(request.req, dbp, obj, resource)
    else:
        raise Exception("Trying to instantiate something that can't be instantiated '%s'" % (obj,))

    name = request.req.args.get('name')
    parent_name = request.req.args.get('parent')

    attributes = [Attribute(n,m,t) for n,t,m in _group_spec_attributes(request.req)]

    if parent_name:
        dbp.load_spec(parent_name)
        bases = (dbp.pool.get_item(parent_name),)
    else:
        bases = tuple()
    brand_new_inst = Entity(name=name, attributes=attributes, bases=bases)

    dbp.pool.add(brand_new_inst)
    dbp.save(get_reporter_id(request.req), 'comment', request.req.remote_addr)
    add_notice(request.req, 'Your changes have been saved.')
    url = request.req.href.customartifacts('spec', brand_new_inst.get_name(), action='view')
    request.req.redirect(url)
开发者ID:filipefigcorreia,项目名称:TracAdaptiveSoftwareArtifacts,代码行数:27,代码来源:views.py

示例15: post_new_artifact

def post_new_artifact(request, dbp, obj, resource):
    require_permission(request.req, resource, dbp.env, operation="CREATE")

    assert(obj is Instance or isinstance(obj, Entity)) # otherwise, we're trying to instantiate something that is not an artifact

    spec_name = request.req.args['spec']
    if spec_name:
        try:
            dbp.load_spec(spec_name)
            spec = dbp.pool.get_item(spec_name)
        except ValueError:
            add_warning(request.req, "Spec '%s' not found, assumed an empty spec instead." % spec_name)
            spec = Instance
    else:
        spec = Instance

    values, str_attr = _group_artifact_values(request.req)
    brand_new_inst = spec(str_attr=str_attr, values=values)

    dbp.pool.add(brand_new_inst)
    dbp.save(get_reporter_id(request.req), 'comment', request.req.remote_addr)

    if request.get_format() == 'page':
        add_notice(request.req, 'Your changes have been saved.')
        url = request.req.href.customartifacts('artifact/%d' % (brand_new_inst.get_id(),), action='view', format=request.get_format())
        request.req.redirect(url)
    else:
        import json
        url = request.req.href.customartifacts('artifact/%d' % (brand_new_inst.get_id(),), action='view')
        msg = json.dumps([{'result': 'success', 'resource_id': brand_new_inst.get_id(), 'resource_url': url}])
        request.req.send_response(200)
        request.req.send_header('Content-Type', 'application/json')
        request.req.send_header('Content-Length', len(msg))
        request.req.end_headers()
        request.req.write(msg)
开发者ID:filipefigcorreia,项目名称:TracAdaptiveSoftwareArtifacts,代码行数:35,代码来源:views.py


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