WIP Work on action
Very restrictive - use a 'current' table
This commit is contained in:
10
action.py
10
action.py
@@ -13,6 +13,8 @@ class TypeAction(Enum):
|
||||
CREATE = 'created'
|
||||
UPDATE = 'updated'
|
||||
MOVE = 'moved'
|
||||
DELETE = 'deleted'
|
||||
ACTIVE = 'activated'
|
||||
|
||||
class Action:
|
||||
def __init__(self, row):
|
||||
@@ -33,13 +35,15 @@ def handle_action(args, last_action, conn):
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(query)
|
||||
for row in cursor.fetchall():
|
||||
log_id, project_id, task_id, note_id, username, taction, message, created_at = row
|
||||
_, project_id, task_id, note_id, username, taction, message, created_at = row
|
||||
logging.debug(row)
|
||||
|
||||
formated_date = datetime.strptime(created_at[:26], '%Y-%m-%d %H:%M:%S.%f').strftime('%b %d, %Y %H:%M')
|
||||
|
||||
if taction == 'init':
|
||||
print('{} ({}): {}'.format(formated_date, username, message))
|
||||
elif taction == TypeAction.ACTIVE.value:
|
||||
print('{} ({}): {}'.format(formated_date, username, message))
|
||||
else:
|
||||
object_type = ''
|
||||
id_object = ''
|
||||
@@ -63,12 +67,12 @@ def handle_action(args, last_action, conn):
|
||||
# Jun 13, 2018 01:55 (edelweiss ): updated note 67: (message: Fix anonymize when get a replica with ID [task 30, status:in progress]
|
||||
# Jul 05, 2018 00:40 (budd): moved task 2: from project 1 to project 2
|
||||
|
||||
def create_action(cursor, project_id = '', task_id = '', note_id = '', message = '', action = TypeAction.CREATE):
|
||||
def record_action(cursor, action_type, message, project_id = '', task_id = None, note_id = None):
|
||||
query = """
|
||||
INSERT INTO action (project_id, task_id, note_id, username, action, message, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?);
|
||||
"""
|
||||
cursor.execute(query, (project_id, task_id, note_id, getpass.getuser(), action.value, message, datetime.now(),))
|
||||
cursor.execute(query, (project_id, task_id, note_id, getpass.getuser(), action_type.value, message, datetime.now(),))
|
||||
|
||||
logging.debug('created action')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user