-import os
+import os, tarfile, ConfigParser, datetime
+from StringIO import StringIO
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.utils.translation import ugettext as _
from django.utils import simplejson
from django.core.cache import cache
from django.core.urlresolvers import reverse
from forum.views.admin import admin_tools_page, admin_page
+from forum.models import User
from forms import ExporterForm
from threading import Thread
+import settings as selsettings
+from forum import settings
-from exporter import export, CACHE_KEY, EXPORT_STEPS, LAST_BACKUP
+from exporter import export, CACHE_KEY, EXPORT_STEPS, LAST_BACKUP, DATE_AND_AUTHOR_INF_SECTION, DATETIME_FORMAT
@admin_tools_page(_('exporter'), _('XML data export'))
form = ExporterForm(request.POST)
if form.is_valid():
- thread = Thread(target=export, args=[form.cleaned_data])
+ thread = Thread(target=export, args=[form.cleaned_data, request.user])
thread.setDaemon(True)
thread.start()
else:
form = ExporterForm()
+ available = []
+
+ #folder = unicode(selsettings.EXPORTER_BACKUP_STORAGE)
+
+ #for f in os.listdir(folder):
+ # if (not os.path.isdir(os.path.join(folder, f))) and f.endswith('.tar.gz'):
+ # try:
+ # tar = tarfile.open(os.path.join(folder, f), "r")
+ # inf = ConfigParser.SafeConfigParser()
+ # inf.readfp(tar.extractfile('backup.inf'))
+ #
+ # if inf.get(DATE_AND_AUTHOR_INF_SECTION, 'site') == settings.APP_URL:
+ # available.append({
+ # 'author': User.objects.get(id=inf.get(DATE_AND_AUTHOR_INF_SECTION, 'author')),
+ # 'date': datetime.strptime(inf.get(DATE_AND_AUTHOR_INF_SECTION, 'finished'), )
+ # })
+ # except Exception, e:
+ # pass
+
return ('modules/exporter/exporter.html', {
- 'form': form
+ 'form': form,
+ 'available': available,
})
@admin_page
response['Content-Disposition'] = 'attachment; filename=backup.tar.gz'
return response
+