- Dodanie przycisku obejmującego zaznaczony tekst tagiem <rozdzial> (testowo).
authorMarek Stępniowski <marek@stepniowski.com>
Fri, 7 Aug 2009 11:28:31 +0000 (13:28 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Fri, 7 Aug 2009 11:28:31 +0000 (13:28 +0200)
 - Dodanie możliwości ustalenia autora i wpisania opisu zmian przy zapisywaniu pliku.

apps/explorer/forms.py
apps/explorer/views.py
project/templates/explorer/file_xml.html

index 2d1c99a..fd460ac 100644 (file)
@@ -5,6 +5,8 @@ from explorer import models
 
 class BookForm(forms.Form):
     text = forms.CharField(widget=forms.Textarea)
+    commit_message = forms.CharField()
+    user = forms.CharField()
     
 
 class ImageFoldersForm(forms.Form):
index b8d00cf..4a78e01 100644 (file)
@@ -22,7 +22,7 @@ def file_xml(request, path):
         form = forms.BookForm(request.POST)
         if form.is_valid():
             repo.add_file(path, form.cleaned_data['text'])
-            repo.commit()
+            repo.commit(message=form.cleaned_data['commit_message'], user=form.cleaned_data['user'])
             return HttpResponseRedirect(request.get_full_path())
     else:
         form = forms.BookForm()
index 3f50659..66e128d 100644 (file)
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 
 {% block extrahead %}
-    <script src="/static/js/jquery.lazyload.js" type="text/javascript" charset="utf-8"></script>
+    <script src="/static/js/jquery.fieldselection.js" type="text/javascript" charset="utf-8"></script>
     <script type="text/javascript" charset="utf-8">        
         function aboveViewport(container, element, treshold) {
             return $(container).offset().top >= $(element).offset().top + $(element).height() + treshold;
             });
             
             setTimeout(checkScroll, 2000);
+            
+            $('#rozdzial-button').click(function(event) {
+                console.log($('#id_text').getSelection().text);
+                $('#id_text').replaceSelection('<rozdzial>' + $('#id_text').getSelection().text + '</rozdzial>', true);
+                event.preventDefault();
+            });
         });
     </script>
 {% endblock extrahead %}
@@ -59,7 +65,8 @@
         </div>
     </div>
     <form action="." method="post" accept-charset="utf-8">
+        <a href="#" id="rozdzial-button">Rodział</a>
         {{ form.text }}
-        <p><input type="submit" value="Zapisz"/></p>
+        <p>Użytkownik: {{ form.user }} Opis zmian: {{ form.commit_message }} <input type="submit" value="Zapisz"/></p>
     </form>
 {% endblock maincontent %}