mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Bump utils to 40.2.1
Changes: https://github.com/alphagov/notifications-utils/compare/40.0.0...40.2.1
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
from abc import ABC, abstractmethod
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
import cachetools
|
import cachetools
|
||||||
from notifications_utils.clients.redis import RequestCache
|
from notifications_utils.clients.redis import RequestCache
|
||||||
|
from notifications_utils.serialised_model import (
|
||||||
|
SerialisedModel,
|
||||||
|
SerialisedModelCollection,
|
||||||
|
)
|
||||||
from werkzeug.utils import cached_property
|
from werkzeug.utils import cached_property
|
||||||
|
|
||||||
from app import db, redis_store
|
from app import db, redis_store
|
||||||
@@ -33,52 +36,6 @@ def ignore_first_argument_cache_key(cls, *args, **kwargs):
|
|||||||
return cachetools.keys.hashkey(*args, **kwargs)
|
return cachetools.keys.hashkey(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SerialisedModel(ABC):
|
|
||||||
|
|
||||||
"""
|
|
||||||
A SerialisedModel takes a dictionary, typically created by
|
|
||||||
serialising a database object. It then takes the value of specified
|
|
||||||
keys from the dictionary and adds them to itself as properties, so
|
|
||||||
that it can be interacted with like a normal database model object,
|
|
||||||
but with no risk that it will actually go back to the database.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@property
|
|
||||||
@abstractmethod
|
|
||||||
def ALLOWED_PROPERTIES(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self, _dict):
|
|
||||||
for property in self.ALLOWED_PROPERTIES:
|
|
||||||
setattr(self, property, _dict[property])
|
|
||||||
|
|
||||||
def __dir__(self):
|
|
||||||
return super().__dir__() + list(sorted(self.ALLOWED_PROPERTIES))
|
|
||||||
|
|
||||||
|
|
||||||
class SerialisedModelCollection(ABC):
|
|
||||||
|
|
||||||
"""
|
|
||||||
A SerialisedModelCollection takes a list of dictionaries, typically
|
|
||||||
created by serialising database objects. When iterated over it
|
|
||||||
returns a SerialisedModel instance for each of the items in the list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@property
|
|
||||||
@abstractmethod
|
|
||||||
def model(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self, items):
|
|
||||||
self.items = items
|
|
||||||
|
|
||||||
def __bool__(self):
|
|
||||||
return bool(self.items)
|
|
||||||
|
|
||||||
def __getitem__(self, index):
|
|
||||||
return self.model(self.items[index])
|
|
||||||
|
|
||||||
|
|
||||||
class SerialisedTemplate(SerialisedModel):
|
class SerialisedTemplate(SerialisedModel):
|
||||||
ALLOWED_PROPERTIES = {
|
ALLOWED_PROPERTIES = {
|
||||||
'archived',
|
'archived',
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ notifications-python-client==5.5.1
|
|||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@40.0.0#egg=notifications-utils==40.0.0
|
git+https://github.com/alphagov/notifications-utils.git@40.2.1#egg=notifications-utils==40.2.1
|
||||||
|
|
||||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
||||||
prometheus-client==0.7.1
|
prometheus-client==0.7.1
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ notifications-python-client==5.5.1
|
|||||||
# PaaS
|
# PaaS
|
||||||
awscli-cwlogs>=1.4,<1.5
|
awscli-cwlogs>=1.4,<1.5
|
||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@40.0.0#egg=notifications-utils==40.0.0
|
git+https://github.com/alphagov/notifications-utils.git@40.2.1#egg=notifications-utils==40.2.1
|
||||||
|
|
||||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
# gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains
|
||||||
prometheus-client==0.7.1
|
prometheus-client==0.7.1
|
||||||
@@ -40,14 +40,14 @@ alembic==1.4.2
|
|||||||
amqp==1.4.9
|
amqp==1.4.9
|
||||||
anyjson==0.3.3
|
anyjson==0.3.3
|
||||||
attrs==19.3.0
|
attrs==19.3.0
|
||||||
awscli==1.18.89
|
awscli==1.18.93
|
||||||
bcrypt==3.1.7
|
bcrypt==3.1.7
|
||||||
billiard==3.3.0.23
|
billiard==3.3.0.23
|
||||||
bleach==3.1.4
|
bleach==3.1.4
|
||||||
blinker==1.4
|
blinker==1.4
|
||||||
boto==2.49.0
|
boto==2.49.0
|
||||||
boto3==1.10.38
|
boto3==1.10.38
|
||||||
botocore==1.17.12
|
botocore==1.17.16
|
||||||
certifi==2020.6.20
|
certifi==2020.6.20
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
click==7.1.2
|
click==7.1.2
|
||||||
|
|||||||
Reference in New Issue
Block a user