Ejemplo n.º 1
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        action = self.request.get('button')

        if action == 'Create':
            new_board_name = self.request.get('tb_name')

            id = str(random.randint(0, 1000000))

            newBoard = TaskBoardProperty(tb_name=new_board_name, tb_id=id)
            myuser.myuser_board.append(newBoard)
            myuser.put()

            new_entry = TaskBoard(id=id,
                                  tb_name=new_board_name,
                                  creator=myuser.email)
            new_entry.tb_member.append(myuser.email)
            new_entry.put()

            self.redirect('/new_tb')
Ejemplo n.º 2
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        board_id = self.request.get('id')

        invited_user = self.request.get('invited_user')

        getBoard = TaskBoard.get_by_id(board_id)
        board_name = getBoard.tb_name

        get_member = MyUser.get_by_id(invited_user)

        action = self.request.get('button')

        if action == 'invite':

            newMember = TaskBoardProperty(tb_name=board_name, tb_id=board_id)
            get_member.myuser_board.append(newMember)
            get_member.put()

            getBoard.tb_member.append(invited_user)
            getBoard.put()

            self.redirect('/')

        elif action == 'cancel':
            self.redirect('/view_board?id=' + board_id)
Ejemplo n.º 3
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        boardId = self.request.get('id')

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        getBoard = TaskBoard.get_by_id(boardId)

        name_of_board = getBoard.tb_name
        creator = getBoard.creator

        allUsers = MyUser.query().fetch()

        template_values = {
            'myuser': myuser,
            'board_name': name_of_board,
            'creator': creator,
            'users': allUsers,
            'board_id': boardId
        }

        template = JINJA_ENVIRONMENT.get_template('invite.html')
        self.response.write(template.render(template_values))
Ejemplo n.º 4
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        boardId = self.request.get('id')
        #taskId = self.request.get('id')

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        getBoard = TaskBoard.get_by_id(boardId)
        board_members = getBoard.tb_member

        name_of_board = getBoard.tb_name
        creator = getBoard.creator

        template_values = {
            'myuser': myuser,
            'board_name': name_of_board,
            'creator': creator,
            'board_id': boardId,
            'board_members': board_members
            #'task_id' :taskId
        }

        template = JINJA_ENVIRONMENT.get_template('addTask.html')
        self.response.write(template.render(template_values))
Ejemplo n.º 5
0
    def post(self):
        new_board_name = self.request.get('new_board_name')

        boardId = self.request.get('id')

        getBoard = TaskBoard.get_by_id(boardId)
        board_name = getBoard.tb_name

        getAllUsers = MyUser.query().fetch()

        action = self.request.get('button')

        if action == 'rename':

            for a in list(getAllUsers):
                for b in list(a.myuser_board):
                    if (b.tb_name == board_name):
                        b.tb_name = new_board_name
                        a.put()

                        getBoard.tb_name = new_board_name
                        getBoard.put()
                        self.redirect('/view_board?id=' + boardId)

        elif action == 'cancel':
            self.redirect('/view_board?id=' + boardId)
Ejemplo n.º 6
0
    def post(self):
        boardId = self.request.get('id')
        task_name = self.request.get('task_name')

        getBoard = TaskBoard.get_by_id(boardId)
        board_members = getBoard.tb_member

        tasks = getBoard.tb_task

        error = ''

        action = self.request.get('button')

        if action == 'update':
            newtaskName = self.request.get('new_task_name')
            Deadline = self.request.get('deadline')
            assignedUser = self.request.get('assigned_user')

            # for i in getBoard.tb_task:
            #     if(i.task_name == task_name):
            #         i.task_name = newtaskName
            #         i.deadline = Deadline
            #         i.assigned_user = assignedUser
            #         getBoard.put()
            #         self.redirect('/')

            existingNames = []

            for i in getBoard.tb_task:
                existingNames.append(i.task_name)

            for i in list(getBoard.tb_task):
                if (i.task_name == task_name):
                    if (newtaskName == task_name):
                        i.task_name = newtaskName
                        i.deadline = Deadline
                        i.assigned_user = assignedUser
                        getBoard.put()
                        self.redirect('/view_board?id=' + boardId)
                    elif (newtaskName != task_name):
                        if (newtaskName in existingNames):
                            error = 'Task Name exists'
                        else:
                            i.task_name = newtaskName
                            i.deadline = Deadline
                            i.assigned_user = assignedUser
                            getBoard.put()
                            self.redirect('/view_board?id=' + boardId)

        if action == 'cancel':
            self.redirect('/view_board?id=' + boardId)

        template_values = {'error': error, 'board_members': board_members}

        template = JINJA_ENVIRONMENT.get_template('editTask.html')
        self.response.write(template.render(template_values))
Ejemplo n.º 7
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'
        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.user_id())
        myuser = myuser_key.get()
        action = self.request.get('button')

        current_time = datetime.datetime.now().strftime("%X")
        current_date = datetime.datetime.now().strftime("%x")

        if action == 'mark_task':
            boardId = self.request.get('id')

            task_name = self.request.get('task_name')

            getBoard = TaskBoard.get_by_id(boardId)

            tasks = getBoard.tb_task

            for a in list(tasks):
                if (task_name == a.task_name):
                    a.completed = 'Yes'
                    a.time_completed = current_time
                    a.date_completed = current_date
                    getBoard.put()

            self.redirect('/view_board?id=' + boardId)

        elif action == 'delete_task':
            boardId = self.request.get('id')

            task_name = self.request.get('task_name')

            getBoard = TaskBoard.get_by_id(boardId)

            tasks = getBoard.tb_task

            for n in tasks:
                if (n.task_name == task_name):
                    tasks.remove(n)
                    getBoard.put()

                    self.redirect('/view_board?id=' + boardId)
