diff --git a/app/routes/inspections.py b/app/routes/inspections.py index 444670c..399526d 100644 --- a/app/routes/inspections.py +++ b/app/routes/inspections.py @@ -477,26 +477,7 @@ def view(inspection_id): parent_form_data = parsed_p.get('_form_data', {}) except (json.JSONDecodeError, TypeError): pass - ''' - # ── DEBUG: log raw schema + form_data so we can see what's actually stored ── - current_app.logger.warning( - 'COMPARISON DEBUG | inspection_id=%s | current_form_data=%s', - inspection_id, json.dumps(form_data) - ) - current_app.logger.warning( - 'COMPARISON DEBUG | parent_id=%s | parent_form_data=%s', - parent.id, json.dumps(parent_form_data) - ) - current_app.logger.warning( - 'COMPARISON DEBUG | form_fields=%s', - json.dumps([ - {'id': f.get('id'), 'type': f.get('type'), 'row': f.get('row'), - 'col': f.get('col'), 'label': f.get('label'), 'text_content': f.get('text_content')} - for f in form_fields - ]) - ) - # ── END DEBUG ── - ''' + scoreable_types = ('rating', 'checkbox', 'radio') # Collect all text/textarea fields per row, keyed by (col, fid) diff --git a/app/routes/issues.py b/app/routes/issues.py index 89be400..83a6b0d 100644 --- a/app/routes/issues.py +++ b/app/routes/issues.py @@ -117,14 +117,6 @@ def view(issue_id): form.assigned_to.choices = [(0, '— Unassigned —')] + [(u.id, u.username) for u in staff] form.status.data = form.status.data or issue.status - # Extend status choices to include pending_verification - form.status.choices = [ - ('open', 'Open'), - ('in_progress', 'In Progress'), - ('pending_verification', 'Pending Verification'), - ('resolved', 'Resolved'), - ] - if form.validate_on_submit(): old_status = issue.status old_assigned_to = issue.assigned_to @@ -424,6 +416,8 @@ def create(): flash('Issue created.', 'success') return redirect(url_for('issues.index')) + return render_template('issues/form.html', form=form, title='Log New Issue') + # ── Supervisor verify resolved issue ───────────────────────────────────────── @@ -554,7 +548,4 @@ def verification_queue(): total_pending = len(pending), sla_status = sla_status, sla_hours_remaining = sla_hours_remaining, - ) - - - return render_template('issues/form.html', form=form, title='Log New Issue') \ No newline at end of file + ) \ No newline at end of file diff --git a/app/routes/scheduled_reports.py b/app/routes/scheduled_reports.py index bbfc989..6a9ad4c 100644 --- a/app/routes/scheduled_reports.py +++ b/app/routes/scheduled_reports.py @@ -110,7 +110,8 @@ def _build_report_data(report: ScheduledReport, start: datetime, end: datetime) Inspection.status == 'completed', Inspection.overall_score.isnot(None), ) - data['avg_score'] = round(float(_si(avg).scalar()), 2) if _si(avg).scalar() else None + avg_val = _si(avg).scalar() + data['avg_score'] = round(float(avg_val), 2) if avg_val else None data['open_issues'] = _iq(Issue.query.filter( Issue.status.in_(['open', 'in_progress']) @@ -392,4 +393,4 @@ def send(): logger.info('SCHEDULED REPORTS CRON | frequency=%s | due=%s | sent=%s | failed=%s', frequency, len(due), sent, failed) - return jsonify({'ok': True, 'frequency': frequency, 'sent': sent, 'failed': failed}) + return jsonify({'ok': True, 'frequency': frequency, 'sent': sent, 'failed': failed}) \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index 32f1217..ead2b0a 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -84,11 +84,6 @@ Scheduled Reports {% endif %} - {% if current_user.role in ['admin','supervisor'] %} - - {% endif %} diff --git a/app/utils/forms.py b/app/utils/forms.py index 7432260..2ccade3 100644 --- a/app/utils/forms.py +++ b/app/utils/forms.py @@ -167,7 +167,8 @@ class IssueForm(FlaskForm): class IssueUpdateForm(FlaskForm): status = SelectField('Status', choices=[ - ('open','Open'), ('in_progress','In Progress'), ('resolved','Resolved'), + ('open','Open'), ('in_progress','In Progress'), + ('pending_verification','Pending Verification'), ('resolved','Resolved'), ], validators=[DataRequired()]) assigned_to = SelectField('Assign To', coerce=int, validators=[Optional()]) update_notes = TextAreaField('Update Notes', validators=[Optional(), Length(max=1000)]) @@ -222,4 +223,4 @@ class CustomerUserForm(FlaskForm): def validate_password(self, field): """Password is required when creating a new account.""" if self._user is None and not field.data: - raise ValidationError('Password is required for new accounts.') + raise ValidationError('Password is required for new accounts.') \ No newline at end of file diff --git a/config.py b/config.py index 38a015b..8cb36a4 100644 --- a/config.py +++ b/config.py @@ -33,7 +33,7 @@ class Config: # ── File uploads ──────────────────────────────────────────────────────── UPLOAD_FOLDER = os.path.join(basedir, 'app/static/uploads') - MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 16 MB + MAX_CONTENT_LENGTH = 50 * 1024 * 1024 # 50 MB ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} # ── Session / cookies ─────────────────────────────────────────────────── diff --git a/requirements.txt b/requirements.txt index c6ee46b..884c4da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,5 @@ Pillow WTForms email-validator gunicorn -pytz +reportlab +pytz \ No newline at end of file