Added Project.find_by_url(project_url) because it's so commonly used as ID

This commit is contained in:
2016-09-20 12:35:42 +02:00
parent a3c87c27da
commit ae33fb64dc

View File

@@ -39,6 +39,14 @@ class Project(List, Find, Create, Post, Update, Delete, Replace):
else:
raise ResourceNotFound(response)
@classmethod
def find_by_url(cls, project_url, params=None, api=None):
if params is None:
params = {}
params.setdefault('where', {}).setdefault('url', project_url)
return cls.find_one(params, api=api)
def update(self, attributes=None, api=None):
api = api or self.api
attributes = attributes or self.to_dict()