Flesh out the webworkers a bit.
This commit is contained in:
parent
7a071fa731
commit
c1ea6263e1
5 changed files with 144 additions and 6 deletions
|
@ -2,6 +2,7 @@ import bcrypt
|
|||
import logging
|
||||
import dateutil.parser
|
||||
import operator
|
||||
import json
|
||||
|
||||
from database import *
|
||||
from util.validation import *
|
||||
|
@ -42,6 +43,10 @@ class InvalidRepositoryBuildException(DataModelException):
|
|||
pass
|
||||
|
||||
|
||||
class InvalidWebhookException(DataModelException):
|
||||
pass
|
||||
|
||||
|
||||
def create_user(username, password, email):
|
||||
if not validate_email(email):
|
||||
raise InvalidEmailAddressException('Invalid email address: %s' % email)
|
||||
|
@ -935,3 +940,25 @@ def list_repository_builds(namespace_name, repository_name,
|
|||
def create_repository_build(repo, access_token, resource_key, tag):
|
||||
return RepositoryBuild.create(repository=repo, access_token=access_token,
|
||||
resource_key=resource_key, tag=tag)
|
||||
|
||||
|
||||
def create_webhook(repo, params_obj):
|
||||
return Webhook.create(repository=repo, parameters=json.dumps(params_obj))
|
||||
|
||||
|
||||
def get_webhook(namespace_name, repository_name, public_id):
|
||||
joined = Webhook.select().join(Repository)
|
||||
found = list(joined.where(Repository.namespace == namespace_name,
|
||||
Repository.name == repository_name,
|
||||
Webhook.public_id == public_id))
|
||||
|
||||
if not found:
|
||||
raise InvalidWebhookException('No webhook found with id: %s' % public_id)
|
||||
|
||||
return found[0]
|
||||
|
||||
|
||||
def list_webhooks(namespace_name, repository_name):
|
||||
joined = Webhook.select().join(Repository)
|
||||
return joined.where(Repository.namespace == namespace_name,
|
||||
Repository.name == repository_name)
|
||||
|
|
Reference in a new issue