mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Merge pull request #3219 from alphagov/pyup-scheduled-update-2021-04-21
Scheduled weekly dependency update for week 16
This commit is contained in:
@@ -150,9 +150,12 @@ def fetch_letter_line_items_for_all_services(start_date, end_date):
|
||||
[(FactBilling.postage.in_(INTERNATIONAL_POSTAGE_TYPES), "international")], else_=FactBilling.postage
|
||||
).label("postage")
|
||||
|
||||
postage_order = case(((formatted_postage == "second", 1),
|
||||
(formatted_postage == "first", 2),
|
||||
(formatted_postage == "international", 3)))
|
||||
postage_order = case(
|
||||
(formatted_postage == "second", 1),
|
||||
(formatted_postage == "first", 2),
|
||||
(formatted_postage == "international", 3),
|
||||
else_=0 # assumes never get 0 as a result
|
||||
)
|
||||
|
||||
query = db.session.query(
|
||||
Organisation.name.label("organisation_name"),
|
||||
|
||||
@@ -71,7 +71,13 @@ def dao_count_inbound_sms_for_service(service_id, limit_days):
|
||||
def _insert_inbound_sms_history(subquery, query_limit=10000):
|
||||
offset = 0
|
||||
inbound_sms_query = db.session.query(
|
||||
*[x.name for x in InboundSmsHistory.__table__.c]
|
||||
InboundSms.id,
|
||||
InboundSms.created_at,
|
||||
InboundSms.service_id,
|
||||
InboundSms.notify_number,
|
||||
InboundSms.provider_date,
|
||||
InboundSms.provider_reference,
|
||||
InboundSms.provider
|
||||
).filter(InboundSms.id.in_(subquery))
|
||||
inbound_sms_count = inbound_sms_query.count()
|
||||
|
||||
|
||||
@@ -328,11 +328,11 @@ def delete_notifications_older_than_retention_by_type(notification_type, qry_lim
|
||||
|
||||
seven_days_ago = get_london_midnight_in_utc(convert_utc_to_bst(datetime.utcnow()).date()) - timedelta(days=7)
|
||||
services_with_data_retention = [x.service_id for x in flexible_data_retention]
|
||||
service_ids_to_purge = db.session.query(Service.id).filter(Service.id.notin_(services_with_data_retention)).all()
|
||||
service_ids_to_purge = Service.query.filter(Service.id.notin_(services_with_data_retention)).all()
|
||||
|
||||
for service_id in service_ids_to_purge:
|
||||
for service in service_ids_to_purge:
|
||||
deleted += _move_notifications_to_notification_history(
|
||||
notification_type, service_id, seven_days_ago, qry_limit)
|
||||
notification_type, service.id, seven_days_ago, qry_limit)
|
||||
|
||||
current_app.logger.info('Finished deleting {} notifications'.format(notification_type))
|
||||
|
||||
|
||||
@@ -9,9 +9,13 @@ def dao_get_service_user(user_id, service_id):
|
||||
|
||||
|
||||
def dao_get_active_service_users(service_id):
|
||||
query = ServiceUser.query.join(ServiceUser.user).filter(
|
||||
ServiceUser.service_id == service_id,
|
||||
User.state == 'active'
|
||||
query = db.session.query(
|
||||
ServiceUser
|
||||
).join(
|
||||
User, User.id == ServiceUser.user_id
|
||||
).filter(
|
||||
User.state == 'active',
|
||||
ServiceUser.service_id == service_id
|
||||
)
|
||||
|
||||
return query.all()
|
||||
|
||||
@@ -43,9 +43,6 @@ def dao_create_template(template):
|
||||
VersionOptions(Template, history_class=TemplateHistory)
|
||||
)
|
||||
def dao_update_template(template):
|
||||
if template.archived:
|
||||
template.folder = None
|
||||
|
||||
db.session.add(template)
|
||||
|
||||
|
||||
|
||||
@@ -199,8 +199,6 @@ class ServiceUser(db.Model):
|
||||
UniqueConstraint('user_id', 'service_id', name='uix_user_to_service'),
|
||||
)
|
||||
|
||||
user = db.relationship('User')
|
||||
|
||||
|
||||
user_to_organisation = db.Table(
|
||||
'user_to_organisation',
|
||||
@@ -674,7 +672,6 @@ class ServicePermission(db.Model):
|
||||
primary_key=True, index=True, nullable=False)
|
||||
permission = db.Column(db.String(255), db.ForeignKey('service_permission_types.name'),
|
||||
index=True, primary_key=True, nullable=False)
|
||||
service = db.relationship("Service")
|
||||
created_at = db.Column(db.DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||
|
||||
service_permission_types = db.relationship(
|
||||
|
||||
@@ -157,7 +157,8 @@ def update_template(service_id, template_id):
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
update_dict = template_schema.load(updated_template).data
|
||||
|
||||
if update_dict.archived:
|
||||
update_dict.folder = None
|
||||
dao_update_template(update_dict)
|
||||
return jsonify(data=template_schema.dump(update_dict).data), 200
|
||||
|
||||
|
||||
@@ -405,7 +405,7 @@ def set_permissions(user_id, service_id):
|
||||
# TODO fix security hole, how do we verify that the user
|
||||
# who is making this request has permission to make the request.
|
||||
service_user = dao_get_service_user(user_id, service_id)
|
||||
user = service_user.user
|
||||
user = get_user_by_id(user_id)
|
||||
service = dao_fetch_service_by_id(service_id=service_id)
|
||||
|
||||
data = request.get_json()
|
||||
|
||||
Reference in New Issue
Block a user