Merge with 07019190bfe33d164593a42b92713b8265bb263b
authorraph
Sat, 13 Feb 2010 12:04:27 +0100
changeset 180 0887863001b1
parent 179 4c0f9871729d (diff)
parent 176 07019190bfe3 (current diff)
child 181 ffc7971c6a59
child 183 f1c6f8fadfef
Merge with 07019190bfe33d164593a42b92713b8265bb263b
src/cm/views/texts.py
--- a/src/cm/media/css/base.css	Sat Feb 13 12:03:14 2010 +0100
+++ b/src/cm/media/css/base.css	Sat Feb 13 12:04:27 2010 +0100
@@ -170,8 +170,18 @@
 	padding: 0.1em;
 }
 
+.diff-title {
+	font-size:140%;
+}
+
+.diff-author {
+	font-size:100%;
+	/*font-style: italic;*/
+}
+
+
 .diff-lineno {
-	font-weight: bold;
+	/*font-weight: bold;*/
 }
 
 .diff-context {
Binary file src/cm/media/img/plus-minus-left.gif has changed
Binary file src/cm/media/img/plus-minus-right.gif has changed
--- a/src/cm/templates/site/text_history.html	Sat Feb 13 12:03:14 2010 +0100
+++ b/src/cm/templates/site/text_history.html	Sat Feb 13 12:04:27 2010 +0100
@@ -77,6 +77,7 @@
             <th>{% blocktrans %}Version{% endblocktrans %}</th>
             <th colspan="2" width="1%">{% blocktrans %}Selection{% endblocktrans %}</th>
             <th>{% blocktrans %}Title{% endblocktrans %}</th>
+            <th>{% blocktrans %}Note{% endblocktrans %}</th>
             <th>{% blocktrans %}Author{% endblocktrans %}</th>
             <th>{% blocktrans %}Created{% endblocktrans %}</th>
             <th>{% blocktrans %}# comments{% endblocktrans %}</th>
@@ -137,6 +138,7 @@
                 --> 
                 </script>
             </td>
+            <td>{{ text_version.note|default_if_none:"" }}</td>
             <td>{{ text_version.get_name }}</td>
             <td>{{ text_version.created|local_date }}</td>
             <td>{{ text_version|nb_comments:request }}</td>
--- a/src/cm/templates/site/text_history_compare.html	Sat Feb 13 12:03:14 2010 +0100
+++ b/src/cm/templates/site/text_history_compare.html	Sat Feb 13 12:04:27 2010 +0100
@@ -27,13 +27,14 @@
 <ul class="sub_list">
     <li><a href="{% url text-history text.key %}">{% blocktrans %}Version list{% endblocktrans %}</a></li>
     <li> / </li>
-    <li><a href="{% url text-history-version text.key v1.key %}">{% blocktrans with v1.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}</a></li>
-    <li> / </li>
-    <li class="active_sub">{% blocktrans with v1.get_version_number as version_1_number and v2.get_version_number as version_2_number %}Comparison between version #{{ version_1_number }} and #{{ version_2_number }}{% endblocktrans %}</li>
-    <li> / </li>
-    <li><a href="{% url text-history-version text.key v2.key %}">{% blocktrans with v2.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}</a></li>
-    <li> / </li>
-    <li><a href="{% url text-history-version text.key text.last_text_version.key %}">{% blocktrans %}Most recent version{% endblocktrans %}</a></li>    
+    {% if v1.get_previous_version %}<li>&nbsp;<a href="{% url text-history-compare text.key v1.get_previous_version.key v1.key %}"><img style="vertical-align: text-bottom;" title="{% blocktrans %}Previous modification{% endblocktrans %}" alt="{% blocktrans %}Previous modification{% endblocktrans %}" src="{{ CM_MEDIA_PREFIX }}img/plus-minus-left.gif"></img></a></li>{% endif %}    
+    <li>&nbsp;<a href="{% url text-history-version text.key v1.key %}" alt="{% blocktrans with v1.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}">&laquo;{{ v1.get_version_number }}</a></li>
+    <li class="active_sub">&nbsp;{% blocktrans with v1.get_version_number as version_1_number and v2.get_version_number as version_2_number %}Comparison between version #{{ version_1_number }} and #{{ version_2_number }}{% endblocktrans %}</li>
+    {% ifnotequal v2.key text.last_text_version.key %}<li>&nbsp;<a href="{% url text-history-version text.key v2.key %}" alt="{% blocktrans with v2.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}">{{ v2.get_version_number }}&raquo;</a></li>
+    {% if v1.get_next_version %}<li>&nbsp;<a href="{% url text-history-compare text.key v2.key v2.get_next_version.key %}"><img style="vertical-align: text-bottom;" title="{% blocktrans %}Next modification{% endblocktrans %}" alt="{% blocktrans %}Next modification{% endblocktrans %}" src="{{ CM_MEDIA_PREFIX }}img/plus-minus-right.gif"></img></a></li>{% endif %}    
+    
+    {% endifnotequal %}
+    <li>&nbsp;<a href="{% url text-history-version text.key text.last_text_version.key %}" alt="{% blocktrans %}Most recent version{% endblocktrans %}">{{ text.last_text_version.get_version_number }}&raquo;&raquo;</a></li>
 </ul>
 
 <div style="clear:both;"></div>
--- a/src/cm/templates/site/text_history_version.html	Sat Feb 13 12:03:14 2010 +0100
+++ b/src/cm/templates/site/text_history_version.html	Sat Feb 13 12:04:27 2010 +0100
@@ -26,18 +26,17 @@
 
 <ul class="sub_list">
     <li><a href="{% url text-history text.key %}">{% blocktrans %}Version list{% endblocktrans %}</a></li>
-    <li> / </li>
-    <li class="active_sub">{% blocktrans with text_version.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}</li>
+    <li>&nbsp;/</li>
     {% if text_version.get_previous_version %}
-    <li> / </li>
-    <li><a href="{% url text-history-compare text.key text_version.get_previous_version.key text_version.key %}">{% blocktrans %}Compare with previous version{% endblocktrans %}</a></li>
+    <li>&nbsp;<a href="{% url text-history-version text.key text_version.get_previous_version.key %}" title="{% blocktrans %}Previous version{% endblocktrans %}" >&laquo;{{ text_version.get_previous_version.get_version_number }}</a></li>
+    <li>&nbsp;<a href="{% url text-history-compare text.key text_version.get_previous_version.key text_version.key %}"><img style="vertical-align: text-bottom;" title="{% blocktrans %}Compare with previous version{% endblocktrans %}" alt="title="{% blocktrans %}Compare with previous version{% endblocktrans %}"  src="{{ CM_MEDIA_PREFIX }}img/plus-minus-left.gif"></img></a></li>
     {% endif %}
+    <li class="active_sub">{% blocktrans with text_version.get_version_number as version_number %}Version {{ version_number }}{% endblocktrans %}</li>
     {% if text_version.get_next_version %}
-    <li> / </li>
-    <li><a href="{% url text-history-compare text.key text_version.key text_version.get_next_version.key %}">{% blocktrans %}Compare with next version{% endblocktrans %}</a></li>
+    <li>&nbsp;<a href="{% url text-history-compare text.key text_version.key text_version.get_next_version.key %}"><img style="vertical-align: text-bottom;" title="{% blocktrans %}Compare with next version{% endblocktrans %}" alt="{% blocktrans %}Compare with next version{% endblocktrans %}" src="{{ CM_MEDIA_PREFIX }}img/plus-minus-right.gif"></img></a></li>
+    <li>&nbsp;<a href="{% url text-history-version text.key text_version.get_next_version.key %}" title="{% blocktrans %}Next version{% endblocktrans %}" >{{ text_version.get_next_version.get_version_number }}&raquo;</a></li>
+    <li>&nbsp;<a href="{% url text-history-version text.key text.last_text_version.key %}" title="{% blocktrans %}Most recent version{% endblocktrans %}">{{ text.last_text_version.get_version_number }}&raquo;&raquo;</a></li>    
     {% endif %}
-    <li> / </li>
-    <li><a href="{% url text-history-version text.key text.last_text_version.key %}">{% blocktrans %}Most recent version{% endblocktrans %}</a></li>    
 </ul>
 
 <div style="clear:both;"></div>
--- a/src/cm/views/texts.py	Sat Feb 13 12:03:14 2010 +0100
+++ b/src/cm/views/texts.py	Sat Feb 13 12:04:27 2010 +0100
@@ -473,7 +473,12 @@
     v1 = get_textversion_by_keys_or_404(v1_version_key, key=key)
     v2 = get_textversion_by_keys_or_404(v2_version_key, key=key)
 
-    content = get_uniffied_inner_diff_table(v1.content, v2.content)
+    content = get_uniffied_inner_diff_table(v1.title,
+                                            v2.title, 
+                                            _("by %(author)s") %{'author' : v1.get_name()},
+                                            _("by %(author)s") %{'author' : v2.get_name()},
+                                            v1.content,
+                                            v2.content)
     if mode=='1':
         # alternate diff
         from cm.utils.diff import text_diff
@@ -533,13 +538,16 @@
 def diff_decorate(minus, plus):
     return minus, plus
 
-def get_uniffied_inner_diff_table(text1, text2):
+def get_uniffied_inner_diff_table(title1, title2, author1, author2, text1, text2):
     """
     Return the inner of the html table for text1 vs text2 diff
     """
     gen = unified_diff(text1.split('\n'), text2.split('\n'), n=3)
     index = 0
     res = ['<table class="diff"><tbody>']
+    res.append('<tr><td></td><td class="diff-title">%s</td><td></td><td></td><td class="diff-title">%s</td></tr>' %(title1, title2))
+    res.append('<tr><td></td><td class="diff-author">%s</td><td></td><td></td><td class="diff-author">%s</td></tr>' %(author1, author2))
+    res.append('<tr><td colspan="5"></td></tr>')
     #res.append('<tr><td width="50%" colspan="2"></td><td width="50%" colspan="2"></td></tr>')
     
     for g in gen:
@@ -635,20 +643,21 @@
         return version
 
     def save_new_version(self, text, request):
-        new_text_version = TextVersion.objects.duplicate(text.get_latest_version(), True) 
-        new_text_version.user = request.user if request.user.is_authenticated() else None
-        new_text_version.note = request.POST.get('note','')
-        new_text_version.email = request.POST.get('email','')
-        new_text_version.name = request.POST.get('name','')
-        new_text_version.save()
-        
         new_content = request.POST.get('content')
         new_title = request.POST.get('title')
         new_format = request.POST.get('format', text.last_text_version.format)        
         new_note = request.POST.get('note',None)
         new_tags = request.POST.get('tags',None)
         cancel_modified_scopes = (request.POST.get('cancel_modified_scopes',u'1') == u'1')
+        
+        new_text_version = text.edit(new_title, new_format, new_content, new_tags, new_note, keep_comments=True, cancel_modified_scopes=cancel_modified_scopes, new_version=True)
+        
         new_text_version.edit(new_title, new_format, new_content, new_tags, new_note, True, cancel_modified_scopes)
+        new_text_version.user = request.user if request.user.is_authenticated() else None
+        new_text_version.note = request.POST.get('note','')
+        new_text_version.email = request.POST.get('email','')
+        new_text_version.name = request.POST.get('name','')
+        new_text_version.save()
         
         return new_text_version