def map_author(self):
     """
     get the full name of a user-id
     """
     return readable_author(self.context)
    def infos(self):
        """Returns Infos for email-template"""
        responses = self.get_responses()
        author = readable_author(self.context)

        if isinstance(author, Message):
            author = self.context.translate(author)

        ticket_infos = {'tracker_title': self.context.aq_parent.title,
                        'tracker_url': self.context.aq_parent.absolute_url(),
                        'title': self.context.Title(),
                        'ticket_id': self.context.getId(),
                        'individualIdendifier':
                            self.context.aq_parent.getIndividualIdentifier,
                        'url': self.context.absolute_url(),
                        'text': self.context.getTicket_description(),
                        'state': map_attribute(self.context, "state"),
                        'responsibleManager': author,
                        'priority': map_attribute(self.context, "priority"),
                        'area': map_attribute(self.context, "area"),
                        'variety': map_attribute(self.context, "variety"),
                        'releases': map_attribute(self.context, "releases"),
                        'watchedRelease': map_attribute(self.context,
                                                        "watchedRelease"),
                        'answerDate': self.context.toLocalizedTime(
                            self.context.getAnswerDate(), long_format=True),
                        'response': False}
        if responses == []:
            return ticket_infos
        else:
            response_date = responses[len(responses) - 1]['response'].date
            if self.context.modification_date > response_date:
                return ticket_infos
            else:
                response = responses[len(responses) - 1]
                changes = {
                    'tracker_title': self.context.aq_parent.title,
                    'tracker_url': self.context.aq_parent.absolute_url(),
                    'title': self.context.Title(),
                    'ticket_id': self.context.getId(),
                    'individualIdendifier':
                        self.context.aq_parent.getIndividualIdentifier,
                    'url': self.context.absolute_url(),
                    'text': '',
                    'state': '',
                    'responsibleManager': '',
                    'priority': '',
                    'area': '',
                    'variety': '',
                    'releases': '',
                    'watchedRelease': '',
                    'answerDate': '',
                    'response': True}
                for item in response['response'].changes:
                    # XXX: Hack to solve the label_unassigned translations
                    # problem.
                    # If we retrieve a responsibleManager named
                    # label_unassigned, try to translate it
                    if item['id'] == 'responsibleManager':
                        if item['before'] == 'label_unassigned':
                            item['before'] = self.context.translate(
                                _(item['before']))
                        if item['after'] == 'label_unassigned':
                            item['after'] = self.context.translate(
                                _(item['after']))

                    changes[item['id']] = (
                        item['before'] + ' → ' + item['after'])
                changes['text'] = response['response'].text
                return changes
Exemple #3
0
def sortable_responsibleManager(obj):
    """get the fullname of the author to sort correctly"""
    author = readable_author(obj)
    if isinstance(author, unicode):
        author = author.encode('utf-8')
    return author