Exemplo n.º 1
0
    def human_duration(self):
        # Use net duration from event participation
        net_duration_s = self.get_net_duration_s()
        if net_duration_s is not None:
            return human_seconds(net_duration_s)

        ideal_duration_s = self.get_ideal_duration_s()
        if ideal_duration_s:
            return human_seconds(ideal_duration_s)

        if self.duration_s:
            return human_seconds(self.duration_s)
Exemplo n.º 2
0
    def human_duration_html(self):
        """
        Enhanced version of self.human_duration()
        with more information via <span title="...">
        """
        net_duration_s = self.get_net_duration_s()
        if net_duration_s is not None:
            duration_diff = self.duration_s - net_duration_s
            html = (
                '<span'
                ' title="{net} is the official net duration'
                ' - GPX-Track: {gpx} (diff: {diff})"'
                '>{net}</span>'
            ).format(
                net=human_seconds(net_duration_s),
                gpx=human_seconds(self.duration_s),
                diff=human_duration(duration_diff),
            )
            return mark_safe(html)

        ideal_duration_s = self.get_ideal_duration_s()
        if ideal_duration_s:
            duration_diff = self.duration_s - ideal_duration_s
            html = (
                '<span'
                ' title="{ideal} is the standardized duration'
                ' - GPX-Track: {gpx} (diff: {diff})"'
                '>{ideal}</span>'
            ).format(
                ideal=human_seconds(ideal_duration_s),
                gpx=human_seconds(self.duration_s),
                diff=human_duration(duration_diff),
            )
            return mark_safe(html)

        if self.duration_s:
            html = ('<span' ' title="real duration"' '>%s</span>') % human_seconds(self.duration_s)
            return mark_safe(html)
Exemplo n.º 3
0
 def human_pace(self):
     if self.pace:
         return "%s min/km" % human_seconds(self.pace * 60)
Exemplo n.º 4
0
 def pace(self, obj):
     pace_s = obj.get_pace_s()
     if pace_s:
         return "%s min/km" % human_seconds(pace_s)
Exemplo n.º 5
0
 def human_duration(self, obj):
     if obj.duration:
         return human_seconds(obj.get_duration_s())
Exemplo n.º 6
0
 def human_duration(self):
     if self.duration:
         return human_seconds(self.get_duration_s())