Exemple #1
0
def change_labels(request, board_id, card_id):
    if request.method != "POST":
        raise Http404

    member = request.user.member

    try:
        board = get_member_boards(member).get(id=board_id)
        card = board.cards.get(id=card_id)
    except (Board.DoesNotExist, Card.DoesNotExist) as e:
        raise Http404

    # Get in labels a list of objects Label gotten from the selected labels
    labels = []
    label_ids = request.POST.getlist("labels")
    for label_id in label_ids:
        try:
            label = board.labels.exclude(name="").get(id=label_id)
            labels.append(label)
        except Label.DoesNotExist:
            pass

    card.update_labels(member, labels)

    return HttpResponseRedirect(reverse("boards:view_card", args=(board_id, card_id)))
Exemple #2
0
    def __init__(self, *args, **kwargs):
        self.member = kwargs.pop("member")
        super(WorkHoursPackageFilterForm, self).__init__(*args, **kwargs)

        # Available multiboards for the work hours package
        self.fields["multiboard"].choices = [("", "None")] + [
            (multiboard.id, multiboard.name)
            for multiboard in self.member.multiboards.all().order_by("name")
        ]

        # Available boards for this user
        boards = get_member_boards(
            self.member).filter(is_archived=False).order_by("name")
        self.fields["board"].choices = [("", "None")] + [(board.id, board.name)
                                                         for board in boards]

        # Available labels for this user
        self.fields["label"].choices = [("None", [("", "None")])] + [
            (board.name, [
                (label.id, label.name)
                for label in board.labels.exclude(name="").order_by("name")
            ]) for board in boards
        ]

        # Is paid?
        self.fields["is_paid"].choices = [("", "Indiferent"), ("Yes", "Yes"),
                                          ("No", "No")]
Exemple #3
0
    def get_work_hours_packages(self):
        # Filtering by multiboard, board or label
        multiboard_id = id = self.cleaned_data.get("multiboard")
        board_id = self.cleaned_data.get("board")
        label_id = self.cleaned_data.get("label")
        work_hours_packages = self.member.work_hours_packages.all().order_by(
            "start_work_date", "end_work_date", "name")
        if multiboard_id:
            multiboard = self.member.multiboards.get(id=multiboard_id)
            work_hours_packages = work_hours_packages.filter(
                board__in=[board.id for board in multiboard.boards.all()])
        elif board_id:
            work_hours_packages = work_hours_packages.filter(board_id=board_id)
        elif label_id:
            label = Label.objects.get(id,
                                      board__in=get_member_boards(self.member))
            work_hours_packages = work_hours_packages.filter(
                board__label=label)

        # Filtering paid work hours packages
        if self.cleaned_data.get("is_paid") == "Yes" or self.cleaned_data.get(
                "is_paid") == "No":
            work_hours_packages = work_hours_packages.filter(
                is_paid=(self.cleaned_data.get("is_paid") == "Yes"))

        return work_hours_packages
Exemple #4
0
    def __init__(self, *args, **kwargs):
        current_member = kwargs.pop("member")
        super(WorkHoursPackageForm, self).__init__(*args, **kwargs)
        self.fields["description"].widget = CKEditorWidget()

        # Available multiboards for the work hours package
        self.fields["multiboard"].choices = [("", "None")] + [
            (multiboard.id, multiboard.name)
            for multiboard in current_member.multiboards.all().order_by("name")
        ]

        # Available boards for this user
        boards = get_member_boards(current_member).filter(
            is_archived=False).order_by("name")
        self.fields["board"].choices = [("", "None")] + [(board.id, board.name)
                                                         for board in boards]

        # Available labels for this user
        self.fields["label"].choices = [("None", [("", "None")])] + [
            (board.name, [
                (label.id, label.name)
                for label in board.labels.exclude(name="").order_by("name")
            ]) for board in boards
        ]

        # Available members for the work hours package
        self.fields["members"].choices = [
            (member.id, member.external_username)
            for member in current_member.team_mates
        ]
Exemple #5
0
 def all_boards_in_downtime(self):
     resumed_boards = get_member_boards(self).\
         annotate(num_resumed_cards=Count(
                 models.Case(
                     models.When(cards__is_closed=False, cards__list__type="development",  then=1),
                     models.When(cards__is_closed=False, cards__list__type="ready_to_develop",  then=1),
                     default=0,
                     output_field=models.IntegerField()
                 ))
         ).\
         filter(num_resumed_cards__gt=0)
     return not resumed_boards.exists()