Пример #1
0
def issue_detail(request, project_id, issue_id):
    instance = models.Issues.objects.filter(project_id=project_id,
                                            id=issue_id).first()
    form = IssuesModelForm(request, instance=instance)
    return render(request, 'web/issue_detail.html', {
        'form': form,
        'issues_object': instance
    })
Пример #2
0
def issues(request, project_id):
    if request.method == "GET":
        # 分页获取数据
        queryset = models.Issues.objects.filter(project_id=project_id)
        page_object = Pagination(current_page=request.GET.get('page'),
                                 all_count=queryset.count(),
                                 base_url=request.path_info,
                                 query_params=request.GET,
                                 per_page=1)
        issues_object_list = queryset[page_object.start:page_object.end]
        form = IssuesModelForm(request)
        return render(
            request, 'web/issues.html', {
                'form': form,
                'issues_object_list': issues_object_list,
                'page_html': page_object.page_html()
            })
    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        # 添加问题
        form.instance.project = request.bug_mgt.project
        form.instance.creator = request.bug_mgt.user
        form.save()
        return JsonResponse({'status': True})
    return JsonResponse({'status': False, 'error': form.errors})
Пример #3
0
def issues_detail(request, project_id, issues_id):
    """ 编辑问题 """
    issues_object = models.Issues.objects.filter(
        id=issues_id, project_id=project_id).first()
    form = IssuesModelForm(request, instance=issues_object)
    return render(request, 'issues_detail.html', {
        'form': form,
        "issues_object": issues_object
    })
Пример #4
0
def issues_detail(request, project_id, issues_id):
    """问题编辑"""
    issues_object = Issues.objects.filter(id=issues_id,
                                          project_id=project_id).first()
    form = IssuesModelForm(request, instance=issues_object)
    return render(request, 'web/issues_detail.html', {
        'form': form,
        'issues_object': issues_object
    })
Пример #5
0
def issues_detail(request, project_id, issues_id):
    """问题详细"""
    issues_obj = Issues.objects.filter(id=issues_id,
                                       project_id=project_id).first()
    form = IssuesModelForm(request, instance=issues_obj)

    context = {
        "form": form,
        'issues_obj': issues_obj,
    }
    return render(request, 'web/issues_detail.html', context)
Пример #6
0
def issues_record(request, project_id, issues_id):
    """初始化操作记录"""
    # 判断是否可以评论和是否可以操作这个问题
    if request.method == "GET":
        reply_list = models.IssuesReply.objects.filter(
            issues_id=issues_id, issues__project=request.tracer.project)
        # 将querSet转换为json格式
        data_list = []
        for row in reply_list:  # 构造页面上需要展示的字段
            data = {
                "id": row.id,
                "reply_type_text": row.get_reply_type_display(),
                "content": row.content,
                "creator": row.creator.username,
                "datetime": row.create_datetime.strftime("%Y-%m-%d %H:%M"),
                "parent_id": row.reply_id
            }
            data_list.append(data)
        return JsonResponse({"status": True, "data": data_list})

    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        form.instance.issues_id = issues_id
        form.instance.reply_type = 2
        form.instance.creator = request.tracer.user
        instance = form.save()
        info = {
            'id': instance.id,
            'reply_type_text': instance.get_reply_type_display(),
            'content': instance.content,
            'creator': instance.creator.username,
            'datetime': instance.create_datetime.strftime("%Y-%m-%d %H:%M"),
            'parent_id': instance.reply_id
        }

        return JsonResponse({'status': True, 'data': info})
    return JsonResponse({"status": False, "error": form.errors})
Пример #7
0
def issues_detail(request, project_id, issues_id):
    """
    编辑问题页面
    :param request:
    :param project_id:
    :param issues_id:
    :return:
    """
    issues_object = models.Issues.objects.filter(
        id=issues_id, project_id=project_id).first()

    form = IssuesModelForm(request, instance=issues_object)
    return render(request, "issues_detail.html", {
        "form": form,
        "issues_object": issues_object
    })
