Naive view project function
This commit is contained in:
36
project.py
36
project.py
@@ -26,7 +26,8 @@ def handle_project(args, last_action, conn):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args[0].isdigit():
|
if args[0].isdigit():
|
||||||
view_project()
|
# TODO I see that in the original pit, this command set project as active!
|
||||||
|
view_project(int(args[0]), last_action.task_id, conn)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# Use sys.exit when no add/update in Database
|
# Use sys.exit when no add/update in Database
|
||||||
@@ -177,7 +178,6 @@ def delete_project(project_id, conn):
|
|||||||
print('deleted project {}: {}'.format(project_id, 'project_name'))
|
print('deleted project {}: {}'.format(project_id, 'project_name'))
|
||||||
|
|
||||||
def list_project(active_project_id, conn):
|
def list_project(active_project_id, conn):
|
||||||
logging.info('>> No arguments')
|
|
||||||
query = """
|
query = """
|
||||||
SELECT id, username, name, status,
|
SELECT id, username, name, status,
|
||||||
(SELECT count(*) FROM task WHERE task.project_id = project.id)
|
(SELECT count(*) FROM task WHERE task.project_id = project.id)
|
||||||
@@ -189,9 +189,35 @@ def list_project(active_project_id, conn):
|
|||||||
for row in cursor.fetchall():
|
for row in cursor.fetchall():
|
||||||
logging.debug('Project row: {}'.format(row))
|
logging.debug('Project row: {}'.format(row))
|
||||||
project_id, username, name, status, nb_task = row
|
project_id, username, name, status, nb_task = row
|
||||||
|
# TODO Formatting track: https://stackoverflow.com/questions/9989334/create-nice-column-output-in-python
|
||||||
print('{:1} {:2d}: ({:8}) | {} | {} ({} tasks)'.format('*' if active_project_id == project_id else '',
|
print('{:1} {:2d}: ({:8}) | {} | {} ({} tasks)'.format('*' if active_project_id == project_id else '',
|
||||||
project_id, username, status, name, nb_task))
|
project_id, username, status, name, nb_task))
|
||||||
|
|
||||||
def view_project():
|
def view_project(project_id, act_task_id, conn):
|
||||||
print("TODO View Project")
|
# FIXME duplicate with list_project
|
||||||
#TODO
|
query = """
|
||||||
|
SELECT id, username, name, status,
|
||||||
|
(SELECT count(*) FROM task WHERE task.project_id = project.id)
|
||||||
|
FROM project WHERE id = ?;
|
||||||
|
"""
|
||||||
|
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(query, (project_id,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
print('* {:d}: ({}) {} (status: {}, {} tasks)'.format(*row))
|
||||||
|
|
||||||
|
# FIXME duplicate with list_task
|
||||||
|
query = """
|
||||||
|
SELECT id, username, name, status, priority, date, time,
|
||||||
|
(SELECT count(*) FROM note WHERE note.task_id = task.id)
|
||||||
|
FROM task WHERE project_id = ?
|
||||||
|
"""
|
||||||
|
cursor.execute(query, (project_id,))
|
||||||
|
for row in cursor.fetchall():
|
||||||
|
logging.debug('Task row: {}'.format(row))
|
||||||
|
task_id, username, name, status, priority, date, time, nb_note = row
|
||||||
|
message = date + time + name
|
||||||
|
print(' {} {:d}: ({}) [{}] [{}] {} ({} tasks)'.format('*' if act_task_id == row[0] else ' ',
|
||||||
|
task_id, username, status, priority, message, nb_note))
|
||||||
|
|
||||||
|
# TODO Add a -v option to see notes?
|
||||||
|
|||||||
Reference in New Issue
Block a user