Exemplo n.º 1
0
def addtask(request):
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    taskid = taskidMD5(username)
    request.session['taskidMD5'] = taskid
    imgs=IMG.objects.all()
    context = {"userinfo":userinfo[0],"imgs":imgs}
    print("*____________________"* 3)
    if request.method == "POST":
        """输入"""
        input_tasktype = request.POST.get("type",None)
        input_title = request.POST.get("title",None)
        input_description = request.POST.get("description",None)
        input_tags = request.POST.get("tags",None)
        input_status = request.POST.get("status",None)
        """需要添加"""
        input_ctime = initTime() 
        new_task = tasks(
            username_id=username,
            title = input_title,
            tasktype = input_tasktype,
            tags = input_tags,
            c_time = input_ctime,
            status = input_status, 
            description = input_description,
        ) 
        new_task.save()
        # print("新任务的ID号:"+ str(new_task.id))
        IMG.objects.filter(active=taskid).update(task_id=new_task.id,active=None)         
        # print(input_tasktype,input_title,input_description,input_tags,input_status)
        return HttpResponseRedirect('task/tasklist.html',context)
    return render(request,'task/addtask.html',context)
Exemplo n.º 2
0
def logout(request):
    username = request.session.get('username', None)
    request.session.clear()
    userinfo = models.UserInfo.objects.filter(username=username)
    l_time = initTime()
    userinfo.update(l_time=l_time)
    return render(request, 'Users/login.html')
Exemplo n.º 3
0
def add_task_point(request):
    input_task_id = request.GET.get("task_id",None)
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    task_point_info = task_point.objects.all().filter(task_id=input_task_id)
    context = {"userinfo":userinfo[0],"task_point_info":task_point_info,"task_id":input_task_id}
    if input_task_id != None:
        context = {"userinfo":userinfo[0],"task_point_info":task_point_info,"task_id":input_task_id}
        if request.method == "POST":
            input_ctime = initTime()
            input_status = request.POST.get("type",None)
            input_title = request.POST.get("title",None) 
            if input_title != None:
                if input_status != 2:
                    new_task_point = task_point(
                        title = input_title,
                        c_time = input_ctime,
                        f_time = input_ctime,
                        status = input_status,
                        task_id = input_task_id
                    )
                    new_task_point.save() 
                else:
                    new_task_point = task_point(
                        title = input_title,
                        c_time = input_ctime,
                        status = input_status,
                        task_id = input_task_id
                    )
                    new_task_point.save()
              
    else:
        context = {"userinfo":userinfo[0],"task_point_info":task_point_info,"status":"没有如此ID","task_id":None}
    return render(request,'task/add_task_point.html',context)
Exemplo n.º 4
0
def adduser(request):
    if request.method == "POST":
        input_username = request.POST.get("username", None)
        input_password = request.POST.get("password", None)
        input_confirm_password = request.POST.get("confirm_password", None)
        input_captcha = request.POST.get("captcha", None)
        input_email = request.POST.get("email", None)
        captcha = request.session.get("code", None)
        input_argv = [
            input_username, input_password, input_confirm_password,
            input_captcha, input_email
        ]
        userinfo = models.UserInfo.objects.filter(username=input_username)
        emailinfo = models.UserInfo.objects.filter(email=input_email)
        for argv in input_argv:
            if argv == None:
                error_msg = "必须全部填写"
                return render(request, "Users/adduser.html",
                              {'error_msg': error_msg})
            else:
                if len(userinfo) > 0:
                    error_msg = "用户已存在"
                    return render(request, "Users/adduser.html",
                                  {'error_msg': error_msg})
                if len(emailinfo) > 0:
                    error_msg = "该邮箱已经注册了用户!"
                    return render(request, "Users/adduser.html",
                                  {'error_msg': error_msg})
                if input_password != input_confirm_password:
                    error_msg = "两次输入的密码不一致"
                    return render(request, "Users/adduser.html",
                                  {'error_msg': error_msg})
                elif captcha.lower() != input_captcha.lower():
                    error_msg = "验证码错误"
                    return render(request, "Users/adduser.html",
                                  {'error_msg': error_msg})
                password = make_password(input_password)
                email = input_email
                c_time = initTime()
                print(c_time)
                models.UserInfo.objects.create(username=input_username,
                                               password=password,
                                               email=email,
                                               c_time=c_time)
                status = "恭喜,注册成功"
                return render(request, 'Users/login.html',
                              {'error_msg': status})
    return render(request, 'Users/adduser.html')