Пример #8
0
def issues(request, project_id):
    if request.method == 'GET':
        # 筛选条件
        allow_filter_name = ['issues_type', 'status', 'priority', ]
        condition = {}
        for name in allow_filter_name:
            value_list = request.GET.getlist(name)
            if not value_list:
                continue
            condition[f'{name}__in'] = value_list

        queryset = models.Issues.objects.filter(project_id=project_id).filter(**condition)
        page_object = Pagination(
            current_page=request.GET.get('page'),
            all_count=queryset.count(),
            base_url=request.path_info,
            query_params=request.GET,
            per_page=10,
        )
        issues_object_list = queryset[page_object.start:page_object.end]

        form = IssuesModelForm(request)
        project_issues_type = models.IssuesType.objects.filter(project_id=project_id).values_list('id', 'title')
        project_total_user = [(request.tracer.project.creator_id, request.tracer.project.creator.username)]
        join_user = models.ProjectUser.objects.filter(project_id=project_id).values_list('user_id', 'user__username')
        project_total_user.extend(join_user)
        invite_form = InviteModelForm()
        context = {'form': form,
                   'invite_form': invite_form,
                   'issues_object_list': issues_object_list,
                   'page_html': page_object.page_html(),
                   'filter_list': [
                       {'title': "问题类型", 'filter': CheckFilter('issues_type', project_issues_type, request)},
                       {'title': "状态", 'filter': CheckFilter('status', models.Issues.status_choices, request)},
                       {'title': "优先级", 'filter': CheckFilter('priority', models.Issues.priority_choices, request)},
                       {'title': "指派者", 'filter': SelectFilter('assign', project_total_user, request)},
                       {'title': "关注者", 'filter': SelectFilter('attention', project_total_user, request)},
                   ]
                   }
        return render(request, 'issues.html', context)
    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        form.instance.creator = request.tracer.user
        form.instance.project = request.tracer.project
        form.save()
        return JsonResponse({'status': True})
    return JsonResponse({'status': False, 'error': form.errors})
Пример #9
0
def issues(request, project_id):
    if request.method == "GET":
        # 根据URL做筛选,筛选条件(根据用户通过GET传过来的参数实现)
        # ?status=1&status=2&issues_type=1
        allow_filter_name = [
            "issues_type",
            "status",
            "priority",
            "assign",
            "attention",
        ]
        condition = {}
        for name in allow_filter_name:
            value_list = request.GET.getlist(name)  # [1,2]
            if not value_list:
                continue
            condition["{}__in".format(name)] = value_list
        """
        condition = {
            "status__in":[1,2],
            'issues_type':[1,]
        }
        """

        # 分页获取数据
        queryset = models.Issues.objects.filter(project_id=project_id).filter(
            **condition)
        page_object = Pagination(
            current_page=request.GET.get("page"),
            all_count=queryset.count(),
            base_url=request.path_info,
            query_params=request.GET,
            per_page=50,
        )
        issues_object_list = queryset[page_object.start:page_object.end]

        form = IssuesModelForm(request)

        project_issues_type = models.IssuesType.objects.filter(
            project_id=project_id).values_list("id", "title")

        project_total_user = [(
            request.tracer.project.creator_id,
            request.tracer.project.creator.username,
        )]
        join_user = models.ProjectUser.objects.filter(
            project_id=project_id).values_list("user_id", "user__username")
        project_total_user.extend(join_user)

        invite_form = InviteModelForm()
        context = {
            "form":
            form,
            "invite_form":
            invite_form,
            "issues_object_list":
            issues_object_list,
            "page_html":
            page_object.page_html(),
            "filter_list": [
                {
                    "title":
                    "问题类型",
                    "filter":
                    CheckFilter("issues_type", project_issues_type, request),
                },
                {
                    "title":
                    "状态",
                    "filter":
                    CheckFilter("status", models.Issues.status_choices,
                                request),
                },
                {
                    "title":
                    "优先级",
                    "filter":
                    CheckFilter("priority", models.Issues.priority_choices,
                                request),
                },
                {
                    "title": "指派者",
                    "filter": SelectFilter("assign", project_total_user,
                                           request),
                },
                {
                    "title":
                    "关注者",
                    "filter":
                    SelectFilter("attention", project_total_user, request),
                },
            ],
        }
        return render(request, "issues.html", context)

    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        form.instance.project = request.tracer.project
        form.instance.creator = request.tracer.user
        form.save()
        return JsonResponse({"status": True})

    return JsonResponse({"status": False, "error": form.errors})
