예제 #1
0
def group_index(request, template_name):
    ''' 组管理 '''
    if request.POST:
        gname = request.REQUEST.get("gname")
        members = request.REQUEST.getlist("members")
        members_id_all = []
        for row_id in members:
            members_id_all.append(str(row_id))

        if request.POST['action'] == 'add':
            try:
                UserGroup.objects.create(gname=gname,
                                         members=",".join(members_id_all))
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            pk = request.POST['pk']
            try:
                UserGroup.objects.filter(pk=pk).update(
                    gname=gname, members=",".join(members_id_all))
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    queryset = UserGroup.objects.all()
    user_list = UserProfile.objects.all()
    search_fields = ['gname']
    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={'user_list': user_list})
예제 #2
0
def task_info(request, template_name):
    _keyword = request.REQUEST.get('keyword', "0")
    _taskstatus = request.REQUEST.get('taskstatus', "9")
    if _keyword != "0" and _taskstatus == "9":
        starttime = request.GET['start_time']
        endtime = request.GET['end_time']
        _t = request.REQUEST.get('t', "today")
        queryset = taskinfo.objects.filter(dramaurl__contains=_keyword,
                                           stime__range=[starttime, endtime
                                                         ]).order_by("-id")
    elif _keyword != "0" and _taskstatus != "9":
        starttime = request.GET['start_time']
        endtime = request.GET['end_time']
        _t = request.REQUEST.get('t', "today")
        queryset = taskinfo.objects.filter(
            dramaurl__contains=_keyword,
            stime__range=[starttime, endtime],
            downloadstatus=_taskstatus).order_by("-id")
    else:
        pass

    search_fields = ['episode']
    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={
                                      't': _t,
                                      'u_stime': starttime,
                                      'u_etime': endtime,
                                      'keyword': _keyword,
                                      'taskstatus': _taskstatus
                                  })
예제 #3
0
def class_index(request,template_name):
    if request.method == 'GET':
        queryset=appclass.objects.all()
    elif request.method == 'POST':
        classid=request.POST["classid"]
        classname=request.POST["classname"]
        pk=request.POST["pk"]
        if request.POST['action'] == 'add':
            try:
                class_base=appclass.objects.create(classid=classid,classname=classname)
                class_base.save()
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            try:
                class_base=appclass.objects.filter(pk=pk).update(classid=classid,classname=classname)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    search_fields = ['classname','classid']
    return get_datatables_records(
        request,
        queryset,
        search_fields,
        template_name,
        extra_context={
        })
예제 #4
0
def playsource_index(request, template_name):
    queryset = channel.objects.all().order_by('channelid')
    search_fields = ['channelid', 'channelname']
    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={})
예제 #5
0
def spider_index(request, template_name):
    queryset = taskmain.objects.all().order_by('-id')
    search_fields = ['dirpath']
    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={})
예제 #6
0
def user_index(request, template_name):
    ''' 用户中心 '''
    queryset = UserProfile.objects.all()
    search_fields = ['user__username', 'id']
    if request.POST:
        first_name=request.POST["first_name"]
        username=request.POST["username"]
        password=request.POST["password"]
        mobile=request.POST["mobile"]
        is_active=request.POST["id_is_active"]
        email=request.POST["email"]
        department=request.POST["department"]

        if request.POST['action'] == 'add':
            try:
                user = User.objects.create_user(username, email, password)
                user.first_name=first_name
                if is_active == "true":
                    user.is_staff=True
                else:
                    user.is_staff=False
                user.save()
                UserProfile.objects.filter(user__username=username).update(mobile=mobile, department=department)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            pk=request.POST["pk"]
            try:
                user = User.objects.filter(username=username).update(username=username, email=email,first_name=first_name)
#                if is_active == "True":
#                    User.objects.filter(id=pk).update(username=username, email=email,first_name=first_name, is_active=1)
#                else:
#                    User.objects.filter(id=pk).update(username=username, email=email,first_name=first_name,is_active=0)
                UserProfile.objects.filter(user__username=username).update(mobile=mobile, department=department)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    return get_datatables_records(
        request,
        queryset,
        search_fields,
        template_name,
        extra_context={
            'queryset_user': queryset
        })
