from api.utils import validate_form, hglibrary, natural_order
from api.models import PartCache, PullRequest
+from pygments import highlight
+from pygments.lexers import DiffLexer
+from pygments.formatters import HtmlFormatter
+
#
import settings
allowed_methods = ('GET',)
@hglibrary
- def read(self, request, source_revision, target_revision, lib):
- '''Return diff between source_revision and target_revision)'''
- source_document = lib.document_for_revision(source_revision)
- target_document = lib.document_for_revision(target_revision)
- print source_document,
- print target_document
+ def read(self, request, docid, lib):
+ '''Return diff between source_revision and target_revision)'''
+ revision = request.GET.get('revision')
+ if not revision:
+ return ''
+ source_document = lib.document(docid)
+ target_document = lib.document_for_revision(revision)
+ print source_document, target_document
+
diff = difflib.unified_diff(
source_document.data('xml').splitlines(True),
target_document.data('xml').splitlines(True),
'source',
'target')
- return ''.join(list(diff))
+ s = ''.join(list(diff))
+ return highlight(s, DiffLexer(), HtmlFormatter(cssclass="pastie"))
#
url(urlpath(r'documents', DOC, 'revision', format=False),
document_merge, {'emitter_format': 'json'}, name="docmerge_view"),
- url(r'diffs/(?P<source_revision>latest|[0-9a-fA-F]+)/(?P<target_revision>latest|[0-9a-fA-F]+)/$',
+ url(r'documents/(?P<docid>[^/]+)/diff$',
diff_resource, {'emitter_format': 'raw'}, name="diff_resource"),
margin-right: auto;
}
-.request-report td, .request-report th {
- vertical-align: top;
- border-right: 1px solid black;
- border-bottom: 1px solid black;
+.pull-request {
+ padding: 20px 20px 10px 20px;
+ border-bottom: 1px dotted #CCC;
+}
+
+.pull-request h2 {
+ padding: 0;
+ margin: 0;
+ font-size: 22px;
+}
+
+.pull-request .request-info {
+ color: #999;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+.pull-request .request-info li {
+ float: left;
+ padding-right: 20px;
+}
+
+.pull-request p.comment {
+ clear: left;
+ padding: 20px 0;
+}
- padding: 0.4em 1em;
- margin: 0em;
+.pull-request p {
+ margin: 0;
+ padding: 0;
}
-.request-report th {
- background-color: black;
- color: white;
+.awesome.button {
+ margin-right: 10px;
}
.request-report .status-N {
.request-report .status-A {
background-color: gray;
-}
\ No newline at end of file
+}
+
+.pull-request .diff {
+ white-space: pre;
+}
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>{% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%}</title>
<link rel="stylesheet" href="{{ STATIC_URL }}css/master.css" type="text/css" />
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/buttons.css" type="text/css" />
<script src="{{ STATIC_URL }}js/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ STATIC_URL }}js/lib/jquery.logging.js" type="text/javascript" charset="utf-8"></script>
{% block extrahead %}
{% extends 'base.html' %}
+{% block bodyid %}management{% endblock %}
+
{% block extrahead %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/managment.css" type="text/css" />
+<link rel="stylesheet" href="{{ STATIC_URL }}css/pygments.css" type="text/css" />
<script type="text/javascript">
$('.accept-button').click(function()
{
var id = parseInt($(this).attr('title'));
-
$.ajax({
url: '{% url pullrequest_list %}/'+id,
});
+ $('.show-diff').click(function() {
+ var button = $(this);
+
+ if (button.attr('disabled') != 'disabled') {
+ button.attr('disabled', 'disabled');
+ var id = parseInt(button.attr('title'));
+ var docid = $('h2', button.parents('.pull-request')).html();
+ var revision = $('.pull-request-revision', button.parents('.pull-request')).html();
+
+ $('.diff').slideUp(function() { $(this).remove() });
+ $('<div class="diff"></div>')
+ .hide()
+ .appendTo($(this).parents('.pull-request'))
+ .slideDown('slow')
+ .load('/api/documents/' + docid + '/diff?revision=' + revision, null, function() {
+ button.attr('disabled', null);
+ });
+ }
+ });
+
});
</script>
{% endblock %}
{% block maincontent %}
-<table class="request-report" cellspacing="0">
- <tr>
- <th>Utwór</th><th>Użytkownik</th><th>Komentarz</th><th>Stan</th>
- <th>Zgłoszono</th><th>Akcje</th>
- </tr>
{% if objects %}
{% for pullreq in objects %}
- <tr class="status-{{pullreq.status}}" id="request-{{pullreq.id}}">
- <td class="column-doc">{{ pullreq.document }}</td>
- <td class="column-user">{{ pullreq.comitter }}</td>
- <td class="column-comment">{{ pullreq.comment }}</td>
- <td class="column-status"> {{ pullreq.status }}</td>
- <td class="column-data">{{ pullreq.timestamp }}</td>
- <td>
- <button type="button" class="accept-button" title="{{pullreq.id}}">Akceptuj</button>
- <a href="{% url editor_view pullreq.document %}?user=$prq-{{pullreq.id}}">Zobacz</a>
- </td>
- </tr>
-
+ <div class="status-{{ pullreq.status }} pull-request" id="request-{{ pullreq.id }}">
+ <h2>{{ pullreq.document }}</h2>
+ <ul class="request-info">
+ <li>commiter: {{ pullreq.comitter }}</li>
+ <li>revision: <span class="pull-request-revision">{{ pullreq.source_revision }}</span></li>
+ <li>status: {{ pullreq.status }}</li>
+ <li>data: {{ pullreq.timestamp }}</li>
+ </ul>
+ <p class="comment">{{ pullreq.comment }}</p>
+ <p class="buttons">
+ <button type="button" class="awesome button green accept-button" title="{{pullreq.id}}">Akceptuj</button>
+ <button type="button" class="awesome button show-diff" title="{{pullreq.id}}">Zmiany</button>
+ <a class="awesome button" href="{% url editor_view pullreq.document %}?user=$prq-{{pullreq.id}}">Zobacz</a>
+ </p>
+ </div>
{% endfor %}
{% else %}
- <tr><td colspan="6">Brak żądań</td></tr>
+ {# <tr><td colspan="6">Brak żądań</td></tr> #}
{% endif %}
-</table>
+{# </table> #}
{% endblock %}