Пример #10
0
def issues(request, project_id):
    """问题首页"""
    if request.method == 'GET':
        form = IssuesModelForm(request)
        invite_form = InviteModelForm()
        # ####### 根据条件查询
        # 根据URL做筛选,筛选条件(根据用户通过GET传过来的参数实现)
        # ?status=1&status=2&issues_type=1
        allow_filter_name = [
            'issues_type', 'priority', 'status', 'assign', 'attention'
        ]
        condition = {}
        for name in allow_filter_name:
            value_list = request.GET.getlist(name)
            if not value_list:
                continue
            condition['{}__in'.format(name)] = value_list
        """
        condition = {
            "status__in":[1,2],
            'issues_type__in':[1,]
        }
        """

        # ####### 分页展示
        queryset = Issues.objects.filter(project_id=project_id).filter(
            **condition)
        page_object = Pagination(current_page=request.GET.get('page'),
                                 all_count=queryset.count(),
                                 base_url=request.path_info,
                                 query_params=request.GET,
                                 per_page=3)
        issues_object_list = queryset[page_object.start:
                                      page_object.end]  # 分页之后的对象

        issues_type_choices = IssuesType.objects.filter(
            project_id=project_id).values_list('id', 'title')
        project_user_choices = [(request.tracer.project.creator.id,
                                 request.tracer.project.creator.username)]
        project_user = ProjectUser.objects.filter(
            project_id=project_id).values_list('user_id', 'user__username')
        project_user_choices.extend(project_user)
        context = {
            'form':
            form,
            'invite_form':
            invite_form,
            'issues_object_list':
            issues_object_list,
            'page_html':
            page_object.page_html(),
            'filter_list': [
                {
                    'title':
                    '问题类型',
                    'filter':
                    CheckFilter('issues_type', issues_type_choices, request)
                },
                {
                    'title': '状态',
                    'filter': CheckFilter('status', Issues.status_choices,
                                          request)
                },
                {
                    'title':
                    '优先级',
                    'filter':
                    CheckFilter('priority', Issues.priority_choices, request)
                },
                {
                    'title': '指派人',
                    'filter': SelectFilter('assign', project_user_choices,
                                           request)
                },
                {
                    'title':
                    '关注者',
                    'filter':
                    SelectFilter('attention', project_user_choices, request)
                },
            ],
            #
            # 'status_list': CheckFilter('status', Issues.status_choices, request),
            # 'priority_list': CheckFilter('priority', Issues.priority_choices, request),
            # 'issues_type_list': CheckFilter('issues_type', issues_type_choices, request)
            #
        }

        return render(request, 'web/issues.html', context)

    # POST方法
    if request.method == 'POST':
        form = IssuesModelForm(request, data=request.POST)
        if form.is_valid():

            form.instance.project_id = project_id
            form.instance.creator = request.tracer.user

            form.save()
            return JsonResponse({'status': True})

        return JsonResponse({'status': False, 'error': form.errors})
Пример #11
0
def issues(request, project_id):
    """问题栏"""
    if request.method == "GET":
        # 筛选条件 -- 通过get来实现参数筛选
        allow_filter_name = [
            'issues_type', 'status', 'priority', 'assign', 'attention'
        ]
        condition = {}  # 条件
        for name in allow_filter_name:
            value_list = request.GET.getlist(name)

            if not value_list:
                continue

            condition['{}__in'.format(name)] = value_list

        # 分页获取数据
        form = IssuesModelForm(request)

        issues_obj = Issues.objects.filter(
            project=request.tracer.project).filter(**condition)

        page_object = Pagination(
            current_page=request.GET.get('page'),
            all_count=issues_obj.count(),
            base_url=request.path_info,
            query_params=request.GET,
            per_page=3,
        )
        issues_object_list = issues_obj[page_object.start:page_object.end]

        project_total_user = [(
            request.tracer.project.create_user_id,
            request.tracer.project.create_user.username,
        )]
        join_user = ProjectUser.objects.filter(
            project_id=project_id).values_list('user_id', 'user__username')
        project_total_user.extend(join_user)

        invite_form = InviteModelForm(data=request.POST)

        context = {
            'form':
            form,
            'invite_form':
            invite_form,
            'issues_object_list':
            issues_object_list,
            'page_html':
            page_object.page_html(),
            'filter_list': [
                {
                    'title':
                    '问题类型',
                    'filter':
                    CheckFilter(
                        'issues_type',
                        IssuesType.objects.filter(
                            project_id=project_id).values_list('id', 'title'),
                        request)
                },
                {
                    'title': '状态',
                    'filter': CheckFilter('status', Issues.STATUS_CHOICES,
                                          request)
                },
                {
                    'title':
                    '优先级',
                    'filter':
                    CheckFilter('priority', Issues.PRIORITY_CHOICES, request)
                },
                {
                    'title': '指派者',
                    'filter': SelectFilter('assign', project_total_user,
                                           request)
                },
                {
                    'title':
                    '关注者',
                    'filter':
                    SelectFilter('attention', project_total_user, request)
                },
            ]
        }
        return render(request, 'web/issues.html', context)

    if request.method == "POST":
        form = IssuesModelForm(request, data=request.POST)

        if form.is_valid():
            # 添加问题数据
            form.instance.project = request.tracer.project
            form.instance.create_user = request.tracer.user

            form.save()

            return JsonResponse({'code': 200})

        return JsonResponse({'msg': form.errors, 'code': 416})
