Ejemplo n.º 1
0
Archivo: models.py Proyecto: dbaty/Yait
    def get_time_info(self, include_private_info):
        """Return a dictionary of time-related information for this
        issue:

        - ``billed``

        - ``estimated``

        - ``spent_real``: sum of the (real) time spent in all
          changes;

        - ``spent_public``: sum of the (public) time spent in all
          changes.

        ``estimated`` and ``spent_public`` are included only if
        ``include_private_info`` is enabled.

        All time information is converted to the "1w 2d 3h" format.
        """
        data = {'billed': self.time_billed or 0,
                'spent_public': 0}
        if include_private_info:
            data.update(estimated=self.time_estimated or 0)
            data.update(spent_real=0)
        for change in self.changes:
            data['spent_public'] += change.time_spent_public or 0
            if include_private_info:
                data['spent_real'] += change.time_spent_real or 0
        for key, value in data.items():
            data[key] = time_to_str(value)
        return data
Ejemplo n.º 2
0
Archivo: models.py Proyecto: dbaty/Yait
 def get_details(self, caches, include_private_time_info=False):
     """Return a list of changes as mappings."""
     details = []
     for attr, label in Issue._ordered:
         if attr in ('time_estimated', 'time_spent_real') and \
                 not include_private_time_info:
             continue
         try:
             before, after = self.changes[attr]
         except KeyError:
             continue
         if attr == 'status':
             cache = caches.statuses
         elif attr == 'assignee':
             cache = caches.fullnames
         else:
             cache = None
         if not before:
             before = 'none'
         else:
             if cache:
                 before = cache[before]
             if attr.startswith('time_'):
                 before = time_to_str(before)
             elif attr == 'kind':
                 before = ISSUE_KIND_LABELS[before - 1]
             elif attr == 'priority':
                 before = ISSUE_PRIORITY_LABELS[before - 1]
         if not after:
             after = 'none'
         else:
             if cache:
                 after = cache[after]
             if attr.startswith('time_'):
                 after = time_to_str(after)
             elif attr == 'kind':
                 after = ISSUE_KIND_LABELS[after - 1]
             elif attr == 'priority':
                 after = ISSUE_PRIORITY_LABELS[after - 1]
         details.append({'attr': attr, 'label': label,
                         'before': before, 'after': after})
     return details
Ejemplo n.º 3
0
Archivo: forms.py Proyecto: dbaty/Yait
 def process_data(self, value):
     self.data = time_to_str(value or 0)
Ejemplo n.º 4
0
 def _call_fut(self, t):
     from yait.utils import time_to_str
     return time_to_str(t)