예제 #1
0
    def post(self):
        user = users.get_current_user()
        board_url = self.request.get("board_url")
        boardName = self.request.get("boardName").strip()
        userToRem = self.request.get("userRemove").strip()
        board = Board.get_by_id(int(self.request.get("key_board")))
        if board:
            board.boardTitle = boardName
            if userToRem != "" and user.email() == board.owner:
                key_user = ndb.Key(User, userToRem)
                user_details = key_user.get()
                if user_details:
                    if user_details.boards != None:
                        del user_details.boards[str(self.request.get("key_board"))]
                        user_details.put()

                for i in range(0,len(board.users)):
                    if str(board.users[i].email.lower()).strip() == userToRem.lower():
                        board.users.pop(i)
                        break

            for i in range(0,len(board.tasks)):
                if str(board.tasks[i].assignee.lower()).strip() == userToRem.lower().strip():
                    board.tasks[i].assignee = 'Unassigned'

            board.put()
            self.add_message('Board updated successfully', 'success')
        else:
            self.add_message("Board doesn't exist", 'success')

        self.redirect(str(board_url), abort=False)
예제 #2
0
 def post(self):
     tName = self.request.get("taskName").lower().strip()
     board_url = self.request.get("board_url")
     keyconcat = tName+'/'+self.request.get("key_board")
     key_name = ndb.Key(Task, keyconcat)
     task = key_name.get()
     if task:
         task.dueDate = datetime.strptime(self.request.get("dueDate"), '%Y-%m-%d')
         task.description = self.request.get("description")
         task.assignee = self.request.get("assignee")
         if task.status == self.request.get("status"):
             task.completionDate = task.completionDate
         else:
             if self.request.get("status") == "completed":
                 now = datetime.now() #using utc time
                 task.completionDate = now
             elif self.request.get("status") == "not completed":
                 task.completionDate = None
         task.status = self.request.get("status")
         task.put()
         boardCheck = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardCheck.tasks)):
             if str(boardCheck.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardCheck.tasks[i].status = task.status
                 boardCheck.tasks[i].description = task.description
                 boardCheck.tasks[i].assignee = task.assignee
                 boardCheck.tasks[i].dueDate = task.dueDate
                 boardCheck.tasks[i].completionDate = task.completionDate
         boardCheck.put()
         self.add_message('Task updated successfully', 'success')
     else:
         self.add_message('Task not found.', 'danger')
     self.redirect(str(board_url), abort=False)
예제 #3
0
    def post(self):
        tName = self.request.get("name")
        board_url = self.request.get("board_url")
        checkbovVal = self.request.get("checkbovVal")
        keyconcat = tName.lower().strip()+'/'+self.request.get("key_board")
        key_name = ndb.Key(Task, keyconcat)
        taskStatus = key_name.get()
        if taskStatus:
            if checkbovVal == "true":
                taskStatus.status = "completed"
                now = datetime.now() #using utc time
                taskStatus.completionDate = now
            elif checkbovVal == "false":
                taskStatus.status = "not completed"
                taskStatus.completionDate = None

            taskStatus.put()
            boardCheck = Board.get_by_id(int(self.request.get("key_board")))

            for i in range(0,len(boardCheck.tasks)):
                if str(boardCheck.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                    boardCheck.tasks[i].status = taskStatus.status
                    boardCheck.tasks[i].completionDate = taskStatus.completionDate
            boardCheck.put()
            self.add_message('Task status updated successfully', 'success')
        else:
            self.add_message('Task not found.', 'danger')
        self.redirect(str(board_url), abort=False)
예제 #4
0
    def get(self, id=None):
        user = users.get_current_user()
        ex_user = True
        board = []
        cmpTask = []
        actTask = []
        cmpToday = []
        taskLen = []
        if user:
            url = users.create_logout_url(self.request.uri)
            url = url.split("board")[0]+"boards"
            url_string = "Logout"
            key_user = ndb.Key(User, user.email())
            if not key_user.get():
                userModel = User(key=key_user, email=user.email())
                userModel.put()
                ex_user = False
            board = Board.get_by_id(int(id))
            if board:
                if board.tasks:
                    taskLen = board.tasks
                    for task in board.tasks:
                        if task.status == "not completed":
                            actTask.append(task.status)
                        if task.status == "completed":
                            cmpTask.append(task.status)
                            if datetime.now().date() == task.completionDate.date():
                                cmpToday.append(task.status)

        else:
            url = users.create_login_url(self.request.uri)
            url_string = "Login"

        template_values = {
            "messages": self.messages,
            "url": url,
            "url_string": url_string,
            "user": user,
            "ex_user": ex_user,
            "board_url": "board/"+id,
            "key_board": id,
            "board": board,
            "taskLen": len(taskLen),
            "cmpTask": len(cmpTask),
            "actTask": len(actTask),
            "cmpToday": len(cmpToday)
        }
        template = JINJA_ENVIRONMENT.get_template("/TaskManagement/taskboard.html")
        self.response.write(template.render(template_values))
예제 #5
0
 def get(self):
     tName = self.request.get("name")
     board_url = self.request.get("board_url")
     keyconcat = tName.lower().strip()+'/'+self.request.get("key_board")
     key_name = ndb.Key(Task, keyconcat)
     taskDel = key_name.get()
     if taskDel:
         taskDel.key.delete()
         boardDel = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardDel.tasks)):
             if str(boardDel.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardDel.tasks.pop(i)
                 break
         boardDel.put()
         self.add_message('Task Deleted successfully.', 'success')
     else:
         boardDel = Board.get_by_id(int(self.request.get("key_board")))
         for i in range(0,len(boardDel.tasks)):
             if str(boardDel.tasks[i].taskTitle.lower()).strip() == tName.lower().strip():
                 boardDel.tasks.pop(i)
                 break
         boardDel.put()
         self.add_message('Task not found in database.', 'danger')
     self.redirect(str(board_url), abort=False)
예제 #6
0
    def post(self):
        board_url = self.request.get("board_url")
        keyconcat = self.request.get("taskName").lower().strip()+'/'+self.request.get("key_board")
        key_name = ndb.Key(Task, keyconcat)
        if not key_name.get():
            task = Task(key=key_name)
            task.taskTitle = self.request.get("taskName").lower().strip()
            task.dueDate = datetime.strptime(self.request.get("dueDate"), '%Y-%m-%d')
            task.description = self.request.get("description")
            task.status = self.request.get("status")
            task.assignee = self.request.get("assignee")
            task.put()
            board = Board.get_by_id(int(self.request.get("key_board")))
            board.tasks.append(key_name.get())
            board.put()
            self.add_message('Task Created successfully.', 'success')
        else:
            self.add_message('Task with same task name already exists.', 'danger')

        self.redirect(str(board_url), abort=False)
예제 #7
0
 def get(self, id=None):
     user = users.get_current_user()
     board = Board.get_by_id(int(id))
     board_url = self.request.get("board_url")
     form_url = '/board/{}'.format(id)
     if board:
         if len(board.users) == 1 and len(board.tasks) == 0 and user.email() == board.users[0].email.strip():
             key_user = ndb.Key(User, user.email())
             user_details = key_user.get()
             if user_details:
                 if user_details.boards != None:
                     del user_details.boards[str(id)]
                     user_details.put()
             board.key.delete()
             self.add_message('Board deleted successfully.', 'success')
             self.redirect('/boards', abort=False)
         else:
             self.add_message('Please remove all the tasks and users in order to delete this board', 'danger')
             self.redirect(form_url, abort=False)
     else:
         self.add_message('Board not found in database.', 'danger')
         self.redirect(form_url, abort=False)
예제 #8
0
    def post(self):
        user = users.get_current_user()
        board_url = self.request.get("board_url")
        if user:
            board = Board.get_by_id(int(self.request.get("key_board")))
            user_email_key = ndb.Key(User, str(self.request.get("email_id").strip()))
            invited_user = user_email_key.get()
            if invited_user:
                if invited_user.boards:
                    board_dict = invited_user.boards
                else:
                    board_dict = {}
                board_dict[board.key.id()] = board.key.urlsafe()
                invited_user.boards = board_dict
                invited_user.put()
                existing_u = []
                for addedUser in board.users:
                    existing_u.append(addedUser.email.strip())

                if invited_user.key.id().strip() not in existing_u:
                    board.users.append(invited_user)
                    board.put()
                    self.add_message('User invited successfully.', 'success')
                    self.redirect(str(board_url), abort=False)
                else:
                    self.add_message('User already invited.', 'danger')
                    self.redirect(str(board_url), abort=False)

                return
            else:
                self.add_message('User not found.', 'danger')
                self.redirect(str(board_url), abort=False)
                return

        else:
            self.add_message('Not authorized.', 'danger')
            self.redirect('/', abort=False)
            return