mirror of https://gitlab.crans.org/bde/nk20
Fix CI
This commit is contained in:
parent
b3bc30b72b
commit
2d0ba4750c
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from treasury.models import Billing, Product
|
from .models import Billing, Product
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Billing)
|
@admin.register(Billing)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.db.models.signals import pre_save, post_save, post_delete
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ ProductFormSet = forms.inlineformset_factory(
|
||||||
extra=1,
|
extra=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProductFormSetHelper(FormHelper):
|
class ProductFormSetHelper(FormHelper):
|
||||||
def __init__(self, form=None):
|
def __init__(self, form=None):
|
||||||
super().__init__(form)
|
super().__init__(form)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_tables2 import A
|
from django_tables2 import A
|
||||||
|
|
||||||
from .models import Billing
|
from .models import Billing
|
||||||
|
@ -11,7 +11,7 @@ from .models import Billing
|
||||||
class BillingTable(tables.Table):
|
class BillingTable(tables.Table):
|
||||||
id = tables.LinkColumn("treasury:billing_update",
|
id = tables.LinkColumn("treasury:billing_update",
|
||||||
args=[A("pk")],
|
args=[A("pk")],
|
||||||
text=lambda record: _("Billing #{:d}").format(record.id),)
|
text=lambda record: _("Billing #{:d}").format(record.id), )
|
||||||
|
|
||||||
billing = tables.LinkColumn("treasury:billing_render",
|
billing = tables.LinkColumn("treasury:billing_render",
|
||||||
verbose_name=_("Billing"),
|
verbose_name=_("Billing"),
|
||||||
|
@ -29,4 +29,4 @@ class BillingTable(tables.Table):
|
||||||
}
|
}
|
||||||
model = Billing
|
model = Billing
|
||||||
template_name = 'django_tables2/bootstrap4.html'
|
template_name = 'django_tables2/bootstrap4.html'
|
||||||
fields = ('id', 'name', 'subject', 'acquitted', 'billing', )
|
fields = ('id', 'name', 'subject', 'acquitted', 'billing',)
|
||||||
|
|
|
@ -15,7 +15,6 @@ from django.urls import reverse_lazy
|
||||||
from django.views.generic import CreateView, UpdateView
|
from django.views.generic import CreateView, UpdateView
|
||||||
from django.views.generic.base import View
|
from django.views.generic.base import View
|
||||||
from django_tables2 import SingleTableView
|
from django_tables2 import SingleTableView
|
||||||
|
|
||||||
from note_kfet.settings.base import BASE_DIR
|
from note_kfet.settings.base import BASE_DIR
|
||||||
|
|
||||||
from .forms import BillingForm, ProductFormSet, ProductFormSetHelper
|
from .forms import BillingForm, ProductFormSet, ProductFormSetHelper
|
||||||
|
@ -130,6 +129,7 @@ class BillingRenderView(LoginRequiredMixin, View):
|
||||||
pass
|
pass
|
||||||
tmp_dir = mkdtemp(prefix=BASE_DIR + "/tmp/")
|
tmp_dir = mkdtemp(prefix=BASE_DIR + "/tmp/")
|
||||||
|
|
||||||
|
try:
|
||||||
with open("{}/billing-{:d}.tex".format(tmp_dir, pk), "wb") as f:
|
with open("{}/billing-{:d}.tex".format(tmp_dir, pk), "wb") as f:
|
||||||
f.write(tex.encode("UTF-8"))
|
f.write(tex.encode("UTF-8"))
|
||||||
del tex
|
del tex
|
||||||
|
@ -142,6 +142,9 @@ class BillingRenderView(LoginRequiredMixin, View):
|
||||||
stdout=open(os.devnull, "wb")
|
stdout=open(os.devnull, "wb")
|
||||||
).wait()
|
).wait()
|
||||||
|
|
||||||
|
if error:
|
||||||
|
raise IOError("An error attempted while generating a billing:", error)
|
||||||
|
|
||||||
error = subprocess.Popen(
|
error = subprocess.Popen(
|
||||||
["pdflatex", "billing-{}.tex".format(pk)],
|
["pdflatex", "billing-{}.tex".format(pk)],
|
||||||
cwd=tmp_dir,
|
cwd=tmp_dir,
|
||||||
|
@ -150,10 +153,15 @@ class BillingRenderView(LoginRequiredMixin, View):
|
||||||
stdout=open(os.devnull, "wb")
|
stdout=open(os.devnull, "wb")
|
||||||
).wait()
|
).wait()
|
||||||
|
|
||||||
pdf = open("{}/billing-{}.pdf".format(tmp_dir, pk), 'rb').read()
|
if error:
|
||||||
shutil.rmtree(tmp_dir)
|
raise IOError("An error attempted while generating a billing:", error)
|
||||||
|
|
||||||
|
pdf = open("{}/billing-{}.pdf".format(tmp_dir, pk), 'rb').read()
|
||||||
response = HttpResponse(pdf, content_type="application/pdf")
|
response = HttpResponse(pdf, content_type="application/pdf")
|
||||||
response['Content-Disposition'] = "inline;filename=billing-{:d}.pdf".format(pk)
|
response['Content-Disposition'] = "inline;filename=billing-{:d}.pdf".format(pk)
|
||||||
|
except IOError as e:
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(tmp_dir)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -32,7 +32,7 @@ deps =
|
||||||
pep8-naming
|
pep8-naming
|
||||||
pyflakes
|
pyflakes
|
||||||
commands =
|
commands =
|
||||||
flake8 apps/activity apps/api apps/logs apps/member apps/note
|
flake8 apps/activity apps/api apps/logs apps/member apps/note apps/treasury
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# Ignore too many errors, should be reduced in the future
|
# Ignore too many errors, should be reduced in the future
|
||||||
|
|
Loading…
Reference in New Issue