コード例 #1
0
def board_delete(req, bid):
    if not req.session.has_key('email'):
        return user_loginout(req)
    user = User.objects.filter(email=req.session['email']).first()

    board = Board.objects.filter(id=bid).first()
    if board:
        board.delete()
        boards = Board.objects.filter(userref=user.id).all()
        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': 'Board Deleted Successfully...',
                'error': ''
            })
    else:
        boards = Board.objects.filter(userref=user.id).all()
        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': '',
                'error': 'Invalid Board Id...'
            })
コード例 #2
0
ファイル: views.py プロジェクト: Nitin4994/Trello
def task_move(req):
    if not req.session.has_key('email'):
        return user_loginout(req)
    user = User.objects.filter(email=req.session['email']).first()

    if req.method=='POST':
        formdata = req.POST
        cateid = formdata['moveCateid']
        taskid = formdata['taskid']

        print("cateid",cateid)
        print("taskid",taskid)

        if cateid == "" or taskid == "":
            boards = Board.objects.filter(userref=user.id).all()
            return render(req, 'board.html',
                          {'user': user,
                           'boards': paggination_records(req, boards),
                           'msg': '',
                           'error': 'Invalid Credentials...'})

        task = Task.objects.filter(id=taskid).first()
        categorie = Categories.objects.filter(id=cateid).first()

        board = Board.objects.filter(id=categorie.bordref.id).first()
        #categories = Categories.objects.filter(bordref=board.id).all()

        if task:
            task.cateref=categorie
            task.save()

        cate_dict = {}
        categories = Categories.objects.filter(bordref=board.id).all()
        for cate in categories:
            task_list = []
            tasks = Task.objects.filter(cateref=cate.id).all()
            # print(type(tasks))
            for task in tasks:
                task_list.append(task)
            cate_dict.update({cate: task_list})
        # print(cate_dict)

        return render(req, 'categorie.html',
                      {'user': user,
                       'board': board,
                       'categories': categories,
                       'cate_dict': cate_dict,
                       'msg': 'Task Moved Successfully...',
                       'error': ''})
    else:
        boards = Board.objects.filter(userref=user.id).all()
        return render(req, 'board.html',
                      {'user': user,
                       'boards': paggination_records(req, boards),
                       'msg': '',
                       'error': 'Invalid Credentials...'})
コード例 #3
0
def board(req):
    if not req.session.has_key('email'):
        return user_loginout(req)

    user = User.objects.filter(email=req.session['email']).first()
    boards = Board.objects.filter(userref=user.id).all()
    return render(
        req, 'board.html', {
            'user': user,
            'boards': paggination_records(req, boards),
            'msg': '',
            'error': ''
        })
コード例 #4
0
def categorie(req, bid):
    if not req.session.has_key('email'):
        return user_loginout(req)
    user = User.objects.filter(email=req.session['email']).first()

    board = Board.objects.filter(id=bid).first()
    #tasks = Task.objects.all()
    #print(tasks)

    if board:
        #print(board.id)
        cate_dict = {}
        categories = Categories.objects.filter(bordref=board.id).all()
        for cate in categories:
            task_list = []
            tasks = Task.objects.filter(cateref=cate.id).all()
            #print(type(tasks))
            for task in tasks:
                task_list.append(task)
            cate_dict.update({cate: task_list})
        #print(cate_dict)
        return render(
            req,
            'categorie.html',
            {
                'user': user,
                'board': board,
                'categories': categories,
                'cate_dict': cate_dict,
                #'tasks':tasks,
                'msg': '',
                'error': ''
            })
    else:
        boards = Board.objects.filter(userref=user.id).all()
        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': '',
                'error': 'Invalid Board Id...'
            })
コード例 #5
0
def board_save(req):
    if not req.session.has_key('email'):
        return user_loginout(req)
    user = User.objects.filter(email=req.session['email']).first()

    if req.method == 'POST':
        formdata = req.POST
        boardname = formdata['boardName']

        boards = Board.objects.filter(userref=user.id).all()
        if boardname == "":
            return render(
                req, 'board.html', {
                    'user': user,
                    'boards': paggination_records(req, boards),
                    'msg': '',
                    'error': 'Invalid credentials...'
                })
        bordinfo = Board(boardName=boardname)
        bordinfo.userref = user
        bordinfo.save()

        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': 'Board Saved Successfully...',
                'error': ''
            })
    else:

        user = User.objects.filter(email=req.session['email']).first()
        boards = Board.objects.filter(userref=user.id).all()
        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': '',
                'error': ''
            })
コード例 #6
0
def categorie_save(req):
    if not req.session.has_key('email'):
        return user_loginout(req)
    user = User.objects.filter(email=req.session['email']).first()

    if req.method == 'POST':
        formdata = req.POST
        boardid = formdata['boardid']
        categorie = formdata['categorie']

        board = Board.objects.filter(id=boardid).first()
        categories = Categories.objects.filter(bordref=board.id).all()
        print(board.boardName)
        if categorie == "":

            cate_dict = {}
            categories = Categories.objects.filter(bordref=board.id).all()
            for cate in categories:
                task_list = []
                tasks = Task.objects.filter(cateref=cate.id).all()
                # print(type(tasks))
                for task in tasks:
                    task_list.append(task)
                cate_dict.update({cate: task_list})
            # print(cate_dict)

            return render(
                req, 'categorie.html', {
                    'user': user,
                    'board': board,
                    'categories': categories,
                    'cate_dict': cate_dict,
                    'msg': '',
                    'error': 'Invalid Categorie...'
                })
        categorieinfo = Categories(cateName=categorie)
        categorieinfo.bordref = board
        categorieinfo.save()

        cate_dict = {}
        categories = Categories.objects.filter(bordref=board.id).all()
        for cate in categories:
            task_list = []
            tasks = Task.objects.filter(cateref=cate.id).all()
            # print(type(tasks))
            for task in tasks:
                task_list.append(task)
            cate_dict.update({cate: task_list})
        # print(cate_dict)

        return render(
            req, 'categorie.html', {
                'user': user,
                'board': board,
                'categories': categories,
                'cate_dict': cate_dict,
                'msg': 'Categorie Saved Successfully...',
                'error': ''
            })
    else:
        boards = Board.objects.filter(userref=user.id).all()
        return render(
            req, 'board.html', {
                'user': user,
                'boards': paggination_records(req, boards),
                'msg': '',
                'error': ''
            })