Пример #1
0
    def populate(self, user_stories, project_stats, set_focus=None):
        if user_stories:
            self.reset()

        self.doomline_limit = data.doomline_limit_points(project_stats)
        first_gains_focus = len(self.widget.contents) == 1 and user_stories

        summation = 0
        doomline = False

        for us in user_stories:
            summation += data.us_total_points(us)

            if not doomline and summation > self.doomline_limit:
                self.widget.contents.append((generic.RowDivider("red", div_char="☠"), ("weight", 0.1)))
                doomline = True

            self.widget.contents.append((UserStoryEntry(us, self.project, self.roles, summation,
                                                        self.on_user_story_status_change,
                                                        self.on_user_story_points_change),
                                         ("weight", 0.1)))
        # Set the focus # TODO: Refactor
        if first_gains_focus:
            if set_focus:
                for idx, item in enumerate(self.widget.contents):
                    widget, options = item
                    if type(widget) is UserStoryEntry and widget.user_story == set_focus:
                        self.widget.contents.focus = idx

            if not self.widget.contents.focus:
                self.widget.contents.focus = 1
Пример #2
0
    def populate(self, user_stories, project_stats, set_focus=None):
        if user_stories:
            self.reset()

        self.doomline_limit = data.doomline_limit_points(project_stats)
        first_gains_focus = len(self.widget.contents) == 1 and user_stories

        summation = 0
        doomline = False

        for us in user_stories:
            summation += data.us_total_points(us)

            if not doomline and summation > self.doomline_limit:
                self.widget.contents.append(
                    (generic.RowDivider("red", div_char="☠"), ("weight", 0.1)))
                doomline = True

            self.widget.contents.append(
                (UserStoryEntry(us, self.project, self.roles, summation,
                                self.on_user_story_status_change,
                                self.on_user_story_points_change), ("weight",
                                                                    0.1)))
        # Set the focus # TODO: Refactor
        if first_gains_focus:
            if set_focus:
                for idx, item in enumerate(self.widget.contents):
                    widget, options = item
                    if type(
                            widget
                    ) is UserStoryEntry and widget.user_story == set_focus:
                        self.widget.contents.focus = idx

            if not self.widget.contents.focus:
                self.widget.contents.focus = 1
Пример #3
0
    def __init__(self, us, project, roles, summation=0.0, on_status_change=None, on_points_change=None):
        self.user_story = us

        colum_items = [(6, generic.ListText("#{0}".format(str(data.us_ref(us))), align="left"))]

        colum_items.append((1, urwid.AttrMap(generic.ListText("⊕" if data.us_client_requirement(us) else " ",
                                                              align="left"), "yellow", "focus")))
        colum_items.append((1, urwid.AttrMap(generic.ListText("☂" if data.us_team_requirement(us) else " ",
                                                              align="left"), "cyan", "focus")))
        colum_items.append((2, urwid.AttrMap(generic.ListText("✖" if data.us_is_blocked(us) else " ",
                                                              align="left"), "red", "focus")))

        colum_items.append(("weight", 0.5, generic.ListText(data.us_subject(us), align="left")))

        us_statuses = data.us_statuses(project)
        items = tuple(((urwid.AttrSpec("h{0}".format(utils.color_to_hex(s.get("color", "#ffffff"))), "default"),
                        s.get("name", "")), s.get("id", None)) for s in us_statuses.values())
        selected = us.get("status", None) or project.get("default_us_status", None)
        status_combo = generic.ComboBox(items, selected_value=selected, style="cyan", enable_markup=True,
                                        on_state_change=on_status_change, user_data=us)
        colum_items.append(("weight", 0.15, status_combo))

        points = data.points(project)
        items = tuple((p.get("name", ""), p.get("id", None)) for p in points.values())
        for r_id, role in roles.items():
            selected = (us.get("points", {}).get(r_id, None) or
                        project.get("default_points", None))
            points_combo = generic.ComboBox(items, selected_value=selected, style="cyan",
                                            on_state_change=on_points_change, user_data=(us, r_id))
            colum_items.append(("weight", 0.05, points_combo))

        colum_items.append(("weight", 0.05, generic.ListText(("green", "{0:.1f}".format(
                                                                        data.us_total_points(us))))))
        colum_items.append(("weight", 0.08, generic.ListText(("cyan", "{0:.1f}".format(summation)))))

        self.widget = urwid.Columns(colum_items)
        super().__init__(urwid.AttrMap(self.widget, "default", "focus"))
Пример #4
0
    def __init__(self, us, project, roles, on_status_change=None, on_points_change=None):
        self.user_story = us

        if us.get("is_closed", False):
            is_closed = urwid.AttrMap(generic.ListText("☑"), "green", "focus-header")
        else:
            is_closed = urwid.AttrMap(generic.ListText("☒"), "red", "focus-header")
        colum_items = [("weight", 0.05, is_closed)]

        us_ref_and_name = "US #{0: <4} {1}".format(str(data.us_ref(us)), data.us_subject(us))
        colum_items.append(("weight", 0.6, generic.ListText(us_ref_and_name, align="left")))

        us_statuses = data.us_statuses(project)
        items = tuple(((urwid.AttrSpec("h{0}".format(utils.color_to_hex(s.get("color", "#ffffff"))), "default"),
                        s.get("name", "")), s.get("id", None)) for s in us_statuses.values())
        selected = us.get("status", None) or project.get("default_us_status", None)
        status_combo = generic.ComboBox(items, selected_value=selected, style="cyan", enable_markup=True,
                                        on_state_change=on_status_change, user_data=us)
        colum_items.append(("weight", 0.15, status_combo))

        points = data.points(project)
        items = tuple((p.get("name", ""), p.get("id", None)) for p in points.values())
        for r_id, role in roles.items():
            role_name = generic.ListText("{}:".format(role.get("name", "UNK.")))

            selected = (us.get("points", {}).get(r_id, None) or
                        project.get("default_points", None))
            points_combo = generic.ComboBox(items, selected_value=selected, style="cyan",
                                            on_state_change=on_points_change, user_data=(us, r_id))
            colum_items.append(("weight", 0.15, urwid.Columns([('pack',role_name), points_combo])))

        colum_items.append(("weight", 0.1, generic.ListText(("green", "TOTAL: {0:.1f}".format(
                                                                      data.us_total_points(us))))))

        self.widget = urwid.Columns(colum_items)
        super().__init__(urwid.AttrMap(urwid.LineBox(urwid.AttrMap(self.widget, "cyan", "focus-header")),
                                       "green"))
