class Item:
def __init__(self, id, content, userid, duedate, collapsed, inhistory, priority, itemorder, faded, projectid, checked, datestring):
self.id = id
self.content = content
self.userid = userid
self.duedate = duedate
self.collapsed = collapsed
self.inhistory = inhistory
self.priority = priority
self.itemorder = itemorder
self.faded = faded
self.projectid = projectid
self.checked = checked
self.datestring = datestring
def __str__(self):
return self.content
class Project:
def __init__(self, id, name, userid, color, collapsed, itemorder, indent, order):
self.id = id
self.name = name
self.userid = userid
self.color = color
self.collapsed = collapsed
self.itemorder = itemorder
self.indent = indent
self.order = order
self.items = {}
def __str__(self):
return self.name
def __name__(self):
return 'Project'
def addItem(self,item):
self.items.update({item.id:item})
def delItem(self,item):
del self.items[item.id]
class TodoList:
def __init__(self):
self.projects = {}
def addProject(self,project):
self.projects.update({project.id:project})
def delProject(self,project):
del self.projects[project.id]
def addItem(self,item):
self.projects[item.projectid].addItem(item)
def delItem(self,item):
self.projects[item.projectid].delItem(item)
Some of the above code is changing as we speak but I am curious if I should make the projects dict and items dicts private and use accessor functions to move items between projects or change the attributes of a project or item.
Another thought is to have items and projects both be members of TodoList as I am provided with the Item's project ID when I get the Item, so I could just have a method that returned all the items with a given project ID and not bother with separating them into the individual projects.
I am just trying to design the best I can as I plan on using this app as an example of my Python coding ability, though I just started with python about 3 days ago.