from django.forms.util import ErrorList
+import wlrepo
+
#
# Some useful decorators
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
# 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={
- 'files': fl, 'bookform': bookform,
+ 'files': repo.documents(), 'bookform': bookform,
})
@permission_required('explorer.can_add_files')
{% 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>