File size: 2,771 Bytes
0a40ab8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{% extends "base.html" %}

{% block title %}Impact Analyses - PoliSage{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h2>Impact Analyses</h2>
        <a href="{{ url_for("analysis.run_analysis") }}" class="btn btn-primary">
            <i class="bi bi-play-circle me-1"></i> Run New Analysis
        </a>
    </div>

    {% with messages = get_flashed_messages(with_categories=true) %}
      {% if messages %}
        {% for category, message in messages %}
          <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
            {{ message }}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
        {% endfor %}
      {% endif %}
    {% endwith %}

    {% if analyses %}
        <div class="list-group">
            {% for analysis in analyses %}
                {% set doc_title = "Unknown Document" %}
                {% if analysis.document_type == "Legislation" and analysis.legislation %}
                    {% set doc_title = analysis.legislation.title %}
                {% elif analysis.document_type == "Draft" and analysis.draft %}
                    {% set doc_title = analysis.draft.title %}
                {% elif analysis.document_type == "Amendment" and analysis.amendment %}
                    {% set doc_title = "Amendment #" ~ analysis.amendment.id ~ (" for " ~ analysis.amendment.legislation.title if analysis.amendment.legislation else "") %}
                {% endif %}
                <a href="{{ url_for("analysis.view_analysis", analysis_id=analysis.id) }}" class="list-group-item list-group-item-action flex-column align-items-start">
                    <div class="d-flex w-100 justify-content-between">
                        <h5 class="mb-1">{{ analysis.analysis_type }} Analysis for: {{ doc_title | truncate(80) }}</h5>
                        <small>{{ analysis.generated_at.strftime("%Y-%m-%d %H:%M") }}</small>
                    </div>
                    <p class="mb-1">Document: {{ analysis.document_type }} ID {{ analysis.document_id }} | Confidence: {{ "%.1f"|format(analysis.confidence_score * 100) ~ "%" if analysis.confidence_score is not none else "N/A" }}</p>
                    <small>Generated by: {{ analysis.generator.username if analysis.generator else "System" }}</small>
                </a>
            {% endfor %}
        </div>
        <!-- Add pagination later if needed -->
    {% else %}
        <div class="alert alert-info" role="alert">
            No impact analyses found. <a href="{{ url_for("analysis.run_analysis") }}">Run a new one?</a>
        </div>
    {% endif %}
</div>
{% endblock %}