Fixed some additional str/bytes issues.
- Legacy-Id: 16342
This commit is contained in:
parent
36cac48063
commit
8b52899459
|
@ -413,11 +413,11 @@ def submit(request, name, option=None):
|
|||
|
||||
# Save file on disk
|
||||
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev))
|
||||
with open(filename, 'wb') as destination:
|
||||
with open(filename, 'w', encoding='utf-8') as destination:
|
||||
if form.cleaned_data['txt']:
|
||||
destination.write(form.cleaned_data['txt'])
|
||||
else:
|
||||
destination.write(form.cleaned_data['content'].encode("utf-8"))
|
||||
destination.write(form.cleaned_data['content'])
|
||||
|
||||
if option in ['initcharter','recharter'] and charter.ad == None:
|
||||
charter.ad = getattr(group.ad_role(),'person',None)
|
||||
|
|
|
@ -159,7 +159,7 @@ class UploadForm(forms.Form):
|
|||
|
||||
def save(self, review):
|
||||
filename = os.path.join(settings.CONFLICT_REVIEW_PATH, '%s-%s.txt' % (review.canonical_name(), review.rev))
|
||||
with open(filename, 'wb') as destination:
|
||||
with open(filename, 'w', encoding='utf-8') as destination:
|
||||
if self.cleaned_data['txt']:
|
||||
destination.write(self.cleaned_data['txt'])
|
||||
else:
|
||||
|
|
|
@ -124,7 +124,7 @@ class UploadForm(forms.Form):
|
|||
|
||||
def save(self, doc):
|
||||
filename = os.path.join(settings.STATUS_CHANGE_PATH, '%s-%s.txt' % (doc.canonical_name(), doc.rev))
|
||||
with open(filename, 'wb') as destination:
|
||||
with open(filename, 'w', encoding='utf-8') as destination:
|
||||
if self.cleaned_data['txt']:
|
||||
destination.write(self.cleaned_data['txt'])
|
||||
else:
|
||||
|
|
|
@ -49,6 +49,7 @@ from django.db import models
|
|||
from django.http import HttpResponse
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.sites.models import Site
|
||||
from django.utils.encoding import force_bytes
|
||||
#from django.views.decorators.cache import cache_page
|
||||
#from django.views.decorators.vary import vary_on_cookie
|
||||
|
||||
|
@ -454,22 +455,22 @@ def telechat_docs_tarfile(request, date):
|
|||
|
||||
tarstream = tarfile.open('', 'w:gz', response)
|
||||
|
||||
manifest = io.StringIO()
|
||||
manifest = io.BytesIO()
|
||||
|
||||
for doc in docs:
|
||||
doc_path = os.path.join(doc.get_file_path(), doc.name + "-" + doc.rev + ".txt")
|
||||
doc_path = force_bytes(os.path.join(doc.get_file_path(), doc.name + "-" + doc.rev + ".txt"))
|
||||
if os.path.exists(doc_path):
|
||||
try:
|
||||
tarstream.add(doc_path, str(doc.name + "-" + doc.rev + ".txt"))
|
||||
manifest.write("Included: %s\n" % doc_path)
|
||||
manifest.write(b"Included: %s\n" % doc_path)
|
||||
except Exception as e:
|
||||
manifest.write("Failed (%s): %s\n" % (e, doc_path))
|
||||
manifest.write(b"Failed (%s): %s\n" % (force_bytes(e), doc_path))
|
||||
else:
|
||||
manifest.write("Not found: %s\n" % doc_path)
|
||||
manifest.write(b"Not found: %s\n" % doc_path)
|
||||
|
||||
manifest.seek(0)
|
||||
t = tarfile.TarInfo(name="manifest.txt")
|
||||
t.size = len(manifest.buf)
|
||||
t.size = len(manifest.getvalue())
|
||||
t.mtime = time.time()
|
||||
tarstream.addfile(t, manifest)
|
||||
|
||||
|
|
Loading…
Reference in a new issue