예제 #1
0
def photoAlbumAdd():
    title = request.form['title']
    isShow = request.form['isShow']
    introduction = request.form['introduction']

    if not strLength(title, 1, 60):
        flash(u'请输入60个字符内的相册名称!')
        return redirect(url_for('admin.photoAlbum'))

    if isShow == 'y':
        isShow = True
    else:
        isShow = False

    if introduction and not strLength(introduction, 1, 1000):
        flash(u'请输入1000个字符内的栏目介绍!')
        return redirect(url_for('admin.photoAlbum'))

    p = Album()
    p.title = title
    p.isShow = isShow
    p.number = Album.objects.count() + 1
    if introduction: p.introduction = introduction
    p.save()
    flash(u'相册创建成功!')
    return redirect(url_for('admin.photoAlbum'))
예제 #2
0
def photoAlbumEdit(id):
    p = Album.objects(id=id).first()
    if request.method == 'GET':
        return render_template('admin/photoAlbumEdit.html', p=p)
    if request.method == 'POST':
        title = request.form['title']
        isShow = request.form['isShow']
        introduction = request.form['introduction']

        if not strLength(title, 1, 60):
            flash(u'请输入60个字符内的相册名称!')
            return redirect(url_for('admin.photoAlbum'))

        if isShow == 'y':
            isShow = True
        else:
            isShow = False

        if introduction and not strLength(introduction, 1, 1000):
            flash(u'请输入1000个字符内的栏目介绍!')
            return redirect(url_for('admin.photoAlbum'))

        p.title = title
        p.isShow = isShow
        p.introduction = introduction
        p.save()
        flash(u'相册修改成功!')
        return redirect(url_for('admin.photoAlbum'))
예제 #3
0
def blogPostAdd(id):
    c = Column.objects(id=id).first()
    if request.method == 'GET':
        return render_template('admin/blogPostAdd.html',c=c)
    if request.method == 'POST':
        title = request.form['title'].strip()
        tags = request.form['tags'].strip()
        video = request.form['video'].strip()
        content = request.form['content']

        if not strLength(title,1,100):
            return jsonify({'status': False, 'info': u'请输入100个字符内的标题'})
        if not strLength(tags,1,60):
            return jsonify({'status': False, 'info': u'请至少输入1个标签,60个字符内'})
        if not strLength(video,0,500):
            return jsonify({'status': False, 'info': u'请至少500个字符内视频嵌入代码'})
        if not strLength(content,1,50000):
            return jsonify({'status': False, 'info': u'请输入50000个字符内的内容'})

        p = Post()
        p.title = title
        p.tags = getTagsFormStrTag(tags)
        p.tagSource = tags
        p.video = video
        p.content = content
        temp = getLeadAndCover(content)
        p.lead = temp[0]
        p.cover = temp[1]
        p.writeTime = getStrTime()
        p.column = c
        p.save()
        c.postCount += 1
        c.save()
        return jsonify({'status': True, 'info': u'文章添加成功'})
예제 #4
0
def kispowerPostShareData(id):
    shareTitle = request.form['shareTitle']
    shareTag = request.form['shareTag']
    shareMode = request.form['shareMode']
    shareIntroduction = request.form['shareIntroduction']
    #检查字段
    if not strLength(shareTitle, 1, 60):
        return jsonify({'status': False, 'msg': u'请输入60个字符内标题'})
    if not strLength(shareTag, 1, 30):
        return jsonify({'status': False, 'msg': u'请输入30个字符内标签'})
    if not strLength(shareIntroduction, 1, 10000):
        return jsonify({'status': False, 'msg': u'请输入10000个字符内简介'})
    shareData = json.loads(request.form['shareData'])
    #必须设置root节点
    source = id + shareData['data']['id']
    shareData['data']['id'] = 'root'
    #设置节点显示模式
    shareData['meta']['displayMode'] = shareMode
    if 'children' in shareData['data'] and len(
            shareData['data']['children']) > 0:
        ks = KShare.objects(source=source).first()
        if ks:
            ks.title = shareTitle
            ks.tag = getTagsFormStrTag(shareTag)
            ks.introduction = shareIntroduction
            ks.introductionHtml = shareIntroduction.replace('\n', '<br>')
            ks.shareTime = getStrTime()
            ks.k = shareData
            ks.save()
            #同步到分享库
            try:
                ks.postKShareToBase(shareTag, current_user.userName,
                                    current_app.config['WEBSITE'],
                                    current_app.config['URL_KSHARE_POST'])
            except:
                pass
            return jsonify({'status': True, 'msg': u'该节点已经分享过,已为你更新为该节点的最新版本'})
        else:
            share = KShare()
            share.title = shareTitle
            share.tag = getTagsFormStrTag(shareTag)
            share.introduction = shareIntroduction
            share.introductionHtml = shareIntroduction.replace('\n', '<br>')
            share.shareTime = getStrTime()
            share.k = shareData
            share.source = source
            share.save()
            #分享到分享库
            try:
                share.postKShareToBase(shareTag, current_user.userName,
                                       current_app.config['WEBSITE'],
                                       current_app.config['URL_KSHARE_POST'])
            except:
                pass
            return jsonify({
                'status': True,
                'msg': u'分享成功!请去管理界面右边菜单栏(知识管理-我的知识分享)查看'
            })
    else:
        return jsonify({'status': False, 'msg': u'该节点没有子节点,不能分享'})
