Пример #1
0
def update_requirement(request):
    """
    更新需求
    """
    result = False
    try:
        if request.POST.get("id"):
            rid = request.POST.get("id")
            new_requirement_name = request.POST.get("requirement_name")
            new_requirement_type = int(request.POST.get("requirement_type_name"))
            new_requirement_dept = int(request.POST.get("requirement_dept_name"))
            new_requirement_desc = request.POST.get("requirement_desc")
            localtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())

            update = Requirement.objects.filter(id=rid).update(requirement_name=new_requirement_name,
                                                            requirement_type=new_requirement_type,
                                                            requirement_dept=new_requirement_dept,
                                                            requirement_desc=new_requirement_desc,
                                                            modifier_user = request.user.id,
                                                            gmt_modified = localtime)
            if update == 1:
                result = True
    except:
        pass

    result = getJson(status=result)
    return HttpResponse('[' + result + ']', mimetype="application/javascript")
Пример #2
0
    def getPaginatorJson(self):
        """
        objects:查询的数据列表
        rows:详细显示的记录,默认对应jqGrid中配置的rowNum
        pageNo:当前页码
        """
        paginator = Paginator(self.objects, self.rows)

        if self.pageNo < 1:
            self.pageNo = 1

        if self.pageNo > paginator.num_pages:
            self.pageNo = paginator.num_pages

        page = paginator.page(self.pageNo)

        # total:总页数, page:当前页数, records:总记录数, rows:实际数据
        result = getJson(total=paginator.num_pages, page=self.pageNo, records=paginator.count, rows=page.object_list)
        return result
Пример #3
0
def del_requirement(request):
    """
    删除需求
    """
    result = False
    try:
        if request.POST.get("ids"):
            idstr = request.POST.get("ids")
            if idstr:
                ids = idstr.split(",")
                rids = [int(rid) for rid in ids]
                update = Requirement.objects.filter(id__in=rids).update(status=-1)
                if (update == len(ids)):
                    result = True
    except:
        pass

    if result:
        transaction.commit()
    else:
        transaction.rollback()

    result = getJson(status=result)
    return HttpResponse(result, mimetype="application/javascript")