Jun 27 MT-6

This commit is contained in:
2026-06-27 20:21:33 -04:00
parent b46c1a7dd5
commit ee7b0286b2
7 changed files with 21 additions and 0 deletions
+3
View File
@@ -26,6 +26,7 @@ from app.models.inspection import Inspection, InspectionTemplate
from app.models.facility import Facility, Area from app.models.facility import Facility, Area
from app.api.errors import api_ok, api_error from app.api.errors import api_ok, api_error
from app.api.decorators import jwt_required from app.api.decorators import jwt_required
from app.tenancy.gates import feature_required, quota_soft_check
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE
from app.utils.notifications import notify_by_matrix from app.utils.notifications import notify_by_matrix
from app.utils.time_utils import now_eastern from app.utils.time_utils import now_eastern
@@ -242,6 +243,8 @@ def list_inspections():
@bp.route('/inspections', methods=['POST']) @bp.route('/inspections', methods=['POST'])
@jwt_required @jwt_required
@feature_required('mobile_api')
@quota_soft_check('inspections')
def create_inspection(): def create_inspection():
""" """
Create a new inspection submitted from the iPad app. Create a new inspection submitted from the iPad app.
+3
View File
@@ -32,6 +32,7 @@ from app.models.facility import Facility, Area
from app.models.inspection import Inspection from app.models.inspection import Inspection
from app.api.errors import api_ok, api_error from app.api.errors import api_ok, api_error
from app.api.decorators import jwt_required from app.api.decorators import jwt_required
from app.tenancy.gates import feature_required, quota_soft_check
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE
from app.utils.notifications import notify_by_matrix from app.utils.notifications import notify_by_matrix
from app.utils.time_utils import now_eastern from app.utils.time_utils import now_eastern
@@ -159,6 +160,8 @@ def list_issues():
@bp.route('/issues', methods=['POST']) @bp.route('/issues', methods=['POST'])
@jwt_required @jwt_required
@feature_required('mobile_api')
@quota_soft_check('issues')
def create_issue(): def create_issue():
""" """
Create a new issue submitted from the iPad app. Create a new issue submitted from the iPad app.
+2
View File
@@ -7,6 +7,7 @@ from app.utils.forms import LoginForm, UserForm, ProfileForm, ForgotPasswordForm
from app.utils.decorators import admin_required, supervisor_required, safe_redirect_url from app.utils.decorators import admin_required, supervisor_required, safe_redirect_url
import logging import logging
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_LOGIN, ACTION_LOGOUT from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_LOGIN, ACTION_LOGOUT
from app.tenancy.gates import quota_soft_check
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -144,6 +145,7 @@ def list_users():
@bp.route('/users/new', methods=['GET', 'POST']) @bp.route('/users/new', methods=['GET', 'POST'])
@login_required @login_required
@admin_required @admin_required
@quota_soft_check('users')
def create_user(): def create_user():
form = UserForm() form = UserForm()
+5
View File
@@ -8,6 +8,8 @@ from app.utils.forms import FacilityForm, AreaForm
from app.utils.decorators import supervisor_required, admin_required from app.utils.decorators import supervisor_required, admin_required
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE
from app.utils.scope import get_customer_scope, get_inspector_scope from app.utils.scope import get_customer_scope, get_inspector_scope
from app.tenancy.gates import quota_soft_check
from app.tenancy.gates import feature_required
bp = Blueprint('facilities', __name__, url_prefix='/facilities') bp = Blueprint('facilities', __name__, url_prefix='/facilities')
@@ -15,6 +17,8 @@ logger = logging.getLogger(__name__)
@bp.route('/') @bp.route('/')
@login_required @login_required
@supervisor_required
@feature_required('scheduled_reports')
def list_facilities(): def list_facilities():
if current_user.role == 'customer': if current_user.role == 'customer':
cids = get_customer_scope(current_user) or [] cids = get_customer_scope(current_user) or []
@@ -54,6 +58,7 @@ def list_facilities():
@bp.route('/new', methods=['GET', 'POST']) @bp.route('/new', methods=['GET', 'POST'])
@login_required @login_required
@supervisor_required @supervisor_required
@quota_soft_check('facilities')
def create_facility(): def create_facility():
form = FacilityForm() form = FacilityForm()
projects = Project.query.filter_by(active=True).order_by(Project.name).all() projects = Project.query.filter_by(active=True).order_by(Project.name).all()
+2
View File
@@ -23,6 +23,7 @@ from app.models.notification import (
EVENT_CUSTOMER_INSPECTION_DONE, EVENT_CUSTOMER_ISSUE_UPDATED, EVENT_CUSTOMER_INSPECTION_DONE, EVENT_CUSTOMER_ISSUE_UPDATED,
) )
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT
from app.tenancy.gates import quota_soft_check
from app.utils.scope import get_customer_scope, get_inspector_scope from app.utils.scope import get_customer_scope, get_inspector_scope
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
@@ -345,6 +346,7 @@ def index():
@bp.route('/start', methods=['GET', 'POST']) @bp.route('/start', methods=['GET', 'POST'])
@login_required @login_required
@quota_soft_check('inspections')
def start(): def start():
form = StartInspectionForm() form = StartInspectionForm()
+2
View File
@@ -18,6 +18,7 @@ from app.utils.forms import IssueForm, IssueUpdateForm
from app.utils.decorators import supervisor_required from app.utils.decorators import supervisor_required
from app.utils.notifications import notify, notify_customers_for_facility, notify_by_matrix from app.utils.notifications import notify, notify_customers_for_facility, notify_by_matrix
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT
from app.tenancy.gates import quota_soft_check
from app.utils.pdf_export import generate_issues_list_pdf from app.utils.pdf_export import generate_issues_list_pdf
from app.utils.scope import get_customer_scope, get_inspector_scope from app.utils.scope import get_customer_scope, get_inspector_scope
from app.utils.sla import sla_status from app.utils.sla import sla_status
@@ -665,6 +666,7 @@ def unfollow(issue_id):
@bp.route('/new', methods=['GET', 'POST']) @bp.route('/new', methods=['GET', 'POST'])
@login_required @login_required
@quota_soft_check('issues')
def create(): def create():
if current_user.role not in ('admin', 'director', 'customer'): if current_user.role not in ('admin', 'director', 'customer'):
abort(403) abort(403)
+4
View File
@@ -42,6 +42,8 @@ from app.utils.decorators import supervisor_required, admin_required
from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE from app.utils.audit import log_action, ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE
from app.utils.time_utils import now_eastern from app.utils.time_utils import now_eastern
from app.utils.sla import sla_status from app.utils.sla import sla_status
from app.tenancy.gates import feature_required
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -297,6 +299,7 @@ def _send_report(report: ScheduledReport):
@bp.route('/') @bp.route('/')
@login_required @login_required
@admin_required @admin_required
@feature_required('scheduled_reports')
def index(): def index():
reports = ScheduledReport.query.order_by(ScheduledReport.name).all() reports = ScheduledReport.query.order_by(ScheduledReport.name).all()
return render_template('scheduled_reports/index.html', reports=reports) return render_template('scheduled_reports/index.html', reports=reports)
@@ -305,6 +308,7 @@ def index():
@bp.route('/new', methods=['GET', 'POST']) @bp.route('/new', methods=['GET', 'POST'])
@login_required @login_required
@admin_required @admin_required
@feature_required('scheduled_reports')
def create(): def create():
facilities = Facility.query.filter_by(active=True).order_by(Facility.name).all() facilities = Facility.query.filter_by(active=True).order_by(Facility.name).all()