예제 #5
0
def navigationWebEdit(id,number):
    number = int(number)
    n = Navigation.objects(id=id).first()
    w = n.webs[number]

    if request.method == 'GET':
        return render_template('admin/navigationWebEdit.html',n=n,w=w,number=number)

    if request.method == 'POST':
        webName = request.form['webName']
        url = request.form['url']
        icon = request.files.get('img')
        introduction = request.form['introduction']

        if not strLength(webName,1,60):
            flash(u'请输入60个字符内的网站名称!')
            return redirect(url_for('admin.navigationColumnManage', id=id))
        if not strLength(url,1,1000):
            flash(u'请输入1000个字符内的网站url!')
            return redirect(url_for('admin.navigationColumnManage', id=id))
        if not url.startswith('http'):
            flash(u'url开头请带上http://或者https://')
            return redirect(url_for('admin.navigationColumnManage', id=id))
        if introduction and not strLength(introduction,1,1000):
            flash(u'请输入1000个字符内的栏目介绍!')
            return redirect(url_for('admin.navigationColumnManage', id=id))

        #其他字段判断完再判断图片上传
        iconPath = None
        if icon and allowedImage(icon.filename):
            if allowedFileSize(len(icon.read()), 1):
                icon.seek(0)
                fileName = creatFileName(current_user.id, icon.filename)
                icon.save(os.path.join(current_app.config['UPLOAD_WEBICON_PATH'], fileName))
                iconPath = current_app.config['UPLOAD_PATH_WEBICON_FOR_DB'] + '/' + fileName
                if w.icon:
                    #删除以前的图片
                    removeFile(os.path.join(current_app.config['STATIC_PATH'], w.icon))
            else:
                flash(u"请上传小于1M的图片!")
                return redirect(url_for('admin.navigationColumnManage', id=id))

        w.webName = webName
        w.url = url
        if introduction:w.introduction=introduction
        else:w.introduction=None
        if iconPath:w.icon=iconPath
        n.webs[number]=w
        n.save()
        flash(u'网站修改成功!')
        return redirect(url_for('admin.navigationColumnManage',id=id))
예제 #6
0
def kispowerKClassAdd():
    title = request.form['title']
    introduction = request.form['introduction']

    if not strLength(title, 1, 60):
        flash(u'请输入60个字符内的名称!')
        return redirect(url_for('admin.kispowerKClass'))
    if introduction and not strLength(introduction, 1, 1000):
        flash(u'请输入1000个字符内的介绍!')
        return redirect(url_for('admin.kispowerKClass'))

    k = KClass()
    k.title = title
    if introduction: k.introduction = introduction
    k.k = creatNewKClass(title, current_user.userName)
    k.save()
    flash(u'根目录添加成功!')
    return redirect(url_for('admin.kispowerKClass'))
예제 #7
0
def blogColumnAdd():
    title = request.form['title']
    introduction = request.form['introduction']

    if not strLength(title,1,30):
        flash(u'请输入60个字符内的专栏名称!')
        return redirect(url_for('admin.blogColumn'))
    if introduction and not strLength(introduction,1,100):
        flash(u'请输入100个字符内的专栏介绍!')
        return redirect(url_for('admin.blogColumn'))

    c = Column()
    c.title = title
    c.number = Column.objects.count()+1
    if introduction:c.introduction=introduction
    c.save()
    flash(u'专栏添加成功!')
    return redirect(url_for('admin.blogColumn'))