Exemplo n.º 5
0
def complatetask(request):
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    taskinfolist = tasks.objects.all()
    context = {"userinfo":userinfo[0],"taskinfolist":taskinfolist}
    """获取复选框值"""
    check_box_list = request.GET.getlist('ids[]')
    """获取taskid对象"""
    for input_task_id in check_box_list:
        """获取对象"""
        taskinfo = tasks.objects.filter(id=input_task_id)
        """只有状态为进行中的时候才可以修改状态"""
        """修改完成时间"""
        if taskinfo[0].status == 1:
            input_ftime = initTime() 
            taskinfo.update(status=2,f_time=input_ftime)
    return HttpResponseRedirect('/task/tasklist.html',context)
Exemplo n.º 6
0
def edit_task_point(request):
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    input_task_id = request.GET.get("task_id",None)
    input_task_point_id = request.GET.get("task_point_id",None)
    task_point_info = task_point.objects.all().filter(task_id=input_task_id)
    task_point1 = task_point.objects.all().filter(id=input_task_point_id)
    context = {"userinfo":userinfo[0],"task_point_info":task_point_info,"task_id":input_task_id,"task_point1":task_point1[0]}
    if request.method == "POST":
        input_f_time = initTime() 
        input_title = request.POST.get("title",None)
        input_status = request.POST.get("type",None)
        task_point1.update(title=input_title,status=input_status)
        if input_status == "2":
            task_point1.update(f_time=input_f_time)
        else:
            task_point1.update(f_time=None)
    return render(request,'task/edit_task_point.html',context)
Exemplo n.º 7
0
def done_task_point(request):
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    input_task_id = request.GET.get("task_id",None)
    input_task_point_id = request.GET.get("task_point_id",None)
    taskinfo = tasks.objects.all().filter(id=input_task_id)
    task_point_info = task_point.objects.all().filter(task_id=input_task_id)
    task_point1 = task_point.objects.all().filter(id=input_task_point_id)
    context = {"userinfo":userinfo[0],"task_point_info":task_point_info,"task_id":input_task_id,"task_point1":task_point1[0]}
    input_f_time = initTime() 
    if task_point1[0].status != 2:
        task_point1.update(status=2)
    if task_point1[0].f_time == None:
        task_point1.update(f_time=input_f_time)
    if  taskinfo[0].s_time == None: 
        taskinfo.update(s_time=input_f_time)
    if  taskinfo[0].status == 0:
        taskinfo.update(status= 1)
    return HttpResponseRedirect('/task/add_task_point/?task_id={}'.format(input_task_id),context)
Exemplo n.º 8
0
def starttask(request):
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.filter(username=username)
    taskinfolist = tasks.objects.all()
    """获取复选框值"""
    check_box_list = request.GET.getlist('ids[]')
    """点击启动,如何启动时间为None则修改启动时间,修改task状态"""
    for input_task_id in check_box_list:
        """获取id的对象"""
        taskinfo = tasks.objects.filter(id=input_task_id)
        """只有状态是未启动【0】的时候才会启动"""
        if taskinfo[0].status == 0:
            taskinfo.update(status=1)
        """修改启动时间"""
        if taskinfo[0].s_time == None:
            input_stime = initTime() 
            taskinfo.update(s_time=input_stime)
    context = {"userinfo":userinfo[0],"taskinfolist":taskinfolist}
    return HttpResponseRedirect('/task/tasklist.html',context)
Exemplo n.º 9
0
def Solve_doc(request):
    """获取任务ID"""
    task_id = request.GET.get("task_id", None)
    taskinfo = tasks.objects.all().filter(id=task_id)[0]
    """用户信息"""
    username = request.session.get("username", None)
    userinfo = UserInfo.objects.all().filter(username=username)[0]
    """如何存在任务文档直接返回,反则创建新的文档"""
    if taskinfo.doc_id == None:
        """标题等于任务名称"""
        title = taskinfo.title
        """markdown文件名字"""
        new_md_name = NameMD5()
        with open("{_dir}/wiki/doc/{_docname}".format(_dir=MEDIA_ROOT,
                                                      _docname=new_md_name),
                  "w",
                  encoding='utf-8') as f:
            f.write("# 请开始你的表演")
            f.close()
        """写入数据库"""
        new_doc = doc(
            title=title,
            c_time=initTime(),
            content=new_md_name,
            username_id=username,
        )
        new_doc.save()
        """更新文档ID到任务表"""
        tasks.objects.filter(id=task_id).update(doc_id=new_doc.id)
        docinfo = doc.objects.all().filter(id=new_doc.id)
        content = {"docinfo": docinfo}
        return render(request, "wiki/adddoc.html", content)
    else:
        doc_id = taskinfo.doc_id
        docinfo = doc.objects.all().filter(id=doc_id)
        # 获取tag
        taskinfo = tasks.objects.all().filter(id=taskinfo.id)
        taskinfo = tag_tagcolor(taskinfo)
        content = {"docinfo": docinfo, "taskinfo": taskinfo[0]}
        return render(request, 'wiki/showdoc.html', content)
    return render(request, "wiki/adddoc.html", content)