diff --git a/brewman/brewman/models/messaging.py b/brewman/brewman/models/messaging.py index 7e08d012..27c64cab 100644 --- a/brewman/brewman/models/messaging.py +++ b/brewman/brewman/models/messaging.py @@ -73,6 +73,10 @@ class Thread(Base): def by_id(cls, id): return DBSession.query(cls).filter(cls.id == id).first() + @classmethod + def by_title(cls, title): + return DBSession.query(cls).filter(cls.title == title).first() + @classmethod def list(cls): return DBSession.query(cls).all() @@ -102,6 +106,8 @@ class Post(Base): @classmethod def by_id(cls, id): + if not isinstance(id, uuid.UUID): + id = uuid.UUID(id) return DBSession.query(cls).filter(cls.id == id).first() @classmethod diff --git a/brewman/brewman/models/validation_exception.py b/brewman/brewman/models/validation_exception.py index 17ce7c97..29607b9f 100644 --- a/brewman/brewman/models/validation_exception.py +++ b/brewman/brewman/models/validation_exception.py @@ -1,5 +1,5 @@ from pyramid.response import Response -from sqlalchemy.exc import OperationalError +from sqlalchemy.exc import OperationalError, IntegrityError import transaction class ValidationError(Exception): @@ -18,7 +18,7 @@ def TryCatchFunction(f): def _decorator(self, *args, **kwargs): try: return f(self, *args, **kwargs) - except (ValidationError, ValueError, KeyError, AttributeError, TypeError, OperationalError) as ex: + except (ValidationError, ValueError, KeyError, AttributeError, TypeError, OperationalError, IntegrityError) as ex: transaction.abort() response = Response("Failed validation: {0}".format(str(ex))) response.status_int = 500 diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index 8a4cb039..1cd19418 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-06-07.1 +# version 2013-06-19.1 CACHE: /partial/404.html diff --git a/brewman/brewman/static/partial/message-detail.html b/brewman/brewman/static/partial/message-detail.html index a366c673..0f38de66 100644 --- a/brewman/brewman/static/partial/message-detail.html +++ b/brewman/brewman/static/partial/message-detail.html @@ -44,14 +44,14 @@