class AddForm(base.AddForm):
    form_fields = form.Fields(IRedmineTicketsPortlet)
    label = _(u"Add Redmine Tickets Portlet")
    description = _(u"Renders list of opened Redmine Tickets for authenticated "
                    "user.")

    def create(self, data):
        return Assignment(**data)
class IUserDataSchema(Interface):

    redmine_username = schema.ASCIILine(
        title=_("Redmine Username"),
        description=_(u"We need this field in order to display your Redmine "
                      "related information."),
        required=False)

    redmine_password = schema.Password(
        title=_("Redmine Password"),
        description=_(u"We need this field in order to display your Redmine "
                      "related information."),
        required=False)
Beispiel #3
0
    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]
Beispiel #4
0
    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)
Beispiel #5
0
    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
Beispiel #8
0
    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]
class IRedmineTicketsPortlet(IPortletDataProvider):

    header = schema.TextLine(
        title=_(u"Header"),
        description=_(u"Header of the portlet."),
        required=True,
        default=u'Redmine Tickets')

    count = schema.Int(
        title=_(u"Number of items to display"),
        description=_(u"How many items to list."),
        required=True,
        default=5)

    request_timeout = schema.Int(
        title=_(u"Request timeout"),
        description=_(u"How many seconds to wait for hanging Redmine request."),
        required=True,
        default=15)
class EditForm(base.EditForm):
    form_fields = form.Fields(IRedmineTicketsPortlet)
    label = _(u"Edit Redmine Tickets Portlet")
    description = _(u"Renders list of opened Redmine Tickets for authenticated "
                    "user.")