예제 #7
0
def store_index(request, template_name):
    if request.method == 'GET':
        _cid = request.REQUEST.get('classid', "0")
        if _cid != "0":
            queryset=appclassinfo.objects.filter(classid=_cid).order_by('-pk')
        else:
            queryset=appclassinfo.objects.all().order_by('-pk')

    elif request.method == 'POST':
        classid=request.POST["classid"]
        appid=request.POST["appid"]
        appname=request.POST["appname"]
        appsearch=request.POST["appsearch"]
        appdesc=request.POST["appdesc"]
        level=request.POST["level"]
        if request.POST['action'] == 'add':
            try:
                app_base=appclassinfo.objects.create(classid=classid,appid=appid,appname=appname,appsearch=appsearch)
                app_base.save()
                app_info=appinfo.objects.create(appid=appid,appdesc=appdesc,level=level)
                app_info.save()
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            try:
                upappbase=appclassinfo.objects.filter(appid=appid)
                upappinfo=appinfo.objects.filter(appid=appid)
                upappbase.update(classid=classid,appid=appid,appname=appname,appsearch=appsearch)
                upappinfo.update(appdesc=appdesc,level=level)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    classinfo=appclass.objects.all()
    search_fields = ['appid','appfolder','appname','appsearch']
    return get_datatables_records(
        request,
        queryset,
        search_fields,
        template_name,
        extra_context={
            'classinfo':classinfo
        })
예제 #8
0
def group_index(request, template_name):
    ''' 组管理 '''
    if request.POST:
        gname=request.REQUEST.get("gname")
        members=request.REQUEST.getlist("members")
        members_id_all=[]
        for row_id in members:
            members_id_all.append(str(row_id))

        if request.POST['action'] == 'add':
            try:
                UserGroup.objects.create(
                    gname=gname,
                    members=",".join(members_id_all)
                )
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            pk=request.POST['pk']
            try:
                UserGroup.objects.filter(pk=pk).update(
                    gname=gname,
                    members=",".join(members_id_all)
                )
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    queryset=UserGroup.objects.all()
    user_list=UserProfile.objects.all()
    search_fields = ['gname']
    return get_datatables_records(
        request,
        queryset,
        search_fields,
        template_name,
        extra_context={
            'user_list':user_list
        })
예제 #9
0
def task_log(request, template_name):
    _pid = request.REQUEST.get('channelid', "0")
    _taskstatus = request.REQUEST.get('taskstatus', "9")
    if _pid != "0" and _taskstatus == "9":
        starttime = request.GET['start_time']
        endtime = request.GET['end_time']
        _t = request.REQUEST.get('t', "today")
        cname = channel.objects.get(channelid=_pid).channelname
        queryset = channel_task.objects.filter(
            channelid=_pid, stime__range=[starttime,
                                          endtime]).order_by('stime')
    elif _pid != "0" and _taskstatus != "9":
        starttime = request.GET['start_time']
        endtime = request.GET['end_time']
        _t = request.REQUEST.get('t', "today")
        cname = channel.objects.get(channelid=_pid).channelname
        queryset = channel_task.objects.filter(
            channelid=_pid,
            stime__range=[starttime, endtime],
            taskstatus=_taskstatus).order_by('stime')
    else:
        pass

    search_fields = ['locatename']
    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={
                                      't': _t,
                                      'u_stime': starttime,
                                      'u_etime': endtime,
                                      'channelid': _pid,
                                      'channelname': cname,
                                      'taskstatus': _taskstatus
                                  })
예제 #10
0
def user_index(request, template_name):
    ''' 用户中心 '''
    queryset = UserProfile.objects.all()
    search_fields = ['user__username', 'id']
    if request.POST:
        first_name = request.POST["first_name"]
        username = request.POST["username"]
        password = request.POST["password"]
        mobile = request.POST["mobile"]
        is_active = request.POST["is_active"]

        if request.POST['is_create'] == "true":
            is_create = 0
        else:
            is_create = 1
        if request.POST['is_modify'] == "true":
            is_modify = 0
        else:
            is_modify = 1
        if request.POST['is_delete'] == "true":
            is_delete = 0
        else:
            is_delete = 1
        email = request.POST["email"]
        department = request.POST["department"]

        if request.POST['action'] == 'add':
            try:
                user = User.objects.create_user(username, email, password)
                user.first_name = first_name
                if is_active == "true":
                    user.is_staff = True
                else:
                    user.is_staff = False
                user.save()
                UserProfile.objects.filter(user__username=username).update(
                    mobile=mobile,
                    department=department,
                    is_delete=is_delete,
                    is_create=is_create,
                    is_modify=is_modify)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))
        else:
            pk = request.POST["pk"]
            try:
                #                user = User.objects.filter(username=username).update(username=username, email=email,first_name=first_name)
                if is_active == "true":
                    User.objects.filter(id=pk).update(username=username,
                                                      email=email,
                                                      first_name=first_name,
                                                      is_active=1)
                else:
                    User.objects.filter(id=pk).update(username=username,
                                                      email=email,
                                                      first_name=first_name,
                                                      is_active=0)
                UserProfile.objects.filter(user__username=username).update(
                    mobile=mobile,
                    department=department,
                    is_delete=is_delete,
                    is_create=is_create,
                    is_modify=is_modify)
                return HttpResponse('ok')
            except Exception as error:
                return HttpResponse(str(error))

    return get_datatables_records(request,
                                  queryset,
                                  search_fields,
                                  template_name,
                                  extra_context={'queryset_user': queryset})