Ejemplo n.º 8
0
    def post(self):
        boardId = self.request.get('id')

        getBoard = TaskBoard.get_by_id(boardId)

        board_name = getBoard.tb_name

        board_members = getBoard.tb_member

        board_tasks = list(getBoard.tb_task)

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        action = self.request.get('button')

        if action == 'remove_user':
            selected_user = self.request.get('selected_user')

            getUser = MyUser.get_by_id(selected_user)

            userBoards = getUser.myuser_board

            if (userBoards == selected_user):
                self.redirect('/')

            for a in board_members:
                if (selected_user == a):
                    board_members.remove(a)
                    getBoard.put()

            for b in list(userBoards):
                if (b.tb_name == board_name):
                    userBoards.remove(b)
                    getUser.put()

            for i in board_tasks:
                if (i.assigned_user == selected_user):
                    i.assigned_user = '******'
                    getBoard.put()

            self.redirect('/view_board?id=' + boardId)

        elif action == 'cancel':
            self.redirect('/view_board?id=' + boardId)

        template_values = {
            'myuser': myuser,
            'board_id': boardId,
            'board_members': board_members
        }

        template = JINJA_ENVIRONMENT.get_template('delete_user.html')
        self.response.write(template.render(template_values))
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'
        # pull the current user from the Request
        user = users.get_current_user()
        id = user.user_id()
        print(id)
        new_tbd_id = ''
        action = self.request.get('button')
        print("hey")
        print(id)

        name = self.request.get('tbd_name')

        if user and action == 'Submit':
            myuser_key = ndb.Key('MyUser', id)
            myuser = myuser_key.get()

            new_taskboard = TaskBoard()

            new_taskboard.tbd_name = self.request.get('tbd_name')
            #new_taskboard.tbd_creator = myuser_key
            new_taskboard.tbd_creator_email = user.email()

            new_taskboard.put()
            new_tbd_id = ndb.Key('TaskBoard', new_taskboard.key.id())
            myuser.tb_key.append(new_tbd_id)
            myuser.put()

            self.redirect('/view_taskboard')

        elif user and action == 'Cancel':
            self.redirect('/view_taskboard')
        else:
            self.redirect('/view_taskboard')
Ejemplo n.º 10
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'
        template_values = {}

        user = users.get_current_user()

        if self.request.get('button') == 'Create':
            if user:
                usr = ndb.Key("User", user.user_id()).get()

                task_board = TaskBoard()
                if len(self.request.get('taskboard_name').strip()) > 0:
                    task_board.name = self.request.get('taskboard_name')
                    task_board.creator = usr.key

                    task_board.put()
                    usr.taskBoards.append(task_board.key)
                    usr.put()
                    self.redirect('/')
                else:
                    self.redirect('/')
            else:
                self.redirect('/')

        if self.request.get('button') == 'Back':
            self.redirect('/')
Ejemplo n.º 11
0
    def post(self):
        self.response.headers['Content-Type'] = 'text/html'

        boardId = self.request.get('id')

        getBoard = TaskBoard.get_by_id(boardId)
        board_members = getBoard.tb_member

        action = self.request.get('button')

        error = ''

        if action == 'addTask':
            taskName = self.request.get('task_name')
            Deadline = self.request.get('deadline')
            assignedUser = self.request.get('assigned_user')

            existingNames = []

            for a in getBoard.tb_task:
                existingNames.append(a.task_name)

            if (taskName in existingNames):
                error = 'task name exists'
            else:
                new_task = Task(task_name=taskName,
                                deadline=Deadline,
                                completed='No',
                                assigned_user=assignedUser,
                                date_completed='',
                                time_completed='')
                getBoard.tb_task.append(new_task)
                getBoard.put()
                self.redirect('/view_board?id=' + boardId)

        elif action == 'cancel':
            self.redirect('/view_board?id=' + boardId)

            template_values = {'error': error, 'board_members': board_members}

            template = JINJA_ENVIRONMENT.get_template('addTask.html')
            self.response.write(template.render(template_values))
Ejemplo n.º 12
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        boardId = self.request.get('id')
        taskName = self.request.get('task_name')

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        old_task_name = ''
        old_deadline = ''
        old_assigned_user = ''

        getBoard = TaskBoard.get_by_id(boardId)
        board_tasks = getBoard.tb_task
        board_members = getBoard.tb_member

        name_of_board = getBoard.tb_name
        creator = getBoard.creator

        for a in board_tasks:
            if (a.task_name == taskName):
                old_task_name = a.task_name
                old_deadline = a.deadline
                old_assigned_user = a.assigned_user

        template_values = {
            'myuser': myuser,
            'board_name': name_of_board,
            'creator': creator,
            'board_id': boardId,
            'board_members': board_members,
            'old_task_name': old_task_name,
            'old_deadline': old_deadline,
            'old_assigned_user': old_assigned_user,
            'task_name': taskName
            #'task_id' :taskId
        }

        template = JINJA_ENVIRONMENT.get_template('editTask.html')
        self.response.write(template.render(template_values))
Ejemplo n.º 13
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        boardId = self.request.get('id')

        user = users.get_current_user()
        myuser_key = ndb.Key('MyUser', user.email())
        myuser = myuser_key.get()

        getBoard = TaskBoard.get_by_id(boardId)

        board_name = getBoard.tb_name

        template_values = {
            'myuser': myuser,
            'board_name': board_name,
            'board_id': boardId
        }

        template = JINJA_ENVIRONMENT.get_template('rename_board.html')
        self.response.write(template.render(template_values))