<%inherit file="master.html"/>
<%namespace name="captcha" module="bodhi.server.captcha"/>
<%namespace name="json" module="json"/>

<link rel="alternate" type="application/atom+xml" title="New Comments on ${update.alias}" href="${request.route_url('comments_rss')}?updates=${update.alias}"/>

<script type="text/javascript">
  $(document).ready(function() {
    var base_url = '${request.registry.settings["resultsdb_api_url"]}' + '/api/v1.0/';

    // Some handy lookups that map taskotron states to bootstrap CSS classes.
    var classes = {
      PASSED: 'success',
      INFO: 'info',
      FAILED: 'danger',
      NEEDS_INSPECTION: 'warning',
      ABORTED: 'warning',
      CRASHED: 'warning',
      ABSENT: 'warning',
    }
    var icons = {
      PASSED: 'check-circle',
      INFO: 'info-circle',
      FAILED: 'minus-circle',
      NEEDS_INSPECTION: 'exclamation-circle',
      ABORTED: 'trash',
      CRASHED: 'fire', // no joke.
      ABSENT: 'question-circle',
    }

    // XXX - For development, we typically have updates in our development
    // bodhi DB from a snapshot from over a year ago -- before the deployment
    // of taskotron.  As such, taskotron doesn't know about the updates that
    // we ask about.  Therefore, it is useful sometimes to mess around here
    // and hardcode something like this:
    //var update = 'ugene-1.14.2-1.fc21';
    var update = '${update.title}';
    var builds = ${update.builds_json | n};

    // These are the required taskotron tests
    var requirements = ${update.requirements_json | n};

    var make_row = function(outcome, testcase, item, arch, time, url) {
      var icon = '<span data-toggle="tooltip" data-placement="top" ' +
        'title="' + outcome + '" ' +
        'class="fa fa-' + icons[outcome] + ' text-' + classes[outcome] + '">' +
        '</span>';

      var required = '';
      if ($.inArray(testcase, requirements) != -1) {
        required = '<span data-toggle="tooltip" data-placement="top" ' +
          'title="' + testcase + ' is a required test" ' +
          'class="fa fa-asterisk">' +
          '</span>';
      }

      if (arch != undefined) {
        item = item + "<small>(" + arch + ")</small>";
      }

      var age = '';
      if (time != undefined) {
        // The ' Z' tells moment.js to interpret the time as UTC
        // https://github.com/fedora-infra/bodhi/issues/217
        var age = moment(time + ' Z').fromNow();
      }

      return '<tr class="table-' + classes[outcome] + '" ' +
        'style="cursor: pointer;"' +
        'data-href="' + url + '">' +
        '<td>' + required + '</td>' +
        '<td>' + icon + '</td>' +
        '<td>' + testcase + '</td>' +
        '<td>' + item + '</td>' +
        '<td>' + age + '</td>' +
        '</tr>';
    };

    var latest = {};
    var receive_resultsdb = function(data) {

      // First, prune duplicate results.  For instance, some depcheck runs
      // happen multiple times on an update.  We only (imho) want to display
      // the latest ones for each arch.  So, prune like this:
      var changed = false;
      $.each(data.data, function(i, result) {

        // However, we want to skip over any ABORTED results:
        // https://github.com/fedora-infra/bodhi/issues/167
        if (result.outcome == 'ABORTED') return;

        var name = result.testcase.name;
        var arch = result.result_data.arch;
        var item = result.result_data.item;
        var submit_time = new Date(result.submit_time);
        if (latest[name] === undefined)
          latest[name] = {};
        if (latest[name][arch] === undefined)
          latest[name][arch] = {};
        if (latest[name][arch][item] === undefined) {
          latest[name][arch][item] = result;
          changed = true;
        }
        if (new Date(latest[name][arch][item].submit_time) < submit_time) {
          latest[name][arch][item] = result;
          changed = true;
        }
      });

      // If this was the last page of data, then bail out.
      if (data.data.length == 0) {
        // Kill the thing showing that we're still loading data, since we're
        // done-done now.
        $('#resultsdb .spinner').remove();

        // Furthermore, if no rows got written.. then we have no results at
        // all!  So, hang an 'out to lunch' sign on the door.
        if ($('#resultsdb tr:not(.warning)').length == 0) {
          var testcase = data.href.match(/testcases\/(.*)\/results/)[1];
          if ($.inArray(testcase, requirements) != -1) {
            $('#resultsdb table').append(make_row(
                  'ABSENT',
                  testcase,
                  'No result found',
                  undefined,
                  undefined,
                  data.href
            ));
          }
        }

        finish();

        return;
      }

      // Otherwise, go ahead an request the next page async while we render.
      // If nothing changed as of the last page, then go ahead and bail.  Wait
      // for the next page.
      if (! changed) {
        request_resultsdb_page(data.next);
        return;
      }

      // Remove all our old rows.  Something changed, so we're going to write new ones.
      $('#resultsdb tr').remove();

      // So, let's complete pruning.  Collapse that nested structure back to a list.
      var data = [];
      $.each(latest, function(name, obj1) {
        $.each(obj1, function(arch, obj2) {
          $.each(obj2, function(item, result) {
            data.push(result);
          });
        });
      });

      // Then, once we have pruned, build a bunch of cells and render each
      // result in the table
      $.each(data, function(i, result) {
        // When there are many builds in an update, the large number of taskotron results can be a
        // problem for browsers. Only show the non-passing results in this case.
        // See https://github.com/fedora-infra/bodhi/issues/951
        if (builds.length < 16 || result.outcome != "PASSED") {
            $('#resultsdb table').append(make_row(
                result.outcome,
                result.testcase.name,
                result.result_data.item,
                result.result_data.arch,
                result.submit_time,
                result.log_url
            ));
        }
      });

      finish();
    };

    var finish = function() {
      // Furthermore, remove the spinner if its still around.
      $('#resultsdb .spinner').remove();

      // Make each cell clickable and awesome
      $('#resultsdb tr').off().click(function(event, row) {
        window.open($(this).attr('data-href'));
      });

      // And, re-do tooltips for newly created spans.
      $('#resultsdb span').tooltip();
    }

    var request_resultsdb_page = function(url) {
      $.ajax(url, {
        dataType: 'jsonp',
        cache: false,
        success: receive_resultsdb,
        error: function(v1, v2, v3) {
          $('#resultsdb .spinner').remove();
          $('#resultsdb').append(
            '<h4 class="text-danger">Error getting results.</h4>');
        },
      });
    };

    var receive_testcases = function(data) {
      if (data.data.length == 0) { return; }
      // Queue up the next page of possible testcases
      gather_testcases(data.next);
      // And queue up requests for the results of the testcases we already know about.
      $.each(data.data, function(i, testcase) {
        $.each(builds, function(j, nvr) {
          var param = $.param({
              type: 'koji_build',
              item: nvr,
          });
          var url = base_url + 'testcases/' + testcase.name + '/results?' + param;
          request_resultsdb_page(url);
        });
      });
    }

    var gather_testcases = function(url) {
      $.ajax(url, {
        dataType: 'jsonp',
        cache: false,
        success: receive_testcases,
        error: function(v1, v2, v3) {
          $('#resultsdb .spinner').remove();
          $('#resultsdb').append(
            '<h4 class="text-danger">Error getting testcases.</h4>');
        },
      });

    }

    if (builds.length > 16) {
	$("<h4>Large update detected: passing test results filtered.</h4>").insertBefore('#resultsdb table');
    }
    // Kick off a few chains of paginated queries.  One for each of the
    // possible testcases.
    gather_testcases(base_url + 'testcases');

  });
