cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Manager WUI - VCS history
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__copyright__ = \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2012-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__version__ = "$Revision$"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#import datetime;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager import config;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.core import db;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testmanager.webui.wuicontentbase import WuiContentBase;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom common import webutils;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass WuiVcsHistoryTooltip(WuiContentBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WUI VCS history tooltip generator.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, aoEntries, sRepository, iRevision, cEntries, fnDPrint, oDisp):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """Override initialization"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync WuiContentBase.__init__(self, fnDPrint = fnDPrint, oDisp = oDisp);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoEntries = aoEntries;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sRepository = sRepository;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.iRevision = iRevision;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.cEntries = cEntries;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def show(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Generates the tooltip.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns (sTitle, HTML).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml = '<div class="tmvcstimeline tmvcstimelinetooltip">\n';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oCurDate = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oEntry in self.aoEntries:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTsZulu = db.dbTimestampToZuluDatetime(oEntry.tsCreated);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oCurDate is None or oCurDate != oTsZulu.date():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oCurDate is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml += ' </dl>\n'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oCurDate = oTsZulu.date();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml += ' <h2>%s:</h2>\n' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ' <dl>\n' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (oTsZulu.strftime('%Y-%m-%d'),);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry = ' <dt id="r%s">' % (oEntry.iRevision, );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += '<a href="%s">' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % ( webutils.escapeAttr(config.g_ksTracChangsetUrlFmt
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % { 'iRevision': oEntry.iRevision, 'sRepository': oEntry.sRepository,}), );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += '<span class="tmvcstimeline-time">%s</span>' % ( oTsZulu.strftime('%H:%MZ'), );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += ' Changeset <span class="tmvcstimeline-rev">[%s]</span>' % ( oEntry.iRevision, );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += ' by <span class="tmvcstimeline-author">%s</span>' % ( webutils.escapeElem(oEntry.sAuthor), );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += '</a>\n';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += '</dt>\n';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEntry += ' <dd>%s</dd>\n' % ( webutils.escapeElem(oEntry.sMessage), );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml += sEntry;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oCurDate is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml += ' </dl>\n';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sHtml += '</div>\n';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return ('VCS History Tooltip', sHtml);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync