This repository was archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Trello #1
Open
arpitrathi
wants to merge
5
commits into
workattech:master
Choose a base branch
from
arpitrathi:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Trello #1
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0642d3b
Initial modules and services designed.
arpitrathi 11be310
Added init file in Services package.
arpitrathi ff2542e
Add input method for create delete board, list.
arpitrathi 239c3c6
Update card listid when moving.
arpitrathi 73013ce
Update Input for BOARD and Card.
arpitrathi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from Library import IdGenerator | ||
| from Library import Access | ||
|
|
||
|
|
||
| class Board(object): | ||
|
|
||
| def __init__(self, name="", url=""): | ||
| self.id = IdGenerator.generateUniqueId() | ||
| self.name = name | ||
| self.privacy = Access.PUBLIC | ||
| self.url = url | ||
| self.members = set() | ||
| self.lists = set() | ||
|
|
||
| def setBoardName(self, name): | ||
| self.name = name | ||
|
|
||
| def setAccessSpecifier(self, access): | ||
| self.privacy = access | ||
|
|
||
| def getBoardName(self): | ||
| return self.name | ||
|
|
||
| def addMemberToBoard(self, userId): | ||
| self.members.add(userId) | ||
|
|
||
| def removeMemberFromBoard(self, userId): | ||
| if userId not in self.members: | ||
| print str(userId) + "not present in Board: " + str(self.id) | ||
| return | ||
| self.members.remove(userId) | ||
|
|
||
| def addListToBoard(self, listId): | ||
| self.lists.add(listId) | ||
|
|
||
| def removeListFromBoard(self, listId): | ||
| if listId not in self.lists: | ||
| print str(listId) + " not present in Board: " + str(self.id) | ||
| return | ||
| self.lists.remove(listId) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from Trello.Models.Library import IdGenerator | ||
|
|
||
|
|
||
| class Cards(object): | ||
| userAssigned = None # type: String | ||
|
|
||
| def __init__(self, name="", listId=None): | ||
| self.id = IdGenerator.generateUniqueId() | ||
| self.name = name | ||
| self.description = None | ||
| self.userAssigned = None | ||
| self.listId = listId | ||
|
|
||
| def setName(self, name): | ||
| self.name = name | ||
|
|
||
| def getName(self): | ||
| return self.name | ||
|
|
||
| def setDescription(self, description): | ||
| self.description = description | ||
|
|
||
| def getDescription(self): | ||
| if self.description is not None: | ||
| return self.description | ||
| return None | ||
|
|
||
| def assignUser(self, userId): | ||
| self.userAssigned = userId | ||
|
|
||
| def removeUser(self): | ||
| self.userAssigned = None | ||
|
|
||
| def getUserName(self): | ||
| return self.userAssigned | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import string | ||
| import random | ||
|
|
||
|
|
||
| class IdGenerator(object): | ||
| generatedIds = set() | ||
|
|
||
| @staticmethod | ||
| def getStringId(): | ||
| randomString = ''.join([random.choice(string.ascii_letters | ||
| + string.digits) for _ in range(10)]) | ||
| return randomString | ||
|
|
||
| @classmethod | ||
| def generateUniqueId(cls): | ||
| randomString = cls.getStringId() | ||
| while randomString in cls.generatedIds: | ||
| randomString = cls.getStringId() | ||
| cls.generatedIds.add(randomString) | ||
| return randomString | ||
|
|
||
|
|
||
| class Access(object): | ||
| PRIVATE = "PRIVATE" | ||
| PUBLIC = "PUBLIC" | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from Trello.Models.Library import IdGenerator | ||
|
|
||
|
|
||
| class Lists(object): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. List |
||
|
|
||
| def __init__(self, name="", boardId=""): | ||
| self.id = IdGenerator.generateUniqueId() | ||
| self.name = name | ||
| self.boardId = boardId | ||
| self.cards = set() | ||
|
|
||
| def setName(self, name): | ||
| self.name = name | ||
|
|
||
| def addCard(self, cardId): | ||
| self.cards.add(cardId) | ||
|
|
||
| def removeCard(self, cardId): | ||
| if cardId not in self.cards: | ||
| print str(cardId) + " not present in List: " + str(self.id) | ||
| return | ||
| self.cards.remove(cardId) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from Trello.Models.Library import IdGenerator | ||
|
|
||
|
|
||
| class User(object): | ||
| def __init__(self, name="", email=""): | ||
| self.id = IdGenerator.generateUniqueId() | ||
| self.name = name | ||
| self.email = email | ||
|
|
||
| def setName(self, name): | ||
| self.name = name | ||
|
|
||
| def getName(self): | ||
| return self.name | ||
|
|
||
| def setEmail(self, email): | ||
| self.email = email |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| from Trello.Models.Board import Board | ||
| from Trello.Models.Library import Access | ||
|
|
||
|
|
||
| class BoardService(object): | ||
|
|
||
| def __init__(self): | ||
| self.boards = dict() | ||
| self.listService = None | ||
| self.cardService = None | ||
|
|
||
| def setServices(self, listService, cardService): | ||
| self.listService = listService | ||
| self.cardService = cardService | ||
|
|
||
| def validatePresent(self, boardId): | ||
| if boardId not in self.boards: | ||
| print "Board Id not present" | ||
| return False | ||
| return True | ||
|
|
||
| def createBoard(self, name): | ||
| board = Board(name) | ||
| self.boards[board.id] = board | ||
| print "Created Board: ", board.id | ||
|
|
||
| def updateName(self, boardId, name): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.setBoardName(name) | ||
|
|
||
| def updateAccess(self, boardId, access): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.setAccessSpecifier(access) | ||
|
|
||
| def addMemberToBoard(self, boardId, userId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.addMemberToBoard(userId) | ||
|
|
||
| def removeMemberFromBoard(self, boardId, userId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.removeMemberFromBoard(userId) | ||
|
|
||
| def addListInBoard(self, boardId, listId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.addListToBoard(listId) | ||
|
|
||
| def removeListFromBoard(self, boardId, listId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| board.removeListFromBoard(listId) | ||
|
|
||
| def deleteBoard(self, boardId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| for memberId in board.members: | ||
| self.removeMemberFromBoard(boardId, memberId) | ||
| for listId in board.lists: | ||
| # self.removeListFromBoard(boardId, listId) | ||
| self.listService.deleteList(listId) | ||
| del self.boards[boardId] | ||
|
|
||
| def showBoardDetailItem(self, boardId): | ||
| if not self.validatePresent(boardId): | ||
| return | ||
| board = self.boards[boardId] | ||
| boardItemInfo = "" | ||
| boardItemInfo += "ID: " + str( board.id ) | ||
| boardItemInfo += ", Name: " + str( board.name ) | ||
| boardItemInfo += ", privacy: " + str( board.privacy ) | ||
|
|
||
| listInfo = "" | ||
| isListPresent = False | ||
| for listId in board.lists: | ||
| isListPresent = True | ||
| if len(listInfo)>0: | ||
| listInfo += ", " | ||
| listInfo += "{ "+ self.listService.showListDetail(listId)+ " }" | ||
| if isListPresent: | ||
| boardItemInfo += "Lists: ", listInfo | ||
| # TODO List | ||
| isMembersPresent = False | ||
| membersInfo = "" | ||
| for members in board.members: | ||
| isMembersPresent = True | ||
| membersInfo += "{ Name: "+ str(members)+ "}" | ||
| if isMembersPresent: | ||
| boardItemInfo += "{ members: " + membersInfo + "}" | ||
| return boardItemInfo | ||
|
|
||
| def showBoardDetail(self): | ||
| boardInfo = "" | ||
| for boardId in self.boards: | ||
| boardInfo += "{ " + self.showBoardDetailItem(boardId)+ "}\n" | ||
| return boardInfo if len(boardInfo)>0 else None | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| from Trello.Models.Cards import Cards | ||
|
|
||
|
|
||
| class CardService(object): | ||
| def __init__(self): | ||
| self.cards = dict() | ||
| self.listService = None | ||
| self.boardService = None | ||
|
|
||
| def setServices(self, boardService, listService): | ||
| self.listService = listService | ||
| self.boardService = boardService | ||
|
|
||
| def createCard(self, cardName, listId): | ||
| card = Cards(name=cardName, listId=listId) | ||
| self.cards[card.id] = card | ||
| self.listService.addCardToList(listId, card.id) | ||
| print "Created Card: ", card.id | ||
|
|
||
| def updateCardName(self, cardId, name): | ||
| card = self.cards[cardId] | ||
| card.setName(name) | ||
|
|
||
| def updateDescription(self, cardId, description): | ||
| card = self.cards[cardId] | ||
| card.setDescription = description | ||
|
|
||
| def assignUserToCard(self, userId, cardId): | ||
| card = self.cards[cardId] | ||
| card.assignUser(userId) | ||
|
|
||
| def unAssignUserFromCard(self, cardId): | ||
| card = self.cards[cardId] | ||
| card.removeUser() | ||
|
|
||
| def moveCardToAnotherList(self, cardId, newListId): | ||
| card = self.cards[cardId] | ||
| if card.listId==newListId: | ||
| print "Same list id" | ||
| return | ||
| self.listService.removeCardFromList(card.listId, cardId) | ||
| self.listService.addCardToList(newListId, cardId) | ||
| card.listId = newListId | ||
|
|
||
| def deleteCard(self, cardId): | ||
| card = self.card[cardId] | ||
| self.listService.removeCardFromList(card.listId, cardId) | ||
| del self.cards[cardId] | ||
|
|
||
| def showCardDetail(self, cardId): | ||
| card = self.cards[cardId] | ||
| cardInfo = "" | ||
| cardInfo += "Id: "+ str(cardId) | ||
| cardInfo += " Name: "+ str(card.getName()) | ||
| if card.getDescription(): | ||
| cardInfo += " Description: " + str(card.getDescription()) | ||
| if card.getUserName(): | ||
| cardInfo += " UserName: " + card.getUserName() | ||
| return cardInfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| from Trello.Models.Lists import Lists | ||
|
|
||
|
|
||
| class ListService(object): | ||
|
|
||
| def __init__(self): | ||
| self.lists = dict() | ||
| self.boardService = None | ||
| self.cardService = None | ||
|
|
||
| def setServices(self, boardService, cardService): | ||
| self.boardService = boardService | ||
| self.cardService = cardService | ||
|
|
||
| def createList(self, boardId, name): | ||
| listWorks = Lists(name, boardId) | ||
| self.lists[listWorks.id] = listWorks | ||
| self.boardService.addListToBoard(boardId, listWorks.id) | ||
| print "Created List: ", listWorks.id | ||
|
|
||
| def addCardToList(self, listId, cardId): | ||
| listWorks = self.lists[listId] | ||
| listWorks.addCard(cardId) | ||
|
|
||
| def removeCardFromList(self, listId, cardId): | ||
| if listId not in self.lists: | ||
| print "ListId not present" | ||
| return | ||
| listWorks = self.lists[listId] | ||
| listWorks.removeCardFromList(cardId) | ||
|
|
||
| def deleteList(self, listId): | ||
| if listId not in self.lists: | ||
| print "List Id not present" | ||
| return | ||
| listWorks = self.lists[listId] | ||
| for cardId in listWorks.cards: | ||
| self.cardService.deleteCard(cardId) | ||
| del self.lists[listId] | ||
| self.boardService.removeListFromBoard(listWorks.boardId, listId) | ||
|
|
||
| def showListDetail(self, listId): | ||
| if listId not in self.lists: | ||
| return "" | ||
| listWorks = self.lists[listId] | ||
| listInfo = "" | ||
| listInfo += "ListID: " + str(listId) | ||
| listInfo += " Name: "+ str(listWorks.name) | ||
| isCardsPresent = False | ||
| cardInfo = "" | ||
| for cardId in listWorks.cards: | ||
| isCardsPresent = True | ||
| if len(cardInfo) > 0: | ||
| cardInfo += "," | ||
| cardInfo += " {" + self.cardService.showCardDetail(cardId) + "}" | ||
| if isCardsPresent: | ||
| listInfo += ", Cards: " + cardInfo | ||
| return listInfo | ||
|
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from Trello.Services.BoardService import BoardService | ||
|
|
||
| from Trello.Services.ListService import ListService | ||
|
|
||
| from Trello.Services.CardService import CardService | ||
|
|
||
|
|
||
| class TrelloManager(object): | ||
| def __init__(self): | ||
| self.boardService = BoardService() | ||
| self.listService = ListService() | ||
| self.cardService = CardService() | ||
|
|
||
| # Initialize each of these objects in other service class. | ||
| self.boardService.setServices(self.listService, self.cardService) | ||
| self.listService.setServices(self.boardService, self.cardService) | ||
| self.cardService.setServices(self.boardService, self.listService) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Card
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use plural