예제 #8
0
def setCommentCode():
    commentCode = request.form['commentCode'].strip()
    if not strLength(commentCode, 0, 2000):
        flash(u"评论代码最多2000个字符")
        return redirect(url_for('admin.webSetting'))

    current_user.custom['commentCode'] = commentCode
    current_user.save()
    flash(u"评论代码修改成功!")
    return redirect(url_for('admin.webSetting'))
예제 #9
0
def setStatisticalCode():
    statisticalCode = request.form['statisticalCode'].strip()
    if not strLength(statisticalCode, 0, 1000):
        flash(u"统计代码最多1000个字符")
        return redirect(url_for('admin.webSetting'))

    current_user.custom['statisticalCode'] = statisticalCode
    current_user.save()
    flash(u"统计代码修改成功!")
    return redirect(url_for('admin.webSetting'))
예제 #10
0
def setCopyright():
    copyright = request.form['copyright'].strip()
    if not strLength(copyright, 1, 100):
        flash(u"copyright最多100个字符")
        return redirect(url_for('admin.webSetting'))

    current_user.custom['copyright'] = copyright
    current_user.save()
    flash(u"copyright信息修改成功!")
    return redirect(url_for('admin.webSetting'))
예제 #11
0
def navigationColumnAdd():
    column = request.form['column']
    introduction = request.form['introduction']

    if not strLength(column,1,60):
        flash(u'请输入60个字符内的栏目名称!')
        return redirect(url_for('admin.navigationColumn'))

    if introduction and not strLength(introduction,1,1000):
        flash(u'请输入1000个字符内的栏目介绍!')
        return redirect(url_for('admin.navigationColumn'))

    n = Navigation()
    n.column = column
    n.number = Navigation.objects.count()+1
    if introduction:n.introduction=introduction
    n.save()
    flash(u'栏目添加成功!')
    return redirect(url_for('admin.navigationColumn'))
예제 #12
0
def navigationWebAdd(id):
    n = Navigation.objects(id=id).first()

    webName = request.form['webName']
    url = request.form['url']
    icon = request.files.get('img')
    introduction = request.form['introduction']

    if not strLength(webName,1,60):
        flash(u'请输入60个字符内的网站名称!')
        return redirect(url_for('admin.navigationColumnManage', id=id))
    if not strLength(url,1,1000):
        flash(u'请输入1000个字符内的网站url!')
        return redirect(url_for('admin.navigationColumnManage', id=id))
    if not url.startswith('http'):
        flash(u'url开头请带上http://或者https://')
        return redirect(url_for('admin.navigationColumnManage', id=id))
    if introduction and not strLength(introduction,1,1000):
        flash(u'请输入1000个字符内的栏目介绍!')
        return redirect(url_for('admin.navigationColumnManage', id=id))

    #其他字段判断完再判断图片上传
    iconPath = None
    if icon and allowedImage(icon.filename):
        if allowedFileSize(len(icon.read()), 1):
            icon.seek(0)
            fileName = creatFileName(current_user.id, icon.filename)
            icon.save(os.path.join(current_app.config['UPLOAD_WEBICON_PATH'], fileName))
            iconPath = current_app.config['UPLOAD_PATH_WEBICON_FOR_DB'] + '/' + fileName
        else:
            flash(u"请上传小于1M的图片!")
            return redirect(url_for('admin.navigationColumnManage', id=id))

    w = Web()
    w.webName = webName
    w.url = url
    if introduction:w.introduction=introduction
    if iconPath:w.icon=iconPath
    n.webs.append(w)
    n.save()
    flash(u'网站添加成功!')
    return redirect(url_for('admin.navigationColumnManage',id=id))
예제 #13
0
def setWebInfo():
    webName = request.form['webName']
    webIntro = request.form['webIntro']
    webKeywords = request.form['webKeywords']
    if not strLength(webName, 1, 32):
        flash(u"网站名:最多16个汉字")
        return redirect(url_for('admin.webSetting'))
    if not strLength(webIntro, 1, 256):
        flash(u"网站简介:最多128个汉字")
        return redirect(url_for('admin.webSetting'))
    if not strLength(webKeywords, 1, 128):
        flash(u"网站关键词:最多64个汉字")
        return redirect(url_for('admin.webSetting'))

    current_user.custom['webName'] = webName
    current_user.custom['webIntro'] = webIntro
    current_user.custom['webKeywords'] = webKeywords
    current_user.save()
    flash(u"信息修改成功!")
    return redirect(url_for('admin.webSetting'))
