|
|
|
@ -12,7 +12,7 @@ from django.contrib import messages |
|
|
|
from django.db import DatabaseError |
|
|
|
from django.db import DatabaseError |
|
|
|
|
|
|
|
|
|
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
|
from django.http import HttpResponseServerError, HttpResponseBadRequest, HttpResponse |
|
|
|
from django.http import HttpResponseBadRequest, HttpResponse |
|
|
|
from django.utils.decorators import method_decorator |
|
|
|
from django.utils.decorators import method_decorator |
|
|
|
from django.views.decorators.http import require_POST |
|
|
|
from django.views.decorators.http import require_POST |
|
|
|
from django.views.decorators.csrf import csrf_protect |
|
|
|
from django.views.decorators.csrf import csrf_protect |
|
|
|
@ -21,7 +21,6 @@ from django.forms.models import inlineformset_factory, model_to_dict |
|
|
|
from django.template.loader import render_to_string |
|
|
|
from django.template.loader import render_to_string |
|
|
|
from django.core.mail import EmailMessage |
|
|
|
from django.core.mail import EmailMessage |
|
|
|
from django.utils.encoding import smart_str |
|
|
|
from django.utils.encoding import smart_str |
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from commons.utils import dthandler |
|
|
|
from commons.utils import dthandler |
|
|
|
from commons.paginator import pagination, save_per_page_value |
|
|
|
from commons.paginator import pagination, save_per_page_value |
|
|
|
@ -33,11 +32,10 @@ from customer.forms import ClientsListForm, ClientForm |
|
|
|
|
|
|
|
|
|
|
|
from docs.as_xls import render_xls_to_string |
|
|
|
from docs.as_xls import render_xls_to_string |
|
|
|
from docs.forms import EmailForm, InvoicesListForm |
|
|
|
from docs.forms import EmailForm, InvoicesListForm |
|
|
|
from docs import filters |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from customer.decorators import license_required |
|
|
|
from customer.decorators import license_required |
|
|
|
from customer.utils import raise_if_no_profile |
|
|
|
from customer.utils import raise_if_no_profile |
|
|
|
from django.conf import settings |
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
import traceback |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG = getattr(settings, 'DEBUG', False) |
|
|
|
DEBUG = getattr(settings, 'DEBUG', False) |
|
|
|
@ -47,6 +45,8 @@ MEDIA_URL = getattr(settings, 'MEDIA_URL', '') |
|
|
|
|
|
|
|
|
|
|
|
ORDER_VAR = 'o' |
|
|
|
ORDER_VAR = 'o' |
|
|
|
ORDER_TYPE_VAR = 'ot' |
|
|
|
ORDER_TYPE_VAR = 'ot' |
|
|
|
|
|
|
|
# GHOSTSCRIPTCMD = 'gs' |
|
|
|
|
|
|
|
GHOSTSCRIPTCMD = '/usr/bin/gs' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Ordering(object): |
|
|
|
class Ordering(object): |
|
|
|
@ -409,7 +409,9 @@ class BaseViews(object): |
|
|
|
f.write(pdf) |
|
|
|
f.write(pdf) |
|
|
|
f.close() |
|
|
|
f.close() |
|
|
|
|
|
|
|
|
|
|
|
args = ["gs", |
|
|
|
print(filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args = [GHOSTSCRIPTCMD, |
|
|
|
"-q", |
|
|
|
"-q", |
|
|
|
"-dNOPAUSE", "-dBATCH", "-dSAFER", |
|
|
|
"-dNOPAUSE", "-dBATCH", "-dSAFER", |
|
|
|
"-sDEVICE=png16m", |
|
|
|
"-sDEVICE=png16m", |
|
|
|
@ -418,10 +420,19 @@ class BaseViews(object): |
|
|
|
"-f", filename |
|
|
|
"-f", filename |
|
|
|
] |
|
|
|
] |
|
|
|
try: |
|
|
|
try: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("Running command:\n%s" % ' '.join(args)) |
|
|
|
|
|
|
|
|
|
|
|
p = s.Popen(args=args, stdout=s.PIPE, stderr=s.PIPE) |
|
|
|
p = s.Popen(args=args, stdout=s.PIPE, stderr=s.PIPE) |
|
|
|
p.wait() |
|
|
|
p.wait() |
|
|
|
except OSError: |
|
|
|
except OSError as e: |
|
|
|
sys.exit("Error executing Ghostscript. Is it in your PATH?") |
|
|
|
sys.exit("{}\nError executing Ghostscript {}. " |
|
|
|
|
|
|
|
"Is it in your PATH?".format(e, GHOSTSCRIPTCMD)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
print("Error while running Ghostscript subprocess. Traceback:") |
|
|
|
|
|
|
|
print("Traceback:\n%s" % traceback.format_exc()) |
|
|
|
|
|
|
|
|
|
|
|
os.remove(filename) |
|
|
|
os.remove(filename) |
|
|
|
filename = '%s.pdf' % self.get_filename(*args, **kwargs) |
|
|
|
filename = '%s.pdf' % self.get_filename(*args, **kwargs) |
|
|
|
imgs = glob.glob(os.path.join(tmp_dir, '*.png')) |
|
|
|
imgs = glob.glob(os.path.join(tmp_dir, '*.png')) |
|
|
|
|