Пример #12
0
def issues(request, project_id):
    if request.method == 'GET':
        # 根据URL携带的参数做筛选。URL类似:?status=1&status&=2&issues_type=1

        allow_filter_name = [
            'issues_type', 'status', 'priority', 'assign', 'attention'
        ]
        condition = {}
        for name in allow_filter_name:
            value_list = request.GET.get(name)
            if value_list:
                condition['{}__in'.format(name)] = value_list
        queryset = models.Issues.objects.filter(project_id=project_id).filter(
            **condition)
        # 分页获取数据
        page_object = Pagination(
            current_page=request.GET.get('page'),
            all_count=queryset.count(),
            base_url=request.path_info,
            query_params=request.GET,
            per_page=5,
        )
        issues_obj_list = queryset[page_object.start:page_object.end]

        form = IssuesModelForm(request)

        project_issues_type = models.IssuesType.objects.filter(
            project_id=project_id).values_list('id', 'title')

        project_total_user = [(request.lxyker.project.creator_id,
                               request.lxyker.project.creator.username)]
        join_user = models.ProjectUser.objects.filter(
            project_id=project_id).values_list('user_id', 'user__username')
        project_total_user.extend(join_user)

        invite_form = InviteModelForm()

        context = {
            'invite_form':
            invite_form,
            'form':
            form,
            'issues_obj_list':
            issues_obj_list,
            'page_html':
            page_object.page_html(),
            'filter_list': [
                {
                    'title':
                    '问题类型',
                    'filter':
                    CheckFilter('issues_type', project_issues_type, request),
                },
                {
                    'title':
                    '状态',
                    'filter':
                    CheckFilter('status', models.Issues.status_choices,
                                request),
                },
                {
                    'title':
                    '优先级',
                    'filter':
                    CheckFilter('priority', models.Issues.priority_choices,
                                request),
                },
                {
                    'title': '指派者',
                    'filter': SelectFilter('assign', project_total_user,
                                           request),
                },
                {
                    'title':
                    '关注者',
                    'filter':
                    SelectFilter('attention', project_total_user, request),
                },
            ],
        }
        return render(request, 'web/issues.html', context)

    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        # 数据校验无误
        form.instance.project = request.lxyker.project
        form.instance.creator = request.lxyker.user
        form.save()
        return JsonResponse({'status': True})
    return JsonResponse({'status': False, 'error': form.errors})
Пример #13
0
def issues(request, project_id):
    """ 问题展示及添加 """
    if request.method == 'GET':
        # 筛选条件(根据用户通过GET传过来的参数
        allow_filter_list = [
            'issues_type', 'status', 'priority', 'assign', 'attention'
        ]
        condition = {}
        for name in allow_filter_list:
            value_list = request.GET.getlist(name)  # 获取所有的值 [1,2,3]
            if not value_list:
                continue

            condition['{}__in'.format(name)] = value_list
        queryset = models.Issues.objects.filter(
            project=request.tracer.project).filter(**condition)
        page_object = Pagination(
            current_page=request.GET.get('page'),
            all_count=queryset.count(),
            base_url=request.path_info,
            query_params=request.GET,
        )
        issues_object_list = queryset[page_object.start:page_object.end]
        form = IssuesModelForm(request)

        issues_type_list = models.IssuesType.objects.filter(
            project_id=project_id).values_list('id', 'title')

        project_total_user = [
            (request.tracer.project.creator_id,
             request.tracer.project.creator.username),
        ]
        project_join_user = models.ProjectUser.objects.filter(
            project_id=project_id).values_list('user_id', 'user__username')

        project_total_user.extend(project_join_user)

        invite_form = InviteModelForm()
        content = {
            'form':
            form,
            'invite_form':
            invite_form,
            'issues_object_list':
            issues_object_list,
            'page_html':
            page_object.page_html(),
            'filter_list': [
                {
                    'title': '问题类型',
                    'filter': CheckFilter('issues_type', issues_type_list,
                                          request)
                },
                {
                    'title':
                    '状态',
                    'filter':
                    CheckFilter('status', models.Issues.status_choices,
                                request)
                },
                {
                    'title':
                    '优先级',
                    'filter':
                    CheckFilter('priority', models.Issues.priority_choices,
                                request)
                },
                {
                    'title': '指派者',
                    'filter': SelectFilter('assign', project_total_user,
                                           request)
                },
                {
                    'title':
                    '关注者',
                    'filter':
                    SelectFilter('attention', project_total_user, request)
                },
            ],
        }
        return render(request, 'issues.html', content)

    form = IssuesModelForm(request, data=request.POST)
    if form.is_valid():
        form.instance.project = request.tracer.project
        form.instance.creator = request.tracer.user
        # 添加问题
        form.save()
        return JsonResponse({'status': True})
    return JsonResponse({'status': False, 'error': form.errors})