</script>

<script type="text/javascript">
$(document).ready(function() {
    var messenger = Messenger({theme: 'flat'});
    var update_id = '${update.title}';
    $("#updatebuttons #edit").attr('href',
        '${request.route_url("update_edit", id=update.title)}');

    $.each(['testing', 'stable', 'unpush', 'revoke'], function(i, action) {
      $("#updatebuttons #" + action).click(function() {
          $("#updatebuttons a").addClass('disabled');
          cabbage.spin(); // for real!
          var url = '${request.route_url("update_request", id=update.title)}';
          $.ajax({
              url: url,
              data: {
                request: action,
                csrf_token: "${request.session.get_csrf_token()}",
              },
              method: 'POST',
              dataType: 'json',
              success: function(response) {
                $("#updatebuttons a").removeClass('disabled');
                cabbage.finish();
                // Just reload the page if all went well..
                location.reload();
              },
              error: function(response) {
                $("#updatebuttons a").removeClass('disabled');
                cabbage.finish();
                $.each(response.responseJSON.errors, function(i, error) {
                    msg = messenger.post({
                      message: error.description,
                      type: "error",
                      hideAfter: false,
                      showCloseButton: true,
                    });
                });
              },
          });
      });
    });

});
</script>

<script type="text/javascript">
var form;
$(document).ready(function(){
  CommentsForm = function() {};
  CommentsForm.prototype = new Form("#new_comment", "${request.route_url('comments')}");
  CommentsForm.prototype.success = function(data) {
    Form.prototype.success.call(this, data);

    $.ajax({
      url: this.url + "../comments/" + data.comment.id,
      dataType: "html",
      success: function(html) {
        console.log(html);
        $("#comments").append(html);
      },
      error: function(html) {
        // TODO -- handle this
        msg = this.messenger.post({
          message: "Unhandled error",
          type: "error",
          hideAfter: false,
          showCloseButton: true,
        });
      }
    });

    // Clear out the form.
    $('#new_comment').find(':input').each(function() {
      switch (this.type) {
      case 'password':
      case 'select-multiple':
      case 'select-one':
      case 'text':
      case 'textarea':
        $(this).val('');
      case 'checkbox':
      case 'radio':
        this.checked = false;
      }
    });

    // And the colors..
    $('#new_comment tr.success').removeClass('success');
    $('#new_comment tr.danger').removeClass('danger');
  };

  form = new CommentsForm();

  $("#preview_button").click(function(){
    update_markdown_preview($("#text").val());
    if ($(this).hasClass("active")) {
      /*preview is visible*/
      $(".comment-preview").hide();
      $("#comment-textarea").show();
    } else {
      $(".comment-preview").show();
      $("#comment-textarea").hide();
    }
     $(this).button('toggle');
  });

});
</script>

