def update_new(self): # TODO: remove update and replace it by this. # But before that we need, to change searchIssues and add searchMyIssues # and update cloudstream if IPloneSiteRoot in providedBy(self.context): return uuid = self.context.UID() field_key = self._get_field_key() url = util._get_server_url() try: issues = util.searchIssues(**{ field_key: uuid, 'status_id': 'o', 'sort': 'updated_on:desc' }) except: logException(logger=logger, context=self.context, msg=_(u"Error during fetching redmine tickets %s" % url)) issues = [] # TODO: convert to dic self.tickets = [self._ticket_from_issue(x, url) for x in issues]
def update(self): self.tickets = () if IPloneSiteRoot in providedBy(self.context): return tickets = [] # check if settings are configured # check user redmine credentials and redmine url/field id registry = getUtility(IRegistry) url = registry.get('vnccollab.redmine.server_url') field_id = registry.get('vnccollab.redmine.plone_uid_field_id') username, password = self.getAuthCredentials() project_id = registry.get('vnccollab.redmine.project_id') if username and password and url and field_id: Issue = type("Issue", (ActiveResource, ), { '_site': url, '_user': username, '_password': password }) # do actual calls to redmine try: # fetch opened issues belonging to authenticated user uuid = self.context.UID() query = { 'cf_%d' % field_id: uuid, 'status_id': 'o', 'sort': 'updated_on:desc' } if project_id: query['project_id'] = str(project_id) data = Issue.find(**query) except Exception: logException( logger=logger, context=self.context, msg=_(u"Error during fetching redmine tickets %s" % url)) return for item in data: info = item.to_dict() # skip invalid entries if not info.get('id') or not info.get('subject'): continue tickets.append({ 'id': info['id'], 'title': safe_unicode(info['subject']), 'body': safe_unicode(info.get('description', '')), 'url': '%s/issues/%s' % (url, info['id']) }) self.tickets = tuple(tickets)
def update(self): self.tickets = () if IPloneSiteRoot in providedBy(self.context): return tickets = [] # check if settings are configured # check user redmine credentials and redmine url/field id registry = getUtility(IRegistry) url = registry.get('vnccollab.redmine.server_url') field_id = registry.get('vnccollab.redmine.plone_uid_field_id') username, password = self.getAuthCredentials() project_id = registry.get('vnccollab.redmine.project_id') if username and password and url and field_id: Issue = type("Issue", (ActiveResource,), {'_site': url, '_user': username, '_password': password}) # do actual calls to redmine try: # fetch opened issues belonging to authenticated user uuid = self.context.UID() query = {'cf_%d' % field_id: uuid, 'status_id': 'o', 'sort': 'updated_on:desc'} if project_id: query['project_id']=str(project_id) data = Issue.find(**query) except Exception: logException(logger=logger, context=self.context, msg=_(u"Error during fetching redmine tickets %s" % url)) return for item in data: info = item.to_dict() # skip invalid entries if not info.get('id') or not info.get('subject'): continue tickets.append({ 'id': info['id'], 'title': safe_unicode(info['subject']), 'body': safe_unicode(info.get('description', '')), 'url': '%s/issues/%s' % (url, info['id']) }) self.tickets = tuple(tickets)
def getTickets(self): """Returns list of opened issues for authenticated user""" try: tickets = util.searchMyIssues(status_id='o', sort='updated_on:desc') except: logException(msg=_(u"Error during fetching redmine tickets %s" % util._get_server_url), context=self.context, logger=logger) return () plone_view = getMultiAdapter((self.context, self.request), name=u'plone') url = util._get_server_url() tickets = [x for x in tickets if x.id and x.subject] tickets = tickets[:self.data.count] result = tuple([self._dct_from_issue(x, plone_view, url) for x in tickets]) return result
def getTickets(self): """Returns list of opened issues for authenticated user""" try: tickets = util.searchMyIssues(status_id="o", sort="updated_on:desc") except: logException( msg=_(u"Error during fetching redmine tickets %s" % util._get_server_url), context=self.context, logger=logger, ) return () plone_view = getMultiAdapter((self.context, self.request), name=u"plone") url = util._get_server_url() tickets = [x for x in tickets if x.id and x.subject] tickets = tickets[: self.data.count] result = tuple([self._dct_from_issue(x, plone_view, url) for x in tickets]) return result
def update_new(self): # TODO: remove update and replace it by this. # But before that we need, to change searchIssues and add searchMyIssues # and update cloudstream if IPloneSiteRoot in providedBy(self.context): return uuid = self.context.UID() field_key = self._get_field_key() url = util._get_server_url() try: issues = util.searchIssues(**{field_key: uuid, 'status_id': 'o', 'sort': 'updated_on:desc'}) except: logException(logger=logger, context=self.context, msg=_(u"Error during fetching redmine tickets %s" % url)) issues = [] # TODO: convert to dic self.tickets = [self._ticket_from_issue(x, url) for x in issues]