예제 #14
0
def blogColumnEdit(id):
    c = Column.objects(id=id).first()
    if request.method == 'GET':
        return render_template('admin/blogColumnEdit.html', c=c)
    if request.method == 'POST':
        title = request.form['title']
        introduction = request.form['introduction']

        if not strLength(title, 1, 30):
            flash(u'请输入60个字符内的专栏名称!')
            return redirect(url_for('admin.blogColumnEdit',id=id))
        if introduction and not strLength(introduction, 1, 100):
            flash(u'请输入100个字符内的专栏介绍!')
            return redirect(url_for('admin.blogColumn',id=id))

        c.title = title
        c.introduction = introduction
        c.save()
        flash(u'专栏修改成功!')
        return redirect(url_for('admin.blogColumn'))
예제 #15
0
def kispowerKClassEdit(id):
    k = KClass.objects(id=id).first()
    if request.method == 'GET':
        return render_template('admin/kispowerKClassEdit.html', k=k)
    if request.method == 'POST':
        title = request.form['title']
        introduction = request.form['introduction']

        if not strLength(title, 1, 60):
            flash(u'请输入60个字符内的名称!')
            return redirect(url_for('admin.kispowerKClassEdit', id=id))
        if introduction and not strLength(introduction, 1, 1000):
            flash(u'请输入1000个字符内的介绍!')
            return redirect(url_for('admin.kispowerKClassEdit', id=id))

        k.title = title
        k.introduction = introduction
        k.save()
        flash(u'根目录修改成功!')
        return redirect(url_for('admin.kispowerKClass'))
예제 #16
0
def navigationColumnEdit(id):
    n = Navigation.objects(id=id).first()
    if request.method == 'GET':
        return render_template('admin/navigationColumnEdit.html',n=n)
    if request.method == 'POST':
        column = request.form['column']
        introduction = request.form['introduction']

        if not strLength(column,1,60):
            flash(u'请输入60个字符内的栏目名称!')
            return redirect(url_for('admin.navigationColumn'))
        if introduction and not strLength(introduction,1,1000):
            flash(u'请输入1000个字符内的栏目介绍!')
            return redirect(url_for('admin.navigationColumn'))

        n.column = column
        if introduction:n.introduction=introduction
        else:n.introduction=None
        n.save()
        flash(u'栏目修改成功!')
        return redirect(url_for('admin.navigationColumn'))
예제 #17
0
def timeManagementYearlyPlanEdit(id):
    yearlyPlan = YearlyPlan.objects(id=id).first()
    levels = current_app.config['PLAN_LEVEL']
    if request.method == 'GET':
        return render_template('admin/timeManagementYearlyPlanEdit.html',
                               levels=levels, yearlyPlan=yearlyPlan,
                               startTime=str(yearlyPlan.startTime).split(' ')[0],
                               endTime=str(yearlyPlan.endTime).split(' ')[0])

    if request.method == 'POST':
        title = request.form['title']
        startTime = request.form['startTime']
        endTime = request.form['endTime']

        planLevel = request.form.getlist('planLevel[]')
        planTitle = request.form.getlist('planTitle[]')
        isDone = request.form.getlist('isDone[]')

        if not strLength(title,1,100):
            return jsonify({'status': False, 'info': u'请输入1-100个字符的年计划标题'})
        if not startTime or not endTime:
            return jsonify({'status': False, 'info': u'请选择时间范围'})

        startTime = strToDatetime('%s 00:00:00' % startTime)
        endTime = strToDatetime('%s 23:59:59' % endTime)
        if endTime <= startTime:
            return jsonify({'status': False, 'info': u'结束时间要晚于开始时间'})

        # 判断年计划时间是否冲突
        yps = YearlyPlan.objects
        for i in yps:
            if i == yearlyPlan: continue
            if not (startTime > i.endTime or endTime < i.startTime):
                return jsonify({'status': False, 'info': u'年计划时间范围(%s - %s)与其他年计划时间(%s - %s)冲突!' %
                                                         (startTime, endTime, i.startTime, i.endTime)})

        plans = []
        for index, t in enumerate(planTitle):
            if len(t)>0:
                p = Plan()
                p.title = t
                p.level = planLevel[index]
                if isDone[index] == 'y':
                    p.isDone = True
                else:
                    p.isDone = False
                plans.append(p)
        yearlyPlan.title = title
        yearlyPlan.startTime = startTime
        yearlyPlan.endTime = endTime
        yearlyPlan.plans = plans
        yearlyPlan.save()
        return jsonify({'status': True, 'info': u'年计划修改成功'})