<div class="subheader p-t-2">
<div class="container">
<div class="row">
  <div class="col-md-12">
    <h1>
      % if update.locked and update.date_locked:
          <span class="fa fa-lock text-muted" aria-hidden="true" data-toggle="tooltip" title="This update is currently locked since ${(update.date_locked).strftime('%Y-%m-%d %H:%M:%S')} (UTC) and cannot be modified.">
          </span>
          <span class="sr-only">Locked</span>
      % endif
      % if update.alias:
      ${update.alias}
      % else:
      ${update.get_title(', ', 2, ", &hellip;") | n}
      <div>
        <span title="${(', ').join(map(lambda x: x.nvr, update.builds[2:]))}">
          <small>${ "(+ " + str(len(update.builds) - 2) + " more)" if len(update.builds) > 2 else "" }</small>
        </span>
      </div>
      % endif
      % if update.type:
        ${self.util.type2icon(update.type) | n}
      % endif
      % if update.critpath:
      <span class="label label-danger"> <i class="fa fa-fire"></i></span>
      % endif

      % if can_edit:
        % if not update.locked:
          <div id='updatebuttons' class="btn-group pull-right" role="group" aria-label="...">
          % if not update.pushed:
            <a id='edit' class="btn btn-sm btn-primary"><span class="fa fa-pencil"></span> Edit</a>
            % if update.request is None:
              % if update.status.description != 'testing':
              <a id='testing' class="btn btn-sm btn-success"><span class="fa fa-arrow-circle-right"></span> Push to Testing</a>
              % endif
              % if update.status.description not in ['stable', 'obsolete']:
                <a id='stable' class="btn btn-sm btn-success"><span class="fa fa-arrow-circle-right"></span> Push to Stable</a>
              % endif
            % else:
              <a id='revoke' class="btn btn-sm btn-danger"><span class="fa fa-arrow-circle-left"></span> Revoke</a>
            % endif
          % elif update.pushed and (update.status.description != 'stable' or (update.status.description == 'stable' and 'releng' in [group.name for group in request.user.groups])):
            <a id='edit' class="btn btn-sm btn-default"><span class="fa fa-pencil"></span> Edit</a>
            % if update.critpath and getattr(update.request, 'description', None) != 'stable':
              % if update.critpath_approved:
                <a id='stable' class="btn btn-sm btn-success"><span class="fa fa-arrow-circle-right"></span> Push to Stable</a>
              % endif
            % elif update.meets_testing_requirements and getattr(update.request, 'description', None) != 'stable':
              <a id='stable' class="btn btn-sm btn-success"><span class="fa fa-arrow-circle-right"></span> Push to Stable</a>
            % elif update.stable_karma not in (0, None) and update.karma >= update.stable_karma and not update.autokarma and getattr(update.request, 'description', None) != 'stable':
              <a id='stable' class="btn btn-sm btn-success"><span class="fa fa-arrow-circle-right"></span> Push to Stable</a>
            % endif
            <a id='unpush' class="btn btn-sm btn-danger"><span class="fa fa-arrow-circle-left"></span> Unpush</a>
          % endif
          </div>
        % endif
      % endif

    </h1>
    <h3>
      ${update.type} update for
      % for build in update.builds:
        ${self.util.packagename_from_nvr(build.nvr)}
      % endfor
      in ${update.release.long_name}
    </h3>
    <div>
      Status: ${self.util.status2html(update.status) | n}
      % if 'pending' in update.status:
         <span class="text-muted" data-toggle="tooltip" title="${(update.date_submitted).strftime('%Y-%m-%d %H:%M:%S')} (UTC)"> ${self.util.age(update.date_submitted)} </span>
      % elif 'testing' in update.status and update.date_testing:
         <span class="text-muted" data-toggle="tooltip" title="${(update.date_testing).strftime('%Y-%m-%d %H:%M:%S')} (UTC)"> ${self.util.age(update.date_testing)} </span>
      % elif 'stable' in update.status:
        <span class="text-muted" data-toggle="tooltip" title="${(update.date_stable).strftime('%Y-%m-%d %H:%M:%S')} (UTC)"> ${self.util.age(update.date_stable)} </span>
      % endif
    </div>
  </div>
