예제 #1
0
    def get_grouped_entries(self):
        grouped_entries = []
        grouped_timeline = groupby(self.submissions_values,
                                   key=lambda item: "\001".join([
                                       str(x) for x in [
                                           item['submitter_id'],
                                           item['creation_time'],
                                           item['suggestion_id'],
                                       ]
                                   ]))

        # Target field timeline entry should go first
        def target_field_should_be_first(x):
            return 0 if x["field"] == SubmissionFields.TARGET else 1

        # Group by submitter id and creation_time because
        # different submissions can have same creation time
        for __, values in grouped_timeline:
            entry_group = {'entries': []}
            values = sorted(values, key=target_field_should_be_first)
            for item in values:
                if "submitter" not in entry_group:
                    entry_group['submitter'] = DisplayUser(
                        item["submitter__username"],
                        item["submitter__full_name"], item["submitter__email"])
                if "datetime" not in entry_group:
                    entry_group['datetime'] = item['creation_time']
                via_upload = item["type"] == SubmissionTypes.UPLOAD
                entry_group["via_upload"] = via_upload
                entry_group['entries'].append(self.get_entry(item))
            grouped_entries.append(entry_group)
        return grouped_entries
예제 #2
0
def _get_sugg_accepted_with_comment_desc(suggestion, comment):
    user = DisplayUser(suggestion.user.username, suggestion.user.full_name)
    params = {
        'author': user.author_link,
        'comment': format_html(u'<span class="comment">{}</span>', comment)
    }

    return (u'Accepted suggestion from %(author)s '
            u'with comment: %(comment)s' % params)
예제 #3
0
파일: display.py 프로젝트: yiyibooks/pootle
 def __iter__(self):
     for score in self.top_scores:
         score_data = dict(user=DisplayUser(score["user__username"],
                                            score["user__full_name"],
                                            score["user__email"]),
                           total_score=score["score__sum"],
                           public_total_score=formatter.number(
                               int(round(score["score__sum"]))))
         for k in ["translated", "reviewed", "suggested"]:
             score_data[k] = formatter.number(
                 int(round(score["%s__sum" % k])))
         yield self.format_score(score_data)
예제 #4
0
파일: timeline.py 프로젝트: ii0/pootle
 def context(self):
     return {
         'events':
         self.events,
         'via_upload':
         self.via_upload,
         'datetime':
         self.context_event.timestamp,
         'user':
         DisplayUser(self.user.username, self.user.full_name,
                     self.user.email),
     }
예제 #5
0
 def user(self):
     return DisplayUser(self.username, self.full_name)
예제 #6
0
 def suggestion_reviewer_display(self):
     return DisplayUser(self.values["suggestion__reviewer__username"],
                        self.values["suggestion__reviewer__full_name"],
                        self.values["suggestion__reviewer__email"])
예제 #7
0
 def submitter_display(self):
     return DisplayUser(self.values["submitter__username"],
                        self.values["submitter__full_name"],
                        self.values["submitter__email"])
예제 #8
0
def _get_sugg_accepted_desc(suggestion):
    user = DisplayUser(suggestion.user.username, suggestion.user.full_name)
    params = {'author': user.author_link}
    return u'Accepted suggestion from %(author)s' % params
예제 #9
0
파일: timeline.py 프로젝트: ii0/pootle
 def user(self):
     return DisplayUser(self.suggestion.user.username,
                        self.suggestion.user.full_name)