Пример #5
0
    def __init__(self,
                 us,
                 project,
                 roles,
                 on_status_change=None,
                 on_points_change=None):
        self.user_story = us

        if us.get("is_closed", False):
            is_closed = urwid.AttrMap(generic.ListText("☑"), "green",
                                      "focus-header")
        else:
            is_closed = urwid.AttrMap(generic.ListText("☒"), "red",
                                      "focus-header")
        colum_items = [("weight", 0.05, is_closed)]

        us_ref_and_name = "US #{0: <4} {1}".format(str(data.us_ref(us)),
                                                   data.us_subject(us))
        colum_items.append(
            ("weight", 0.6, generic.ListText(us_ref_and_name, align="left")))

        us_statuses = data.us_statuses(project)
        items = tuple(((urwid.AttrSpec(
            "h{0}".format(utils.color_to_hex(s.get("color", "#ffffff"))),
            "default"), s.get("name", "")), s.get("id", None))
                      for s in us_statuses.values())
        selected = us.get("status", None) or project.get(
            "default_us_status", None)
        status_combo = generic.ComboBox(items,
                                        selected_value=selected,
                                        style="cyan",
                                        enable_markup=True,
                                        on_state_change=on_status_change,
                                        user_data=us)
        colum_items.append(("weight", 0.15, status_combo))

        points = data.points(project)
        items = tuple(
            (p.get("name", ""), p.get("id", None)) for p in points.values())
        for r_id, role in roles.items():
            role_name = generic.ListText("{}:".format(role.get("name",
                                                               "UNK.")))

            selected = (us.get("points", {}).get(r_id, None)
                        or project.get("default_points", None))
            points_combo = generic.ComboBox(items,
                                            selected_value=selected,
                                            style="cyan",
                                            on_state_change=on_points_change,
                                            user_data=(us, r_id))
            colum_items.append(("weight", 0.15,
                                urwid.Columns([('pack', role_name),
                                               points_combo])))

        colum_items.append(
            ("weight", 0.1,
             generic.ListText(
                 ("green",
                  "TOTAL: {0:.1f}".format(data.us_total_points(us))))))

        self.widget = urwid.Columns(colum_items)
        super().__init__(
            urwid.AttrMap(
                urwid.LineBox(
                    urwid.AttrMap(self.widget, "cyan", "focus-header")),
                "green"))
Пример #6
0
    def __init__(self,
                 us,
                 project,
                 roles,
                 summation=0.0,
                 on_status_change=None,
                 on_points_change=None):
        self.user_story = us

        colum_items = [(6,
                        generic.ListText("#{0}".format(str(data.us_ref(us))),
                                         align="left"))]

        colum_items.append(
            (1,
             urwid.AttrMap(
                 generic.ListText(
                     "⊕" if data.us_client_requirement(us) else " ",
                     align="left"), "yellow", "focus")))
        colum_items.append(
            (1,
             urwid.AttrMap(
                 generic.ListText("☂" if data.us_team_requirement(us) else " ",
                                  align="left"), "cyan", "focus")))
        colum_items.append(
            (2,
             urwid.AttrMap(
                 generic.ListText("✖" if data.us_is_blocked(us) else " ",
                                  align="left"), "red", "focus")))

        colum_items.append(
            ("weight", 0.5, generic.ListText(data.us_subject(us),
                                             align="left")))

        us_statuses = data.us_statuses(project)
        items = tuple(((urwid.AttrSpec(
            "h{0}".format(utils.color_to_hex(s.get("color", "#ffffff"))),
            "default"), s.get("name", "")), s.get("id", None))
                      for s in us_statuses.values())
        selected = us.get("status", None) or project.get(
            "default_us_status", None)
        status_combo = generic.ComboBox(items,
                                        selected_value=selected,
                                        style="cyan",
                                        enable_markup=True,
                                        on_state_change=on_status_change,
                                        user_data=us)
        colum_items.append(("weight", 0.15, status_combo))

        points = data.points(project)
        items = tuple(
            (p.get("name", ""), p.get("id", None)) for p in points.values())
        for r_id, role in roles.items():
            selected = (us.get("points", {}).get(r_id, None)
                        or project.get("default_points", None))
            points_combo = generic.ComboBox(items,
                                            selected_value=selected,
                                            style="cyan",
                                            on_state_change=on_points_change,
                                            user_data=(us, r_id))
            colum_items.append(("weight", 0.05, points_combo))

        colum_items.append(
            ("weight", 0.05,
             generic.ListText(
                 ("green", "{0:.1f}".format(data.us_total_points(us))))))
        colum_items.append(("weight", 0.08,
                            generic.ListText(
                                ("cyan", "{0:.1f}".format(summation)))))

        self.widget = urwid.Columns(colum_items)
        super().__init__(urwid.AttrMap(self.widget, "default", "focus"))