diff --git a/data/database.py b/data/database.py index 225b0c11c..6309c4eb4 100644 --- a/data/database.py +++ b/data/database.py @@ -722,6 +722,7 @@ class RepositoryNotification(BaseModel): repository = ForeignKeyField(Repository, index=True) event = ForeignKeyField(ExternalNotificationEvent) method = ForeignKeyField(ExternalNotificationMethod) + title = CharField(null=True) config_json = TextField() diff --git a/data/model/notification.py b/data/model/notification.py index b894a1cf7..87ae7f7ca 100644 --- a/data/model/notification.py +++ b/data/model/notification.py @@ -113,12 +113,12 @@ def delete_matching_notifications(target, kind_name, **kwargs): notification.delete_instance() -def create_repo_notification(repo, event_name, method_name, config): +def create_repo_notification(repo, event_name, method_name, config, title=None): event = ExternalNotificationEvent.get(ExternalNotificationEvent.name == event_name) method = ExternalNotificationMethod.get(ExternalNotificationMethod.name == method_name) return RepositoryNotification.create(repository=repo, event=event, method=method, - config_json=json.dumps(config)) + config_json=json.dumps(config), title=title) def get_repo_notification(uuid): diff --git a/endpoints/api/repositorynotification.py b/endpoints/api/repositorynotification.py index 54643ccc3..832328cbe 100644 --- a/endpoints/api/repositorynotification.py +++ b/endpoints/api/repositorynotification.py @@ -26,7 +26,8 @@ def notification_view(note): 'uuid': note.uuid, 'event': note.event.name, 'method': note.method.name, - 'config': config + 'config': config, + 'title': note.title, } @@ -55,7 +56,11 @@ class RepositoryNotificationList(RepositoryParamResource): 'config': { 'type': 'object', 'description': 'JSON config information for the specific method of notification' - } + }, + 'title': { + 'type': 'string', + 'description': 'The human-readable title of the notification', + }, } }, } @@ -78,7 +83,8 @@ class RepositoryNotificationList(RepositoryParamResource): raise request_error(message=ex.message) new_notification = model.notification.create_repo_notification(repo, parsed['event'], - parsed['method'], parsed['config']) + parsed['method'], parsed['config'], + parsed.get('title', None)) resp = notification_view(new_notification) log_action('add_repo_notification', namespace, diff --git a/static/directives/create-external-notification-dialog.html b/static/directives/create-external-notification-dialog.html index 0b7401c30..592efc322 100644 --- a/static/directives/create-external-notification-dialog.html +++ b/static/directives/create-external-notification-dialog.html @@ -11,14 +11,14 @@