diff --git a/data/model.py b/data/model.py index 50ef5892e..f95fe5a2a 100644 --- a/data/model.py +++ b/data/model.py @@ -1067,12 +1067,12 @@ def list_logs(user_or_organization_name, repository = None): return joined.where(User.username == user_or_organization_name, LogEntry.datetime >= week_ago).order_by(LogEntry.datetime.desc()) def log_action(kind_name, user_or_organization_name, performer=None, repository=None, - access_token=None, ip=None, metadata={}, datetime=None): - if not datetime: - datetime = datetime.today() + access_token=None, ip=None, metadata={}, timestamp=None): + if not timestamp: + timestamp = datetime.today() kind = LogEntryKind.get(LogEntryKind.name == kind_name) account = User.get(User.username == user_or_organization_name) entry = LogEntry.create(kind=kind, account=account, performer=performer, repository=repository, access_token=access_token, ip=ip, - metadata_json=json.dumps(metadata), datetime=datetime) + metadata_json=json.dumps(metadata), datetime=timestamp) diff --git a/initdb.py b/initdb.py index f1c3c5788..5dc75e52f 100644 --- a/initdb.py +++ b/initdb.py @@ -252,31 +252,31 @@ def populate_database(): six_ago = today - timedelta(5) four_ago = today - timedelta(4) - model.log_action('org_create_team', org.username, performer=new_user_1, datetime=week_ago, + model.log_action('org_create_team', org.username, performer=new_user_1, timestamp=week_ago, metadata={'team': 'readers'}) - model.log_action('org_set_team_role', org.username, performer=new_user_1, datetime=week_ago, + model.log_action('org_set_team_role', org.username, performer=new_user_1, timestamp=week_ago, metadata={'team': 'readers', 'role': 'read'}) - model.log_action('create_repo', org.username, performer=new_user_1, repository=org_repo, datetime=week_ago, + model.log_action('create_repo', org.username, performer=new_user_1, repository=org_repo, timestamp=week_ago, metadata={'namespace': org.username, 'repo': 'orgrepo'}) - model.log_action('change_repo_permission', org.username, performer=new_user_2, repository=org_repo, datetime=six_ago, + model.log_action('change_repo_permission', org.username, performer=new_user_2, repository=org_repo, timestamp=six_ago, metadata={'username': new_user_1.username, 'repo': 'orgrepo', 'role': 'admin'}) - model.log_action('change_repo_permission', org.username, performer=new_user_1, repository=org_repo, datetime=six_ago, + model.log_action('change_repo_permission', org.username, performer=new_user_1, repository=org_repo, timestamp=six_ago, metadata={'username': new_user_2.username, 'repo': 'orgrepo', 'role': 'read'}) - model.log_action('add_repo_accesstoken', org.username, performer=new_user_1, repository=org_repo, datetime=four_ago, + model.log_action('add_repo_accesstoken', org.username, performer=new_user_1, repository=org_repo, timestamp=four_ago, metadata={'repo': 'orgrepo', 'token': 'deploytoken'}) - model.log_action('push_repo', org.username, performer=new_user_2, repository=org_repo, datetime=today, + model.log_action('push_repo', org.username, performer=new_user_2, repository=org_repo, timestamp=today, metadata={'username': new_user_2.username, 'repo': 'orgrepo'}) - model.log_action('pull_repo', org.username, performer=new_user_2, repository=org_repo, datetime=today, + model.log_action('pull_repo', org.username, performer=new_user_2, repository=org_repo, timestamp=today, metadata={'username': new_user_2.username, 'repo': 'orgrepo'}) - model.log_action('pull_repo', org.username, repository=org_repo, datetime=today, + model.log_action('pull_repo', org.username, repository=org_repo, timestamp=today, metadata={'token': 'sometoken', 'token_code': 'somecode', 'repo': 'orgrepo'}) if __name__ == '__main__': diff --git a/test/data/test.db b/test/data/test.db index fdb9329a0..c2ef5d652 100644 Binary files a/test/data/test.db and b/test/data/test.db differ