コード例 #1
0
    def unfinished(user_groups):
        from bmp.models.user import Group, User

        purchases = []
        uid = session[USER_SESSION]["uid"]
        group = set(User.get(uid)["group"]).intersection(PURCHASE.FLOW)
        group_map = {}
        for g in Group.select(to_dict=False):
            group_map[g.name.upper()] = g.desc

        for purchase in Purchase.query \
                .filter(Purchase.is_draft == False) \
                .filter(Purchase.is_finished == False).order_by(Purchase.apply_time.desc()).all():

            approvals = purchase.approvals
            apply_uid = purchase.apply_uid
            cur_approval_type = purchase.cur_approval_type
            purchase.cur_approval_type_desc = ""
            purchase.approval_enable = False
            is_append = False

            if group_map.__contains__(cur_approval_type.upper()):
                purchase.cur_approval_type_desc = group_map[
                    cur_approval_type.upper()]

            if uid in [purchase.apply_uid] + [a.uid for a in approvals] \
                    or group.intersection([a.type for a in approvals]):
                purchases.append(purchase)
                is_append = True

            if cur_approval_type == PURCHASE.FLOW_ONE:
                if Purchase.__is_superior(uid, apply_uid):
                    purchase.approval_enable = True
                    if not is_append:
                        purchases.append(purchase)
            elif uid in user_groups[cur_approval_type]:
                purchase.approval_enable = True
                if not is_append:
                    purchases.append(purchase)
            else:
                continue
        return [
            Purchase._to_dict(p, ["approval_enable", "cur_approval_type_desc"])
            for p in purchases
        ]
コード例 #2
0
ファイル: purchase.py プロジェクト: xutaoding/bmp
    def unfinished(user_groups):
        from bmp.models.user import Group, User

        purchases = []
        uid = session[USER_SESSION]["uid"]
        group = set(User.get(uid)["group"]).intersection(PURCHASE.FLOW)
        group_map = {}
        for g in Group.select(to_dict=False):
            group_map[g.name.upper()] = g.desc

        for purchase in Purchase.query \
                .filter(Purchase.is_draft == False) \
                .filter(Purchase.is_finished == False).order_by(Purchase.apply_time.desc()).all():

            approvals = purchase.approvals
            apply_uid = purchase.apply_uid
            cur_approval_type = purchase.cur_approval_type
            purchase.cur_approval_type_desc = ""
            purchase.approval_enable = False
            is_append = False

            if group_map.__contains__(cur_approval_type.upper()):
                purchase.cur_approval_type_desc = group_map[cur_approval_type.upper()]

            if uid in [purchase.apply_uid] + [a.uid for a in approvals] \
                    or group.intersection([a.type for a in approvals]):
                purchases.append(purchase)
                is_append = True

            if cur_approval_type == PURCHASE.FLOW_ONE:
                if Purchase.__is_superior(uid, apply_uid):
                    purchase.approval_enable = True
                    if not is_append:
                        purchases.append(purchase)
            elif uid in user_groups[cur_approval_type]:
                purchase.approval_enable = True
                if not is_append:
                    purchases.append(purchase)
            else:
                continue
        return [Purchase._to_dict(p, ["approval_enable", "cur_approval_type_desc"]) for p in purchases]
コード例 #3
0
 def get(self, name="%"):
     return self.succ(Group.select(name))