예제 #18
0
파일: view.py 프로젝트: pengjinfu/kispower
def contact():
    if request.method == 'GET':
        return render_template('%s/contact.html' %
                               current_user.getCustom()['homeTemplate'],
                               mark='contact')
    elif request.method == 'POST':
        name = request.form['name']
        if not strLength(name, 1, 20):
            return jsonify({'status': False, 'info': u'请输入20个字符内的名字'})
        email = request.form['email']
        if not reEmail(email):
            return jsonify({'status': False, 'info': u'请输入正确的邮箱'})
        message = request.form['message']
        if not strLength(message, 1, 1000):
            return jsonify({'status': False, 'info': u'请输入1000个字符内的消息'})
        c = contactMessage()
        c.name = name
        c.email = email
        c.message = message
        c.at = getStrTime()
        c.save()
        return jsonify({'status': True, 'info': u'提交成功!'})
예제 #19
0
def timeManagementWeeklyPlanAdd():
    title = request.form['title']
    monthlyPlanId = request.form['monthlyPlanId']
    startTime = request.form['startTime']
    endTime = request.form['endTime']
    planLevel = request.form.getlist('planLevel[]')
    planTitle = request.form.getlist('planTitle[]')

    if not strLength(title,1,100):
        return jsonify({'status': False, 'info': u'请输入1-100个字符的周计划标题!'})
    if not startTime or not endTime:
        return jsonify({'status': False, 'info': u'请选择时间范围!'})

    startTime = strToDatetime('%s 00:00:00' % startTime)
    endTime = strToDatetime('%s 23:59:59' % endTime)
    if endTime <= startTime:
        return jsonify({'status': False, 'info': u'结束时间必须要晚于开始时间!'})

    m = MonthlyPlan.objects(id=monthlyPlanId).first()
    #时间范围判断
    #周计划的时间范围必须在月计划的时间范围内
    if not (startTime>=m.startTime and endTime<=m.endTime):
        return jsonify({'status': False, 'info': u'周计划的时间范围必须在月计划的时间范围内!'})
    #该年计划下的月计划时间范围不冲突
    wps = WeeklyPlan.objects(monthlyPlan=m)
    for i in wps:
        if not (startTime >= i.endTime or endTime <= i.startTime):
            return jsonify({'status': False, 'info': u'周计划的时间范围(%s - %s)和“%s”的时间范围(%s - %s)冲突' %
                  (startTime,endTime,i.title,i.startTime,i.endTime)})

    plans = []
    for index, t in enumerate(planTitle):
        if len(t) > 0:
            p = Plan()
            p.title = t
            p.level = planLevel[index]
            plans.append(p)

    w = WeeklyPlan()
    w.title = title
    w.startTime = startTime
    w.endTime = endTime
    w.plans = plans
    w.monthlyPlan = m
    w.save()
    return jsonify({'status': True, 'info': u'周计划添加成功!'})
예제 #20
0
def timeManagementMonthlyPlanAdd():
    title = request.form['title']
    yearlyPlanId = request.form['yearlyPlanId']
    startTime = request.form['startTime']
    endTime = request.form['endTime']
    planLevel = request.form.getlist('planLevel[]')
    planTitle = request.form.getlist('planTitle[]')

    if not strLength(title,1,100):
        return jsonify({'status': False, 'info': u'请输入1-100个字符的月计划标题!'})
    if not startTime or not endTime:
        return jsonify({'status': False, 'info': u'请选择时间范围'})

    startTime = strToDatetime('%s 00:00:00' % startTime)
    endTime = strToDatetime('%s 23:59:59' % endTime)
    if endTime <= startTime:
        return jsonify({'status': False, 'info': u'结束时间必须要晚于开始时间'})

    y = YearlyPlan.objects(id=yearlyPlanId).first()
    #时间范围判断
    #月计划的时间范围必须在年计划的时间范围内
    if not (startTime>=y.startTime and endTime<=y.endTime):
        return jsonify({'status': False, 'info': u'月计划的时间范围必须在年计划的时间范围内'})
    #该年计划下的月计划时间范围不冲突
    mps = MonthlyPlan.objects(yearlyPlan=y)
    for i in mps:
        if not (startTime >= i.endTime or endTime <= i.startTime):
            return jsonify({'status': False, 'info': u'月计划的时间范围(%s - %s)和“%s”的时间范围(%s - %s)冲突' %
                  (startTime,endTime,i.title,i.startTime,i.endTime)})

    plans = []
    for index, t in enumerate(planTitle):
        if len(t) > 0:
            p = Plan()
            p.title = t
            p.level = planLevel[index]
            plans.append(p)

    m = MonthlyPlan()
    m.title = title
    m.startTime = startTime
    m.endTime = endTime
    m.plans = plans
    m.yearlyPlan = y
    m.save()
    return jsonify({'status': True, 'info': u'月计划添加成功'})
