From f7c154abb5626fdca1195ba26d63897c6c26db8c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 18 Jul 2014 14:12:20 -0400 Subject: [PATCH] Get Quay notification support working in the notification methods --- endpoints/notificationmethod.py | 32 +++++++++++++++---- initdb.py | 4 ++- .../external-notification-view.html | 7 +++- static/js/app.js | 10 +++++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/endpoints/notificationmethod.py b/endpoints/notificationmethod.py index a7fd7b87e..a9ffa78eb 100644 --- a/endpoints/notificationmethod.py +++ b/endpoints/notificationmethod.py @@ -57,13 +57,33 @@ class QuayNotificationMethod(NotificationMethod): # Probably deleted. return True - target_name = config_data['target']; - target = model.get_user(target_name) - if not target: - return False + # Lookup the target user or team to which we'll send the notification. + target_info = config_data['target'] + target_users = [] - model.create_notification(event_handler.event_name(), target, - metadata=notification_data['event_data']) + if target_info['kind'] == 'user': + target = model.get_user(target_info['name']) + if not target: + # Just to be safe. + return True + + target_users.append(target) + elif target_info['kind'] == 'team': + # Lookup the team. + team = None + try: + team = model.get_organization_team(repository.namespace, target_info['name']) + except model.InvalidTeamException: + # Probably deleted. + return True + + # Lookup the team's members + target_users = model.get_organization_team_members(team.id) + + # For each of the target users, create a notification. + for target_user in set(target_users): + model.create_notification(event_handler.event_name(), target_user, + metadata=notification_data['event_data']) return True diff --git a/initdb.py b/initdb.py index 20d442c8f..99a9f0624 100644 --- a/initdb.py +++ b/initdb.py @@ -347,6 +347,7 @@ def populate_database(): (1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)], None)) + """ __generate_repository(new_user_1, 'insane', None, False, [], (2, [(3, [], 'v2.0'), (1, [(1, [(1, [], ['latest', 'prod'])], @@ -384,7 +385,8 @@ def populate_database(): (5, [], 'v4.20'), (1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)], None)) - + """ + __generate_repository(new_user_2, 'publicrepo', 'Public repository pullable by the world.', True, [], (10, [], 'latest')) diff --git a/static/directives/external-notification-view.html b/static/directives/external-notification-view.html index 3a3d7abfe..aa173879e 100644 --- a/static/directives/external-notification-view.html +++ b/static/directives/external-notification-view.html @@ -34,7 +34,7 @@ -
+
To @@ -45,6 +45,11 @@ To {{ config.url }} + + + To + +
diff --git a/static/js/app.js b/static/js/app.js index 6ef24b750..b1b79ae2f 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1110,6 +1110,13 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading 'message': 'We will be down for schedule maintenance from {from_date} to {to_date} ' + 'for {reason}. We are sorry about any inconvenience.', 'page': 'http://status.quay.io/' + }, + 'repo_push': { + 'level': 'info', + 'message': 'Repository {repository} has been pushed with the following tags updated: {updated_tags}', + 'page': function(metadata) { + return '/repository/' + metadata.repository; + } } }; @@ -4668,7 +4675,8 @@ quayApp.directive('externalNotificationView', function () { ApiService.testRepoNotification(null, params).then(function() { bootbox.dialog({ - "message": "Test Notification Sent", + "title": "Test Notification Queued", + "message": "A test version of this notification has been queued and should appear shortly", "buttons": { "close": { "label": "Close",