Fix the spawn_notification to work in all cases and clean up some of the remaining code

This commit is contained in:
Joseph Schorr 2014-07-18 16:34:52 -04:00
parent 591cd020b8
commit 752efb9e0f
17 changed files with 18379 additions and 18415 deletions

View file

@ -0,0 +1,32 @@
from app import app, notification_queue
from data import model
import json
def spawn_notification(repo, event_name, extra_data={}, subpage=None, pathargs=[]):
repo_string = '%s/%s' % (repo.namespace, repo.name)
homepage = 'https://quay.io/repository/%s' % repo_string
if subpage:
homepage = homepage + subpage
event_data = {
'repository': repo_string,
'namespace': repo.namespace,
'name': repo.name,
'docker_url': 'quay.io/%s' % repo_string,
'homepage': homepage,
'visibility': repo.visibility.name
}
event_data.update(extra_data)
notifications = model.list_repo_notifications(repo.namespace, repo.name, event_name=event_name)
for notification in notifications:
notification_data = {
'notification_id': notification.id,
'repository_id': repo.id,
'event_data': event_data
}
path = [repo.namespace, repo.name, 'notification', event_name] + pathargs
notification_queue.put(path, json.dumps(notification_data))