예제 #21
0
def timeManagementYearlyPlanAdd():
    title = request.form['title']
    startTime = request.form['startTime']
    endTime = request.form['endTime']

    planLevel = request.form.getlist('planLevel[]')
    planTitle = request.form.getlist('planTitle[]')

    if not strLength(title,1,100):
        return jsonify({'status': False, 'info': u'请输入1-100个字符的年计划标题'})
    if not startTime or not endTime:
        return jsonify({'status': False, 'info': u'请选择时间范围'})

    startTime = strToDatetime('%s 00:00:00' % startTime)
    endTime = strToDatetime('%s 23:59:59' % endTime)
    if endTime <= startTime:
        return jsonify({'status': False, 'info': u'结束时间必须要晚于开始时间'})

    #判断年计划时间是否冲突
    yps = YearlyPlan.objects
    for i in yps:
        if not (startTime>i.endTime or endTime<i.startTime):
            return jsonify({'status': False, 'info': u'年计划时间范围(%s - %s)与其他年计划时间(%s - %s)冲突!' %
                  (startTime,endTime,i.startTime,i.endTime)})

    plans = []
    for index, t in enumerate(planTitle):
        if len(t) > 0:
            p = Plan()
            p.title = t
            p.level = planLevel[index]
            plans.append(p)

    yearlyPlan = YearlyPlan()
    yearlyPlan.title = title
    yearlyPlan.startTime = startTime
    yearlyPlan.endTime = endTime
    yearlyPlan.plans = plans
    yearlyPlan.save()
    return jsonify({'status': True, 'info': u'年计划添加成功'})
예제 #22
0
def timeManagementWeeklyPlanEdit(id):
    w = WeeklyPlan.objects(id=id).first()
    if request.method == 'GET':
        levels = current_app.config['PLAN_LEVEL']
        mps = MonthlyPlan.objects.order_by('-id')[:12]
        return render_template('admin/timeManagementWeeklyPlanEdit.html',
                               levels=levels, w=w, mps=mps,
                               startTime=str(w.startTime).split(' ')[0],
                               endTime=str(w.endTime).split(' ')[0])

    if request.method == 'POST':
        title = request.form['title']
        monthlyPlanId = request.form['monthlyPlanId']
        startTime = request.form['startTime']
        endTime = request.form['endTime']
        planLevel = request.form.getlist('planLevel[]')
        planTitle = request.form.getlist('planTitle[]')
        isDone = request.form.getlist('isDone[]')

        if not strLength(title, 1, 100):
            return jsonify({'status': False, 'info': u'请输入1-100个字符的周计划标题!'})
        if not startTime or not endTime:
            return jsonify({'status': False, 'info': u'请选择时间范围!'})

        startTime = strToDatetime('%s 00:00:00' % startTime)
        endTime = strToDatetime('%s 23:59:59' % endTime)
        if endTime <= startTime:
            return jsonify({'status': False, 'info': u'结束时间必须要晚于开始时间!'})

        m = MonthlyPlan.objects(id=monthlyPlanId).first()
        # 时间范围判断
        # 周计划的时间范围必须在月计划的时间范围内
        if not (startTime >= m.startTime and endTime <= m.endTime):
            return jsonify({'status': False, 'info': u'周计划的时间范围必须在月计划的时间范围内!'})
        # 该月计划下的周计划时间范围不冲突
        wps = WeeklyPlan.objects(monthlyPlan=m)
        for i in wps:
            if i==w:continue
            if not (startTime >= i.endTime or endTime <= i.startTime):
                return jsonify({'status': False, 'info': u'周计划的时间范围(%s - %s)和“%s”的时间范围(%s - %s)冲突' %
                                (startTime, endTime, i.title, i.startTime, i.endTime)})

        plans = []
        for index, t in enumerate(planTitle):
            if len(t) > 0:
                p = Plan()
                p.title = t
                p.level = planLevel[index]
                if isDone[index] == 'y':
                    p.isDone = True
                else:
                    p.isDone = False
                plans.append(p)

        w.title = title
        w.startTime = startTime
        w.endTime = endTime
        w.plans = plans
        w.monthlyPlan = m
        w.save()
        return jsonify({'status': True, 'info': u'周计划修改成功!'})