Fix date time parameter on log_action to properly use the current time (for reals)

This commit is contained in:
Joseph Schorr 2013-12-03 16:48:44 -05:00
parent c7ee3aaea1
commit 9a61903d28
3 changed files with 13 additions and 13 deletions

View file

@ -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)

View file

@ -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__':

Binary file not shown.