X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/1f58a10a88c18512abc9c84f49a04a18e00fa8c5..74dca79d402e43baaa69b760698429f223f98e3c:/apps/explorer/views.py?ds=inline diff --git a/apps/explorer/views.py b/apps/explorer/views.py index 68fd1921..ffe5973d 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -3,8 +3,10 @@ import hg, urllib2 from django.utils import simplejson as json from django.views.generic.simple import direct_to_template + from django.conf import settings -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, HttpResponse +from django.contrib.auth.decorators import login_required from explorer import forms, models @@ -19,15 +21,19 @@ def file_xml(request, path): if request.method == 'POST': form = forms.BookForm(request.POST) if form.is_valid(): - repo.add_file(path, form.cleaned_data['text']) + # save the changes to a local branch +# repo.write_lock() + print request.user +# repo.switch_to_branch(request.user.name) +# repo.add_file(path, form.cleaned_data['text']) # add references to comment issues = _get_issues_for_file(path) commit_message = _add_references(form.cleaned_data['commit_message'], issues) print 'Commiting with: ' + commit_message - repo.commit(message=commit_message, user=form.cleaned_data['user']) - return HttpResponseRedirect(request.get_full_path()) +# repo.commit(message=commit_message, user=form.cleaned_data['user']) + return HttpResponse( json.dumps({'message': commit_message}) ) else: form = forms.BookForm() form.fields['text'].initial = repo.get_file(path).data() @@ -63,11 +69,30 @@ def htmleditor_panel(request, path): }) +def dceditor_panel(request, path): + if request.method == 'POST': + form = forms.DublinCoreForm(request.POST) + if form.is_valid(): + form.save(repo, path) + repo.commit(message='%s: DublinCore edited' % path) + else: + text = repo.get_file(path).data() + form = forms.DublinCoreForm(text=text) + + return direct_to_template(request, 'explorer/panels/dceditor.html', extra_context={ + 'form': form, + }) + + +# ================= +# = Utility views = +# ================= def folder_images(request, folder): return direct_to_template(request, 'explorer/folder_images.html', extra_context={ 'images': models.get_images_from_folder(folder), }) + def _add_references(message, issues): return message + " - " + ", ".join(map(lambda issue: "Refs #%d" % issue['id'], issues))