Change way to set a project as active
This commit is contained in:
32
project.py
32
project.py
@@ -26,13 +26,8 @@ def handle_project(args, last_action, conn):
|
||||
sys.exit(0)
|
||||
|
||||
if args[0].isdigit():
|
||||
# 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)
|
||||
|
||||
# Use sys.exit when no add/update in Database
|
||||
|
||||
if args[0] == '-c':
|
||||
view_project_set_active(int(args[0]), last_action.task_id, conn)
|
||||
elif args[0] == '-c':
|
||||
if len(args) == 1:
|
||||
print('missing project name')
|
||||
sys.exit(1)
|
||||
@@ -142,6 +137,12 @@ def edit_project(project, project_id, conn):
|
||||
|
||||
update_args = [item for item in project.__dict__.items() if item[1] is not None]
|
||||
|
||||
if not update_args:
|
||||
print("nothing to update")
|
||||
print("Tips: if you want to set an active, just do '{} project <project_id>'"
|
||||
.format(os.path.basename(sys.argv[0])))
|
||||
sys.exit(1)
|
||||
|
||||
logging.debug('Project update args: {}'.format(update_args))
|
||||
|
||||
query = 'UPDATE project SET {} WHERE id = ?'
|
||||
@@ -149,15 +150,11 @@ def edit_project(project, project_id, conn):
|
||||
logging.debug('update project query: ' + query)
|
||||
|
||||
cursor = conn.cursor()
|
||||
if update_args:
|
||||
logging.debug('Do a project update')
|
||||
cursor.execute(query, (project_id,))
|
||||
logging.debug('Do a project update')
|
||||
cursor.execute(query, (project_id,))
|
||||
|
||||
log_args = ', '.join("%s: '%s'" % (k, v) for k, v in update_args)
|
||||
print('updated project {}: ({})'.format(project_id, log_args))
|
||||
else:
|
||||
print('updated project {}: set as active project'.format(project_id))
|
||||
# TODO If not project ID to set active
|
||||
log_args = ', '.join("%s: '%s'" % (k, v) for k, v in update_args)
|
||||
print('updated project {}: ({})'.format(project_id, log_args))
|
||||
|
||||
action.create_action(cursor, project_id, message = 'update ' + str(update_args))
|
||||
|
||||
@@ -193,7 +190,7 @@ def list_project(active_project_id, conn):
|
||||
print('{:1} {:2d}: ({:8}) | {} | {} ({} tasks)'.format('*' if active_project_id == project_id else '',
|
||||
project_id, username, status, name, nb_task))
|
||||
|
||||
def view_project(project_id, act_task_id, conn):
|
||||
def view_project_set_active(project_id, act_task_id, conn):
|
||||
# FIXME duplicate with list_project
|
||||
query = """
|
||||
SELECT id, username, name, status,
|
||||
@@ -219,5 +216,6 @@ def view_project(project_id, act_task_id, conn):
|
||||
message = date + time + name
|
||||
print(' {} {:d}: ({}) [{}] [{}] {} ({} tasks)'.format('*' if act_task_id == row[0] else ' ',
|
||||
task_id, username, status, priority, message, nb_note))
|
||||
action.create_action(cursor, project_id=project_id)
|
||||
|
||||
# TODO Add a -v option to see notes?
|
||||
# TODO Add a -v option to see notes?
|
||||
Reference in New Issue
Block a user