Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move style to it's own file
dominik-zeglen7d4bf601a0c1
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.pyindex db2e4bdb96..03740e2b50 100644--- a/saleor/dashboard/order/views.py+++ b/saleor/dashboard/order/views.py@@ -381,25 +381,19 @@ def order_invoice(request, order_pk, group_pk):group = DeliveryGroup.objects.prefetch_related('items').get(pk=group_pk)ctx = {'order': order,'group': group}- with open('/app/saleor/static/assets/dashboard.css') as f:- ctx['style'] = f.read()with open('/app/saleor/static/images/saleor_logo.svg') as f:ctx['logo'] = "data:image/svg+xml;charset=utf-8;base64," \+ str(b64encode(bytes(f.read().replace('white', '#333'),'utf-8')),'utf-8')- # rendered_template = get_template(- # 'dashboard/order/pdf/invoice.html').render(ctx)- # pdf_file = HTML(string=rendered_template).write_pdf()- # response = HttpResponse(pdf_file, content_type='application/pdf')- # name = "invoice-%s" % order.id- # response['Content-Disposition'] = 'filename=%s' % name- # return response-- return TemplateResponse(request,- 'dashboard/order/pdf/invoice.html',- ctx)+ rendered_template = get_template(+ 'dashboard/order/pdf/invoice.html').render(ctx)+ pdf_file = HTML(string=rendered_template).write_pdf()+ response = HttpResponse(pdf_file, content_type='application/pdf')+ name = "invoice-%s" % order.id+ response['Content-Disposition'] = 'filename=%s' % name+ return response@staff_member_required@@ -410,8 +404,6 @@ def order_packing_slip(request, order_pk, group_pk):group = DeliveryGroup.objects.prefetch_related('items').get(pk=group_pk)ctx = {'order': order,'group': group}- with open('/app/saleor/static/assets/dashboard.css') as f:- ctx['style'] = f.read()with open('/app/saleor/static/images/saleor_logo.svg') as f:ctx['logo'] = "data:image/svg+xml;charset=utf-8;base64," \+ str(b64encode(bytes(f.read()diff --git a/templates/dashboard/order/pdf/invoice.html b/templates/dashboard/order/pdf/invoice.htmlindex 464266630e..9d4afd2f7e 100644--- a/templates/dashboard/order/pdf/invoice.html+++ b/templates/dashboard/order/pdf/invoice.html@@ -1,55 +1,8 @@{% load i18n static %}{% load prices_i18n %}{% load discount_amount_for from prices %}-{% load staticfiles %}-<style>- {{ style }}- html, body {- font-size: 12px;- }- .order-table {- margin-bottom: 30px;- }-- .data-table {- max-width: 100%;- width: 100%;- }-- .data-table tr {- border-bottom: 1px #d0d0d0 solid;- }-- .data-table tr:last-child {- border-bottom: none;- }-- .data-table td {- height: 30px;- padding: 10px;- }-- header {- margin-bottom: 5rem;- }-- #invoice-footer {- position: fixed;- bottom: 0;- width: 100%;- text-align: center;- }-- @page {- @bottom-center {- content: "Saleor eCommerce, Mirumee Software";- }- @bottom-right {- content: "Page " counter(page) "/" counter(pages);- }- }-</style>+{% include 'dashboard/order/pdf/style.html' %}<header><div style="float:left">diff --git a/templates/dashboard/order/pdf/packing_slip.html b/templates/dashboard/order/pdf/packing_slip.htmlindex 4c4d662bae..f0c11dbe2b 100644--- a/templates/dashboard/order/pdf/packing_slip.html+++ b/templates/dashboard/order/pdf/packing_slip.html@@ -2,54 +2,7 @@{% load prices_i18n %}{% load discount_amount_for from prices %}-<style>- {{ style }}- html, body {- font-size: 12px;- }-- .order-table {- margin-bottom: 30px;- }-- .data-table {- max-width: 100%;- width: 100%;- }-- .data-table tr {- border-bottom: 1px #d0d0d0 solid;- }-- .data-table tr:last-child {- border-bottom: none;- }-- .data-table td {- height: 30px;- padding: 10px;- }-- header {- margin-bottom: 5rem;- }-- #invoice-footer {- position: fixed;- bottom: 0;- width: 100%;- text-align: center;- }-- @page {- @bottom-center {- content: "Saleor eCommerce, Mirumee Software";- }- @bottom-right {- content: "Page " counter(page) "/" counter(pages);- }- }-</style>+{% include 'dashboard/order/pdf/style.html' %}<header><div style="float:left">diff --git a/templates/dashboard/order/pdf/style.html b/templates/dashboard/order/pdf/style.htmlnew file mode 100644index 0000000000..7623c6fff7--- /dev/null+++ b/templates/dashboard/order/pdf/style.html@@ -0,0 +1,49 @@+<style>+ .currency,h6{color:#9e9e9e!important}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}details,header{display:block}[hidden]{display:none}h1{font-size:2em;margin:.67em 0}img{border:0}svg:not(:root){overflow:hidden}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}html{-webkit-box-sizing:border-box;box-sizing:border-box}*,:after,:before{-webkit-box-sizing:inherit;box-sizing:inherit}img.responsive-img{max-width:100%;height:auto}table,td,th{border:none}table{width:100%;display:table}table.bordered>tbody>tr,table.bordered>thead>tr{border-bottom:1px solid #d0d0d0}table.highlight>tbody>tr{-webkit-transition:background-color .25s ease;transition:background-color .25s ease}table.highlight>tbody>tr:hover{background-color:#f2f2f2}thead{border-bottom:1px solid #d0d0d0}td,th{padding:15px 5px;display:table-cell;text-align:left;vertical-align:middle;border-radius:2px}.left-align{text-align:left}.right-align{text-align:right}.left{float:left!important}.right{float:right!important}@font-face{font-family:Roboto;src:local(Roboto Thin),url(/static/assets/Roboto-Thin.woff2) format("woff2"),url(/static/assets/Roboto-Thin.woff) format("woff");font-weight:100}@font-face{font-family:Roboto;src:local(Roboto Light),url(/static/assets/Roboto-Light.woff2) format("woff2"),url(/static/assets/Roboto-Light.woff) format("woff");font-weight:300}@font-face{font-family:Roboto;src:local(Roboto Regular),url(/static/assets/Roboto-Regular.woff2) format("woff2"),url(/static/assets/Roboto-Regular.woff) format("woff");font-weight:400}@font-face{font-family:Roboto;src:local(Roboto Medium),url(/static/assets/Roboto-Medium.woff2) format("woff2"),url(/static/assets/Roboto-Medium.woff) format("woff");font-weight:500}@font-face{font-family:Roboto;src:local(Roboto Bold),url(/static/assets/Roboto-Bold.woff2) format("woff2"),url(/static/assets/Roboto-Bold.woff) format("woff");font-weight:700}html{line-height:1.5;font-family:Roboto,sans-serif;font-weight:400;color:rgba(0,0,0,.87)}h1,h2,h3,h4,h5,h6{font-weight:400;line-height:1.1}h1{font-size:3rem;margin:1.5rem 0 1.2rem}h1,h2{line-height:110%}h2{font-size:2rem;margin:1rem 0 .8rem}h3{font-size:1.5rem;margin:.75rem 0 .6rem}h3,h4{line-height:110%}h4{font-size:1.3rem;margin:.65rem 0 .52rem}h5{margin:.6rem 0 .48rem}h5,h6{line-height:110%}h6{font-size:1rem;margin:.5rem 0 .4rem}::-webkit-input-placeholder{color:#fff}:-ms-input-placeholder,::-ms-input-placeholder{color:#fff}::placeholder{color:#fff}[type=radio]:checked,[type=radio]:not(:checked){position:absolute;opacity:0;pointer-events:none}[type=radio]:checked+label,[type=radio]:not(:checked)+label{position:relative;padding-left:35px;cursor:pointer;display:inline-block;height:25px;line-height:25px;font-size:1rem;-webkit-transition:.28s ease;transition:.28s ease;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}[type=radio]:checked+label:after,[type=radio]:checked+label:before,[type=radio]:not(:checked)+label:after,[type=radio]:not(:checked)+label:before{border-radius:50%}[type=radio]:not(:checked)+label:after,[type=radio]:not(:checked)+label:before{border:2px solid #5a5a5a}[type=radio]:not(:checked)+label:after{-webkit-transform:scale(0);transform:scale(0)}[type=radio]:checked+label:before{border:2px solid transparent}[type=radio]:checked+label:after{border:2px solid #26a69a}[type=radio]:checked+label:after{background-color:#26a69a}[type=radio]:checked+label:after{-webkit-transform:scale(1.02);transform:scale(1.02)}[type=radio]:disabled:checked+label:before,[type=radio]:disabled:not(:checked)+label:before{background-color:transparent;border-color:rgba(0,0,0,.42)}[type=radio]:disabled+label{color:rgba(0,0,0,.42)}[type=radio]:disabled:not(:checked)+label:before{border-color:rgba(0,0,0,.42)}[type=radio]:disabled:checked+label:after{background-color:rgba(0,0,0,.42);border-color:#949494}[type=checkbox]:checked,[type=checkbox]:not(:checked){position:absolute;opacity:0;pointer-events:none}[type=checkbox]:not(:checked):disabled+label:before{border:none;background-color:rgba(0,0,0,.42)}[type=checkbox]:checked+label:before{top:-4px;left:-5px;width:12px;height:22px;border-top:2px solid transparent;border-left:2px solid transparent;border-right:2px solid #26a69a;border-bottom:2px solid #26a69a;-webkit-transform:rotate(40deg);transform:rotate(40deg);-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform-origin:100% 100%;transform-origin:100% 100%}[type=checkbox]:checked:disabled+label:before{border-right:2px solid rgba(0,0,0,.42);border-bottom:2px solid rgba(0,0,0,.42)}[type=checkbox]:indeterminate+label:before{top:-11px;left:-12px;width:10px;height:22px;border-top:none;border-left:none;border-right:2px solid #26a69a;border-bottom:none;-webkit-transform:rotate(90deg);transform:rotate(90deg);-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform-origin:100% 100%;transform-origin:100% 100%}[type=checkbox]:indeterminate:disabled+label:before{border-right:2px solid rgba(0,0,0,.42);background-color:transparent}h5{font-weight:400;font-size:1.2rem;text-transform:uppercase;padding-top:10px}h6{font-size:13px}.formatted-address{white-space:pre-wrap}.currency{font-size:12px;font-weight:400}.data-table-header{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;height:64px}.data-table td,.data-table th{height:48px;overflow:hidden;padding:0 24px;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap}.data-table td:first-child,.data-table th:first-child{padding-left:24px}.data-table td:last-child,.data-table th:last-child{padding-right:24px}.data-table th{color:#757575;font-weight:400;font-size:12px;height:56px}.data-table tfoot{font-weight:700}.data-table .wide{width:99%}@media print{html{background-color:#fff}.data-table th{color:rgba(0,0,0,.87)}}++ html, body {+ font-size: 12px;+ }++ .order-table {+ margin-bottom: 30px;+ }++ .data-table {+ max-width: 100%;+ width: 100%;+ }++ .data-table tr {+ border-bottom: 1px #d0d0d0 solid;+ }++ .data-table tr:last-child {+ border-bottom: none;+ }++ .data-table td {+ height: 30px;+ padding: 10px;+ }++ header {+ margin-bottom: 5rem;+ }++ #invoice-footer {+ position: fixed;+ bottom: 0;+ width: 100%;+ text-align: center;+ }++ @page {+ @bottom-center {+ content: "Saleor eCommerce, Mirumee Software";+ }+ @bottom-right {+ content: "Page " counter(page) "/" counter(pages);+ }+ }+</style>