mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge branch 'master' into celery-jobs
This commit is contained in:
@@ -70,7 +70,7 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
endpoint = "/service/{0}".format(service_id)
|
||||
return self.put(endpoint, data)
|
||||
|
||||
def create_service_template(self, name, type_, content, service_id):
|
||||
def create_service_template(self, name, type_, content, service_id, subject=None):
|
||||
"""
|
||||
Create a service template.
|
||||
"""
|
||||
@@ -80,10 +80,14 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
"content": content,
|
||||
"service": service_id
|
||||
}
|
||||
if subject:
|
||||
data.update({
|
||||
'subject': subject
|
||||
})
|
||||
endpoint = "/service/{0}/template".format(service_id)
|
||||
return self.post(endpoint, data)
|
||||
|
||||
def update_service_template(self, id_, name, type_, content, service_id):
|
||||
def update_service_template(self, id_, name, type_, content, service_id, subject=None):
|
||||
"""
|
||||
Update a service template.
|
||||
"""
|
||||
@@ -94,8 +98,12 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
'content': content,
|
||||
'service': service_id
|
||||
}
|
||||
if subject:
|
||||
data.update({
|
||||
'subject': subject
|
||||
})
|
||||
endpoint = "/service/{0}/template/{1}".format(service_id, id_)
|
||||
return self.put(endpoint, data)
|
||||
return self.post(endpoint, data)
|
||||
|
||||
def get_service_template(self, service_id, template_id, *params):
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from notifications_python_client.notifications import BaseAPIClient
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from flask.ext.login import UserMixin
|
||||
from flask.ext.login import (UserMixin, login_fresh)
|
||||
|
||||
|
||||
class UserApiClient(BaseAPIClient):
|
||||
@@ -81,6 +81,11 @@ class UserApiClient(BaseAPIClient):
|
||||
return False, 'Code not found'
|
||||
raise e
|
||||
|
||||
def get_users_for_service(self, service_id):
|
||||
endpoint = '/service/{}/users'.format(service_id)
|
||||
resp = self.get(endpoint)
|
||||
return resp['data']
|
||||
|
||||
|
||||
class User(UserMixin):
|
||||
def __init__(self, fields, max_failed_login_count=3):
|
||||
@@ -100,6 +105,12 @@ class User(UserMixin):
|
||||
def is_active(self):
|
||||
return self.state == 'active'
|
||||
|
||||
def is_authenticated(self):
|
||||
# To handle remember me token renewal
|
||||
if not login_fresh():
|
||||
return False
|
||||
return super(User, self).is_authenticated()
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
Reference in New Issue
Block a user