Updates of the main view.
authorŁukasz Rekucki <lrekucki@gmail.com>
Sat, 26 Sep 2009 12:10:53 +0000 (14:10 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Sat, 26 Sep 2009 12:10:53 +0000 (14:10 +0200)
apps/explorer/views.py
project/templates/explorer/file_list.html

index 889fda5..e3ca63a 100644 (file)
@@ -22,6 +22,8 @@ from toolbar import models as toolbar_models
 
 from django.forms.util import ErrorList
 
 
 from django.forms.util import ErrorList
 
+import wlrepo
+
 #
 # Some useful decorators
 
 #
 # Some useful decorators
 
@@ -36,7 +38,7 @@ def file_path(fileid):
 def with_repo(view):
     """Open a repository for this view"""
     def view_with_repo(request, *args, **kwargs):          
 def with_repo(view):
     """Open a repository for this view"""
     def view_with_repo(request, *args, **kwargs):          
-        kwargs['repo'] = hg.Repository(settings.REPOSITORY_PATH)
+        kwargs['repo'] = wlrepo.MercurialLibrary(settings.REPOSITORY_PATH)
         return view(request, *args, **kwargs)
     return view_with_repo
 
         return view(request, *args, **kwargs)
     return view_with_repo
 
@@ -55,20 +57,11 @@ def ajax_login_required(view):
 # View all files
 #
 @with_repo
 # View all files
 #
 @with_repo
-def file_list(request, repo):
-    #
-    latest_default = repo.get_branch_tip('default')
-
-    fl = []
-    for file in repo.repo[latest_default]:
-        m = re.match(u'^pub_([^/]+).xml$', file.decode('utf-8'), re.UNICODE)
-        if m is not None:
-            fl.append(m.group(1))
-            
-    bookform = forms.BookUploadForm()
-
+def file_list(request, repo):   
+    import api.forms
+    bookform = api.forms.DocumentUploadForm()
     return direct_to_template(request, 'explorer/file_list.html', extra_context={
     return direct_to_template(request, 'explorer/file_list.html', extra_context={
-        'files': fl, 'bookform': bookform,
+        'files': repo.documents(), 'bookform': bookform,
     })
 
 @permission_required('explorer.can_add_files')
     })
 
 @permission_required('explorer.can_add_files')
index 7612a71..bf6758f 100644 (file)
@@ -81,10 +81,8 @@ $(function() {
 {% if perms.explorer.can_add_files %}
 <div class="upload-file-widget">
 <h2>Dodaj nowy utwór</h2>
 {% if perms.explorer.can_add_files %}
 <div class="upload-file-widget">
 <h2>Dodaj nowy utwór</h2>
-<form action="{% url file_upload %}" method="POST" enctype="multipart/form-data">
-    <p><label>{{bookform.file.label}}: {{ bookform.file }}</label></p>
-    <p><label>{{bookform.bookname.label}}: {{bookform.bookname}}</label></p>
-    <p><label>{{bookform.autoxml}} {{bookform.autoxml.label}}</label></p>
+<form action="/api/documents" method="POST" enctype="multipart/form-data">
+    {{ bookform }}
     <p><button type="submit">Dodaj książkę</button></p>
 </form>
 </div>
     <p><button type="submit">Dodaj książkę</button></p>
 </form>
 </div>