{% extends "sentry/group/details.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block title %}{{ group.error }} | {{ block.super }}{% endblock %}

{% block inner %}
    <ul class="messages" id="message_list">
        <li class="row1 active level-{{ message.level }}" data-sentry-count="{{ message.times_seen }}">
            <h3>
                {{ message.message_top|truncatechars:100 }}
                {% if message.url %}
                     on {{ message.url }}
                {% endif %}
            </h3>
            <span class="status status-{{ message.status }}">{{ message.get_status_display }}</span>
            <p class="message">
                {% if message.message_id %}
                    <span class="tag tag-id">{{ message.message_id }}</span>
                {% endif %}
                <span class="tag tag-level">{{ message.get_level_display }}</span>
                <span class="tag tag-server">{{ message.server_name }}</span>
                {% with message.get_version as version %}
                    {% if version %}
                        <span class="tag tag-version">{{ version.0 }} {{ version.1 }}</span> 
                    {% endif %}
                {% endwith %}
                <span class="last_seen" title="{{ message.datetime }}">{{ message.datetime|timesince }}</span>
            </p>
        </li>
    </ul>

    {% if message.has_two_part_message %}
        <h2>{% trans "Full Message" %}</h2>
        <pre id="full-message">{{ message.message }}</pre>
    {% endif %}

    {% if exeption_type %}
        <div id="summary">
          <h3>{{ exception_type }}: {{ exception_value|escape }}</h3>
          <table class="meta">
            <tr>
              <th>Exception Value:</th>
              <td><pre>{{ exception_value|escape }}</pre></td>
            </tr>
            {% if lastframe %}
            <tr>
              <th>Exception Location:</th>
              <td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
            </tr>
            {% endif %}
          </table>
        </div>
    {% endif %}
    
    {% if template_info %}
        <div id="template">
            <h2>Template error</h2>
            <p>In template <code>{{ template_info.name }}</code>, error at line <strong>{{ template_info.line }}</strong></p>
            <h3>{{ template_info.message }}</h3>
            <ol>
            {% for source_line in template_info.source_lines %}
                <li class="{% if source_line.0 == template_info.line %} selected{% endif %}" value="{{ source_line.0 }}">
                {% if source_line.0 == template_info.line %}
                    <pre>{{ template_info.before }}<span class="specific">{{ template_info.during }}</span>{{ template_info.after }}</pre>
                {% else %}
                    <pre>{{ source_line.1 }}</pre>
                {% endif %}
            {% endfor %}
            </table>
        </div>
    {% endif %}
    
    {% if frames %}
        <div id="traceback">
          <h2>Traceback</h2>
          {% autoescape off %}
          <div id="browserTraceback">
            <ul class="traceback">
              {% for frame in frames %}
                <li class="frame">
                  <code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code>

                  {% if frame.context_line %}
                    <div class="context" id="c{{ frame.id }}">
                      {% if frame.pre_context %}
                        <ol start="{{ frame.pre_context_lineno }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
                      {% endif %}
                      <ol start="{{ frame.lineno }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol>
                      {% if frame.post_context %}
                        <ol start='{{ frame.lineno|plus:1 }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
                      {% endif %}
                    </div>
                  {% endif %}

                  {% if frame.vars %}
                    <div class="commands">
                        <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a>
                    </div>
                    <table class="vars" id="v{{ frame.id }}">
                      <thead>
                        <tr>
                          <th>Variable</th>
                          <th>Value</th>
                        </tr>
                      </thead>
                      <tbody>
                      {% for var in frame.vars|dictsort:"0" %}
                        <tr>
                          <td>{{ var.0|escape }}</td>
                          <td class="code"><pre>{{ var.1|pprint|escape }}</pre></td>
                        </tr>
                      {% endfor %}
                      </tbody>
                    </table>
                  {% endif %}
                </li>
              {% endfor %}
            </ul>
          </div>
          {% endautoescape %}
        </div>
    {% else %}
        {% if group.traceback %}
            <pre>{{ group.traceback }}</pre>
        {% endif %}
    {% endif %}
    
    <div id="requestinfo">
        <h2>{% trans "Additional Data" %}</h2>
        <table>
            {% for k, v in json_data %}
                <tr>
                    <th class="key">{{ k }}</th>
                    <td class="values">
                    {% if v %}
                        {% if v|is_dict %}
                            <table class="vars">
                                <thead>
                                    <tr>
                                        <th>{% trans "Variable" %}</th>
                                        <th>{% trans "Value" %}</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for k_, v_ in v.iteritems|as_sorted %}
                                    <tr>
                                        <td>{{ k_ }}</td>
                                        <td class="code"><pre>{{ v_|pprint }}</pre></td>
                                    </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        {% else %}
                            <pre>{{ v|pprint }}</pre>
                        {% endif %}
                    {% else %}
                        <p>{% blocktrans with k as varname %}No data for {{ varname }}{% endblocktrans %}</p>
                    {% endif %}
                    </td>
                </tr>
            {% endfor %}
        </table>
    </div>
{% endblock %}