</div>
<ul class="nav nav-tabs p-t-2" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" data-toggle="tab" href="#details" role="tab">Details</a>
  </li>

  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#packages" role="tab">Builds <span class="label label-default">${len(update.builds)}</span></a>
  </li>

  % if update.bugs:
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#bugs" role="tab">Bugs <span class="label label-default">${len(update.bugs)}</span></a>
  </li>
  % endif

  % if update.test_cases:
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#tests" role="tab">Test Cases <span class="label label-default">${len(update.test_cases)}</span></a>
  </li>
  % endif

  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#automatedtests" role="tab">Automated Tests</a>
  </li>

</ul>
</div>
</div>
<div class="container p-t-2">
  <!-- Tab panes -->
  <div class="tab-content">
    <div class="tab-pane active" id="details" role="tabpanel">
      <div class="row">
        <div class="col-md-9">
          % if update.notes:
          ${self.util.markup(update.notes) | n}
          % endif
          % if not 'unspecified' in update.suggest:
          <div class="alert alert-info">
            % if 'logout' in update.suggest:
            <h4>Logout Required</h4>
            After installing this update it is required that you logout of
            your current user session and log back in to ensure the changes
            supplied by this update are applied properly.
            % elif 'reboot' in update.suggest:
            <h4>Reboot Required</h4>
            After installing this update it is required that you reboot your
            system to ensure the changes supplied by this update are applied
            properly.
            % endif
          </div>
          % endif

          <div class="p-t-3">
            <h4>Comments <span class="label label-default">${len(update.comments)}</span>
              <small><a href="${request.route_url('comments_rss')}?updates=${update.alias}">
                  <span class="fa fa-rss"></span>
              </a></small>
            </h4>
            <div id="comments">
              % for comment in update.comments:
              <div id="comment-${comment.id}">
                ${self.fragments.comment(comment, display_update=False)}
              </div>
              % endfor
            </div>

            <form id="new_comment" class="form-horizontal" role="form"
              action="javascript:form.submit();">

              <div class="alert alert-danger col-sm-4 col-sm-offset-1" style="display:none">
                <strong></strong><span class="error"></span>
              </div>

              <div class="clearfix"></div>

              <input type="hidden" name="csrf_token" value="${request.session.get_csrf_token()}"/>
              <input type="hidden" name="update" value="${update.title}"/>

              <hr/>

              <div class="row">
                <div class="col-md-12">

                  <h5 class="m-t-2">
                    <strong>Add Comment &amp; Feedback</strong>
                    <div id="preview_button" class="btn btn-sm btn-secondary pull-xs-right">Toggle Preview</div>
                  </h5>

                    <div class="form-group" id="comment-textarea" class="m-t-2">
                        <textarea class="form-control" id="text" name="text" rows="6"
                          placeholder="Comment..."></textarea>
                        <div class="alert alert-danger" for="text" style="display:none">
                          <strong></strong> <span class="error"></span>
                        </div>
                      <p class="pull-right"><small>Comment fields support <a href="#" data-toggle="modal" data-target="#markdown-help">Fedora-Flavored Markdown</a>.</small></p>
                    </div>

                    % if not request.user:
                    <div class="form-group" class="m-t-3">
                        <input class="form-control" id="email" name="email" type="email"
                        placeholder="email@address.org" required="true"></input>
                        <div class="alert alert-danger" for="email" style="display:none">
                          <strong></strong> <span class="error"></span>
                        </div>
                    </div>
                    % endif

                    ${self.fragments.markdown_help_modal()}

                    <div id="preview" class="comment-preview m-t-2" style="display:none;"></div>

                </div>
                <div class="col-md-12">
                    <table class="table m-t-2">
                      <colgroup class='strip' span="1"></colgroup>
                      <colgroup class='strip' span="1"></colgroup>
                      <colgroup class='strip' span="1"></colgroup>
                      <colgroup span="1"></colgroup>
                      <thead>
                        <tr>
                          <th class='icon'><span data-toggle="tooltip" data-placement="top" class="label label-danger" title="FAIL - Does not fix the bug or pass the test case.">-1</span></th>
                          <th class='icon'><span data-toggle="tooltip" data-placement="top" title="Untested." class="label label-default">0</span></th>
                          <th class='icon'><span data-toggle="tooltip" data-placement="top" title="PASS - Fixes the bug or passes the test case." class="label label-success">+1</span></th>
                          <th><a href="https://fedoraproject.org/wiki/QA:Update_feedback_guidelines" target="_blank">Feedback Guidelines</a></th>
                        </tr>
                      </thead>

                      % for bug in update.bugs:
                      <tr>
                        <input type="hidden" name="bug_feedback.${loop.index}.bug_id" value="${bug.bug_id}">
                        <td data-class="danger">  <input type="radio" name="bug_feedback.${loop.index}.karma" value="-1"> </td>
                        <td>                      <input type="radio" name="bug_feedback.${loop.index}.karma" value="0" checked> </td>
                        <td data-class="success"> <input type="radio" name="bug_feedback.${loop.index}.karma" value="1"> </td>
                        <td>${self.util.bug_link(bug) | n}</td>
                      </tr>
                      % endfor

                      % for test in update.full_test_cases:
                      <tr>
                        <input type="hidden" name="testcase_feedback.${loop.index}.testcase_name" value="${test.name}">
                        <td data-class="danger">  <input type="radio" name="testcase_feedback.${loop.index}.karma" value="-1"> </td>
                        <td>                      <input type="radio" name="testcase_feedback.${loop.index}.karma" value="0" checked> </td>
                        <td data-class="success"> <input type="radio" name="testcase_feedback.${loop.index}.karma" value="1"> </td>
                        <td>${self.util.testcase_link(test) | n}</td>
                      </tr>
                      % endfor

                      % if update.critpath:
                      <tr>
                        <td data-class="danger">  <input type="radio" name="karma_critpath" value="-1"> </td>
                        <td>                      <input type="radio" name="karma_critpath" value="0" checked> </td>
                        <td data-class="success"> <input type="radio" name="karma_critpath" value="1"> </td>
                        <td>Does the system's basic functionality continue to work after this update?</td>
                      </tr>
                      % endif

                      <tr>
                        <td data-class="danger">  <input type="radio" name="karma" value="-1"> </td>
                        <td>                      <input type="radio" name="karma" value="0" checked> </td>
                        <td data-class="success"> <input type="radio" name="karma" value="1"> </td>
                        <td>Is the update generally functional?</td>
                      </tr>

                    </table>
                </div>
              </div>

              % if not request.user and request.registry.settings.get('captcha.secret', None):
              <%
                captcha_key, captcha_url = captcha.generate_captcha(request)
              %>
              <div class="row">
                <div class="col-sm-12 text-xs-right">
                  <input type="hidden" name="captcha_key" value="${captcha_key}"/>
                  <img class="image m-t-1" src="${captcha_url}"/>
                </div>
              </div>

              <div class="row">
                <div class="col-sm-4 col-sm-offset-8 m-b-1">
                  <input class="form-control" id="captcha_value" name="captcha_value"
                  placeholder="prove that you're a human" required="true"></input>
                </div>
              </div>
              % endif

              <div class="form-group m-t-1">
                <div class="col-sm-12">
                  <button type="submit" class="pull-right btn btn-default">
                    <span class="indicator fa fa-comment" data-spinclass="indicator fa fa-spinner fa-spin"></span>
                    Add Comment &amp; Feedback
                  </button>
                </div>
              </div>
            </form>

          </div>
        </div>
        <div class="col-md-3">
          <div class="card">
            <div class="card-block">

              <div class="p-b-1">
                <div>
                  <strong>Status</strong>
                </div>
                <div>
                  ${self.util.status2html(update.status) | n}
                </div>
              </div>

              % if update.request:
              <div class="p-b-1">
                <div>
                  <strong>Request</strong>
                </div>
                <div>
                  ${self.util.request2html(update.request) | n}
                  % if not update.signed:
                    <span class="fa fa-cog" data-toggle="tooltip" data-placement="top" title="Update is being signed"></span>
                  % endif
                </div>
              </div>
              % endif


              <div class="p-b-1">
                <div>
                  <strong>Submitted by</strong>
                </div>
                <div>
                  <a href="${request.route_url('user', name=update.user.name)}">
                    <img class="img-circle" src="${self.util.avatar(update.user.name, size=24)}"/>
                    ${update.user.name}
                  </a>
                </div>
              </div>

              % if update.type:
              <div class="p-b-1">
                <div>
                  <strong>Update Type</strong>
                </div>
                <div>
                  ${self.util.type2html(update.type) | n}
                </div>
              </div>
              % endif
              % if not 'unspecified' in update.severity:
              <div class="p-b-1">
                <div>
                  <strong>Update Severity</strong>
                </div>
                <div>
                  <tr>
                    ${self.util.severity2html(update.severity) | n}
                  </tr>
                </div>
              </div>
              % endif

              <div class="p-b-1">
                <div>
                  <strong>Karma</strong>
                </div>
                <div>
                    ${self.util.karma2html(update.karma) | n}
                    % if update.stable_karma:
                    <br/><small>stable threshold: ${update.stable_karma}</small>
                    % endif
                    % if update.unstable_karma:
                    <br/><small>unstable threshold: ${update.unstable_karma}</small>
                    % endif
                  </a>
                </div>
              </div>

              <div  class="p-b-1">
                <div>
                  <strong>Autopush</strong>
                </div>
                <div>
                  % if update.autokarma is True:
                  <td><span class='label label-success'>Enabled</span></td>
                  % elif update.autokarma is False:
                  <td><span class='label label-danger'>Disabled</span></td>
                  % endif
                </div>
              </div>

              <div class="p-b-1">
                <div>
                  <strong>Dates</strong>
                </div>
                <div>
                  <table class="table table-sm">
                    <tr>
                      <td>submitted</td>
                      <td class="text-muted">
                        <span data-toggle='tooltip' title='${(update.date_submitted).strftime("%Y-%m-%d %H:%M:%S")} (UTC)'>${self.util.age(update.date_submitted)}
                      </td>
                    </tr>

                    % if update.date_testing:
                    <tr>
                      <td>in testing</td>
                      <td class="text-muted">
                        <span data-toggle='tooltip' title='${(update.date_testing).strftime("%Y-%m-%d %H:%M:%S")} (UTC)'>${self.util.age(update.date_testing)}</span>
                      </td>
                    </tr>
                    % endif

                    % if update.date_stable:
                    <tr>
                      <td>in stable</td>
                      <td class="text-muted">
                        <span data-toggle='tooltip' title='${(update.date_stable).strftime("%Y-%m-%d %H:%M:%S")} (UTC)'>${self.util.age(update.date_stable)}</span>
                      </td>
                    </tr>
                    % endif

                    % if update.days_to_stable and update.status.description == 'testing':
                    <tr>
                      <td>days to stable</td>
                      <td class="text-muted">
                        <span>${str(update.days_to_stable)}</span>
                      </td>
                    </tr>
                    % endif

                    % if update.date_modified:
                    <tr>
                      <td>modified</td>
                      <td class="text-muted">
                        <span data-toggle='tooltip' title='${(update.date_modified).strftime("%Y-%m-%d %H:%M:%S")} (UTC)'>${self.util.age(update.date_modified)}</span>
                      </td>
                    </tr>
                    % endif

                    % if update.date_approved:
                    <tr>
                      <td>approved</td>
                      <td class="text-muted">
                        <span data-toggle='tooltip' title='${(update.date_approved).strftime("%Y-%m-%d %H:%M:%S")} (UTC)'>${self.util.age(update.date_approved)}</span>
                      </td>
                    </tr>
                    % endif
                  </table>
                </div>
              </div>



            </div>
          </div>
        </div>
      </div>
    </div>

    % if update.bugs:
    <div class="tab-pane" id="bugs" role="tabpanel">
      <h3>Related Bugs <span class="badge">${len(update.bugs)}</span></h3>
      <table class="table">
        <colgroup class='strip' span="1"></colgroup>
        <colgroup class='strip' span="1"></colgroup>
        <colgroup span="1"></colgroup>
        <thead>
          <tr>
            <th class='icon'><span data-toggle="tooltip" data-placement="top" title="FAIL - Does not fix the bug." class="fa fa-times-circle-o"></span></th>
            <th class='icon'><span data-toggle="tooltip" data-placement="top" title="PASS - Passes the test case." class="fa fa-check-circle-o"></span></th>
            <th></th>
          </tr>
        </thead>
        % for bug in update.bugs:
        <tr>
          <td>${self.util.karma2html(update.get_bug_karma(bug)) | n}</td>
          <td>${self.util.bug_link(bug) | n}</td>
        </tr>
        % endfor
      </table>
    </div>
    % endif

    <div class="tab-pane" id="packages" role="tabpanel">
      <table class="table">
        % for build in update.builds:
        <tr class="media">
          <td><a href="https://koji.fedoraproject.org/koji/search?terms=${build.nvr}&type=build&match=glob" target="_blank">${build.nvr}</a></td>
          <td class="pull-right">
            % if build.signed:
              <span class="fa fa-lock" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Build signed"></span>
            % else:
              <span class="fa fa-cog" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Build is being signed"></span>
            % endif
            <a href='${request.route_url("updates_rss") + "?packages=" + build.package.name}'>
              <span class="fa fa-rss" data-toggle="tooltip" data-placement="top" title="RSS feed for new Bodhi updates containing ${build.package.name}"></span>
            </a>
            <a href='${request.route_url("updates") + "?packages=" + build.package.name}'>
              <span class="fa fa-list" data-toggle="tooltip" data-placement="top" title="Show other Bodhi updates for ${build.package.name}"></span>
            </a>
            % if can_edit:
            % if build.override:
            <a href="${request.route_url('override', nvr=build.nvr)}">
              <span class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="Edit the buildroot override for ${build.nvr}"/>
            </a>
            % else:
            <a href='${request.route_url("new_override")}?nvr=${build.nvr}'>
              <span class="fa fa-plus" data-toggle="tooltip" data-placement="top" title="Create a buildroot override for ${build.nvr}"/>
            </a>
            % endif
            % endif
          </td>
        </tr>
        % endfor
      </table>
    </div>

    <div class="tab-pane" id="automatedtests" role="tabpanel">
      <div id="resultsdb">
      <h3>Automated Test Results</h3>
      <img class='spinner' src='static/img/spinner.gif'>
      <table class="table">
        <colgroup class='strip' span="1"></colgroup>
        <colgroup span="1"></colgroup>
        <colgroup span="1"></colgroup>
      </table>
      </div>
    </div>

    % if update.test_cases:
    <div class="tab-pane" id="tests" role="tabpanel">
    <h3>Test Cases</h3>
    <table class="table">
      <colgroup class='strip' span="1"></colgroup>
      <colgroup class='strip' span="1"></colgroup>
      <colgroup span="1"></colgroup>
      <thead>
        <tr>
          <th><span data-toggle="tooltip" data-placement="top" title="FAIL - Does not fix the bug or pass the test case." class="fa fa-times-circle-o"></span></th>
          <th><span data-toggle="tooltip" data-placement="top" title="PASS - Fixes the bug or passes the test case." class="fa fa-check-circle-o"></span></th>
          <th></th>
        </tr>
      </thead>
      % for test in update.full_test_cases:
      <tr>
        <td>${self.util.karma2html(update.get_testcase_karma(test)) | n}</td>
        <td>${self.util.testcase_link(test) | n}</td>
      </tr>
      % endfor
    </table>
  </div>
    % endif

  </div>


<div class="row">

</div>
</div> <!-- end container -->
