mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 12:19:47 -04:00
12
.flake8
12
.flake8
@@ -1,7 +1,15 @@
|
||||
[flake8]
|
||||
# Rule definitions: http://flake8.pycqa.org/en/latest/user/error-codes.html
|
||||
# W503: line break before binary operator
|
||||
exclude = venv*,__pycache__,node_modules,cache
|
||||
ignore = W503
|
||||
max-complexity = 14
|
||||
max-line-length = 120
|
||||
|
||||
# B003 assigning to os.environ
|
||||
# B306 BaseException.message has been deprecated
|
||||
# W503: line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
extend_ignore=
|
||||
B003,
|
||||
B306,
|
||||
W503,
|
||||
W504
|
||||
|
||||
@@ -246,7 +246,10 @@ def get_notifications_as_json(service_id, message_type=None):
|
||||
|
||||
|
||||
@main.route('/services/<uuid:service_id>/notifications.csv', endpoint="view_notifications_csv")
|
||||
@main.route('/services/<uuid:service_id>/notifications/<template_type:message_type>.csv', endpoint="view_notifications_csv")
|
||||
@main.route(
|
||||
'/services/<uuid:service_id>/notifications/<template_type:message_type>.csv',
|
||||
endpoint="view_notifications_csv"
|
||||
)
|
||||
@user_has_permissions()
|
||||
def get_notifications(service_id, message_type, status_override=None):
|
||||
# TODO get the api to return count of pages as well.
|
||||
|
||||
@@ -601,7 +601,10 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/<uuid:template_id>/check/<uuid:upload_id>", methods=['GET'])
|
||||
@main.route("/services/<uuid:service_id>/<uuid:template_id>/check/<uuid:upload_id>/row-<int:row_index>", methods=['GET'])
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/<uuid:template_id>/check/<uuid:upload_id>/row-<int:row_index>",
|
||||
methods=['GET']
|
||||
)
|
||||
@user_has_permissions('send_messages', restrict_admin_usage=True)
|
||||
def check_messages(service_id, template_id, upload_id, row_index=2):
|
||||
|
||||
|
||||
@@ -425,7 +425,10 @@ def service_add_email_reply_to(service_id):
|
||||
first_email_address=first_email_address)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/service-settings/email-reply-to/<uuid:notification_id>/verify", methods=['GET', 'POST'])
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-reply-to/<uuid:notification_id>/verify",
|
||||
methods=['GET', 'POST']
|
||||
)
|
||||
@user_has_permissions('manage_service')
|
||||
def service_verify_reply_to_address(service_id, notification_id):
|
||||
replace = request.args.get('replace', False)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial
|
||||
from string import ascii_uppercase
|
||||
|
||||
from dateutil.parser import parse
|
||||
from flask import abort, flash, redirect, render_template, request, url_for
|
||||
@@ -10,7 +9,6 @@ from notifications_python_client.errors import HTTPError
|
||||
from notifications_utils import LETTER_MAX_PAGE_COUNT
|
||||
from notifications_utils.formatters import nl2br
|
||||
from notifications_utils.pdf import is_letter_too_long
|
||||
from notifications_utils.recipients import first_column_headings
|
||||
|
||||
from app import (
|
||||
current_service,
|
||||
@@ -29,7 +27,7 @@ from app.main.forms import (
|
||||
TemplateAndFoldersSelectionForm,
|
||||
TemplateFolderForm,
|
||||
)
|
||||
from app.main.views.send import get_example_csv_rows, get_sender_details
|
||||
from app.main.views.send import get_sender_details
|
||||
from app.models.service import Service
|
||||
from app.models.template_list import TemplateList, TemplateLists
|
||||
from app.template_previews import TemplatePreview, get_page_count_for_letter
|
||||
@@ -110,7 +108,10 @@ def start_tour(service_id, template_id):
|
||||
@main.route("/services/<uuid:service_id>/templates/folders/<uuid:template_folder_id>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<uuid:service_id>/templates/<template_type:template_type>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<uuid:service_id>/templates/all/folders/<uuid:template_folder_id>", methods=['GET', 'POST'])
|
||||
@main.route("/services/<uuid:service_id>/templates/<template_type:template_type>/folders/<uuid:template_folder_id>", methods=['GET', 'POST'])
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/templates/<template_type:template_type>/folders/<uuid:template_folder_id>",
|
||||
methods=['GET', 'POST']
|
||||
)
|
||||
@user_has_permissions()
|
||||
def choose_template(service_id, template_type='all', template_folder_id=None):
|
||||
template_folder = current_service.get_template_folder(template_folder_id)
|
||||
@@ -329,7 +330,9 @@ def _add_template_by_type(template_type, template_folder_id):
|
||||
@main.route("/services/<uuid:service_id>/templates/copy")
|
||||
@main.route("/services/<uuid:service_id>/templates/copy/from-folder/<uuid:from_folder>")
|
||||
@main.route("/services/<uuid:service_id>/templates/copy/from-service/<uuid:from_service>")
|
||||
@main.route("/services/<uuid:service_id>/templates/copy/from-service/<uuid:from_service>/from-folder/<uuid:from_folder>")
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/templates/copy/from-service/<uuid:from_service>/from-folder/<uuid:from_folder>"
|
||||
)
|
||||
@user_has_permissions('manage_templates')
|
||||
def choose_template_to_copy(
|
||||
service_id,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
This script can be used to retrieve Zendesk tickets.
|
||||
This can be run locally if you set the ZENDESK_API_KEY. Or the script can be run from a flask shell from a ssh session.
|
||||
"""
|
||||
# flake8: noqa: T001 (print)
|
||||
|
||||
import os
|
||||
import requests
|
||||
import urllib.parse
|
||||
@@ -137,4 +139,3 @@ def get_tickets_with_description():
|
||||
'Tags': row.get('tags', '')
|
||||
})
|
||||
next_page = data["next_page"]
|
||||
|
||||
|
||||
@@ -9,8 +9,3 @@ multi_line_output=3
|
||||
known_third_party=notifications_utils,notifications_python_client
|
||||
known_first_party=app,tests
|
||||
include_trailing_comma=True
|
||||
|
||||
[flake8]
|
||||
# W504 line break after binary operator
|
||||
extend_ignore=B003, B306, W504
|
||||
select=B901, B902, B903
|
||||
|
||||
@@ -6,9 +6,8 @@ from unittest.mock import ANY, call
|
||||
|
||||
import pyexcel
|
||||
import pytest
|
||||
import requests_mock
|
||||
from bs4 import BeautifulSoup
|
||||
from flask import current_app, url_for
|
||||
from flask import url_for
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.main.views.platform_admin import (
|
||||
|
||||
@@ -68,7 +68,11 @@ def test_post_upload_letter_redirects_for_valid_file(
|
||||
)
|
||||
mock_s3 = mocker.patch('app.main.views.uploads.upload_letter_to_s3')
|
||||
mocker.patch('app.main.views.uploads.get_letter_metadata', return_value={
|
||||
'filename': 'tests/test_pdf_files/one_page_pdf.pdf', 'page_count': '1', 'status': 'valid', 'recipient': 'The Queen'})
|
||||
'filename': 'tests/test_pdf_files/one_page_pdf.pdf',
|
||||
'page_count': '1',
|
||||
'status': 'valid',
|
||||
'recipient': 'The Queen'
|
||||
})
|
||||
mocker.patch('app.main.views.uploads.service_api_client.get_precompiled_template')
|
||||
|
||||
service_one['restricted'] = False
|
||||
@@ -125,7 +129,11 @@ def test_post_upload_letter_shows_letter_preview_for_valid_file(
|
||||
mocker.patch('app.main.views.uploads.upload_letter_to_s3')
|
||||
mocker.patch('app.main.views.uploads.pdf_page_count', return_value=3)
|
||||
mocker.patch('app.main.views.uploads.get_letter_metadata', return_value={
|
||||
'filename': 'tests/test_pdf_files/one_page_pdf.pdf', 'page_count': '3', 'status': 'valid', 'recipient': 'The Queen'})
|
||||
'filename': 'tests/test_pdf_files/one_page_pdf.pdf',
|
||||
'page_count': '3',
|
||||
'status': 'valid',
|
||||
'recipient': 'The Queen'
|
||||
})
|
||||
mocker.patch('app.main.views.uploads.service_api_client.get_precompiled_template', return_value=letter_template)
|
||||
|
||||
service_one['restricted'] = False
|
||||
|
||||
Reference in New Issue
Block a user