-
{{ notification.title }}/{{ notification.id }}
-
-
Description:
-
{{ notification.short_description }}
-
+
{{ notification.title }}/{{ notification.id }}
+
+
Description:
+
{{ notification.short_description }}
+
-
-
- Recipient |
- Sent Status |
- Is Read |
- Created At |
-
-
-
-
- {{ notification.project.email_notification }} |
- {{ notification.sent_status }} |
- {{ notification.is_read }} |
- {{ notification.created_at }} |
-
-
+
+
+ Recipient |
+ Sent Status |
+ Is Read |
+ Created At |
+
+
+
+
+ {{ notification.project.email_notification }} |
+ {{ notification.sent_status }} |
+ {{ notification.is_read }} |
+ {{ notification.created_at }} |
+
+
diff --git a/yuyu/admin/projects_invoice/tables.py b/yuyu/admin/projects_invoice/tables.py
index 26c99e1..ee04031 100644
--- a/yuyu/admin/projects_invoice/tables.py
+++ b/yuyu/admin/projects_invoice/tables.py
@@ -9,7 +9,7 @@ class InvoiceAction(tables.LinkAction):
verbose_name = "Invoice"
def get_link_url(self, datum=None, *args, **kwargs):
- return reverse("horizon:admin:projects_invoice:download_pdf", kwargs={
+ return reverse("horizon:admin:projects_invoice:invoice_detail", kwargs={
"id": datum['id'],
"project_id": datum['project_id'],
})
diff --git a/yuyu/admin/projects_invoice/templates/projects_invoice/base_invoice.html b/yuyu/admin/projects_invoice/templates/projects_invoice/base_invoice.html
new file mode 100644
index 0000000..9d9002e
--- /dev/null
+++ b/yuyu/admin/projects_invoice/templates/projects_invoice/base_invoice.html
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
invoice
+ order #{{ invoice.id }}
+
+
+
+
+
+
+
+ {{ setting.company_name }}
+ {{ setting.company_address }}
+
+
+
+
+ Invoice Month:
+ {{ invoice.start_date|date:"M Y" }}
+
+
+ Invoice State:
+ {{ invoice.state_text }}
+
+
+
+
+
+
ORDER SUMMARY
+
+
+
+ # |
+ COMPONENT |
+ TOTAL COST |
+
+
+
+
+ 1 |
+ Instance |
+ {{ instance_cost }} |
+
+
+ 2 |
+ Volume |
+ {{ volume_cost }} |
+
+
+ 3 |
+ Floating IP |
+ {{ fip_cost }} |
+
+
+ 4 |
+ Router |
+ {{ router_cost }} |
+
+
+ 5 |
+ Snapshot |
+ {{ snapshot_cost }} |
+
+
+ 6 |
+ Image |
+ {{ image_cost }} |
+
+
+ Subtotal |
+ {{ invoice.subtotal_money }} |
+
+ {% if invoice.state != 1 %}
+
+ Tax |
+ {{ invoice.tax_money }} |
+
+
+ Total |
+ {{ invoice.total_money }} |
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/yuyu/admin/projects_invoice/templates/projects_invoice/download_pdf.html b/yuyu/admin/projects_invoice/templates/projects_invoice/download_pdf.html
deleted file mode 100644
index d39dabb..0000000
--- a/yuyu/admin/projects_invoice/templates/projects_invoice/download_pdf.html
+++ /dev/null
@@ -1,123 +0,0 @@
-{% extends 'base.html' %}
-{% block title %}{{ page_title }}{% endblock %}
-{% block main %}
-
- {% if invoice.state == 2 %}
-
Set to Finished
- {% endif %}
-
- {% if invoice.state == 100 %}
-
Rollback to Unpaid
- {% endif %}
-
-
-
-
-
-
- - Invoice Month
- -
-
{{ invoice.start_date|date:"M Y" }}
-
-
-
Invoice State: {{ invoice.state_text }}
-
-
-
-
- Component |
- Total Cost |
-
-
-
-
- Instance |
- {{ instance_cost }} |
-
-
- Volume |
- {{ volume_cost }} |
-
-
- Floating IP |
- {{ fip_cost }} |
-
-
- Router |
- {{ router_cost }} |
-
-
- Snapshot |
- {{ snapshot_cost }} |
-
-
- Image |
- {{ image_cost }} |
-
-
- |
- |
-
-
- |
- Subtotal: {{ invoice.subtotal_money }} |
-
- {% if invoice.state != 1 %}
-
- |
- Tax: {{ invoice.tax_money }} |
-
-
- |
- Total: {{ invoice.total_money }} |
-
- {% endif %}
-
-
-
-{% endblock %}
-{% block js %}
- {{ block.super }}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/yuyu/admin/projects_invoice/templates/projects_invoice/invoice.html b/yuyu/admin/projects_invoice/templates/projects_invoice/invoice.html
new file mode 100644
index 0000000..688a2e9
--- /dev/null
+++ b/yuyu/admin/projects_invoice/templates/projects_invoice/invoice.html
@@ -0,0 +1,32 @@
+{% extends 'base.html' %}
+{% block title %}{{ page_title }}{% endblock %}
+{% block main %}
+
Download PDF
+ {% if invoice.state == 2 %}
+
Set to
+ Finished
+ {% endif %}
+
+ {% if invoice.state == 100 %}
+
Rollback
+ to Unpaid
+ {% endif %}
+
+
+ {% include 'admin/projects_invoice/base_invoice.html' %}
+{% endblock %}
+{% block js %}
+ {{ block.super }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/yuyu/admin/projects_invoice/templates/projects_invoice/invoice_download.html b/yuyu/admin/projects_invoice/templates/projects_invoice/invoice_download.html
new file mode 100644
index 0000000..9881e14
--- /dev/null
+++ b/yuyu/admin/projects_invoice/templates/projects_invoice/invoice_download.html
@@ -0,0 +1,13 @@
+
+
+
Invoice Download
+ {% include "_stylesheets.html" %}
+
+
+{% include 'admin/projects_invoice/base_invoice.html' %}
+{% include "horizon/_scripts.html" %}
+
+
+
\ No newline at end of file
diff --git a/yuyu/admin/projects_invoice/urls.py b/yuyu/admin/projects_invoice/urls.py
index 4737770..13ea78d 100644
--- a/yuyu/admin/projects_invoice/urls.py
+++ b/yuyu/admin/projects_invoice/urls.py
@@ -16,7 +16,7 @@ from openstack_dashboard.dashboards.yuyu.admin.projects_invoice import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
- url(r'^invoice/pdf/(?P
[^/]+)/(?P[^/]+)/$', views.InvoiceView.as_view(), name='download_pdf'),
+ url(r'^invoice/detail/(?P[^/]+)/(?P[^/]+)/$', views.InvoiceView.as_view(), name='invoice_detail'),
url(r'^invoice/usage/(?P[^/]+)/(?P[^/]+)/$', views.UsageCostView.as_view(), name='usage_cost'),
url(r'^invoice/finish/(?P[^/]+)/$', views.FinishInvoice.as_view(), name='finish_invoice'),
url(r'^invoice/rollback_to_unpaid/(?P[^/]+)/$', views.RollbackToUnpaidInvoice.as_view(),
diff --git a/yuyu/admin/projects_invoice/views.py b/yuyu/admin/projects_invoice/views.py
index 74ba12e..a50d519 100644
--- a/yuyu/admin/projects_invoice/views.py
+++ b/yuyu/admin/projects_invoice/views.py
@@ -27,6 +27,7 @@ from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.yuyu.cases.invoice_use_case import InvoiceUseCase
from .tables import InvoiceTable
+from ...cases.setting_use_case import SettingUseCase
from ...core.usage_cost.tables import InstanceCostTable, VolumeCostTable, FloatingIpCostTable, RouterCostTable, \
SnapshotCostTable, ImageCostTable
from ...core.utils.invoice_utils import state_to_text
@@ -67,14 +68,21 @@ class IndexView(tables.DataTableView):
class InvoiceView(views.APIView):
page_title = _("Invoice")
- template_name = "admin/projects_invoice/download_pdf.html"
invoice_uc = InvoiceUseCase()
+ setting_uc = SettingUseCase()
+
+ def get_template_names(self):
+ if self.request.GET.get('print', None):
+ return ['admin/projects_invoice/invoice_download.html']
+ else:
+ return ['admin/projects_invoice/invoice.html']
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
invoice = self.invoice_uc.get_invoice(self.request, self.kwargs['id'], tenant_id=self.kwargs['project_id'])
context['invoice'] = invoice
+ context['setting'] = self.setting_uc.get_settings(self.request)
context['instance_cost'] = self.get_sum_price(invoice, 'instances')
context['volume_cost'] = self.get_sum_price(invoice, 'volumes')
context['fip_cost'] = self.get_sum_price(invoice, 'floating_ips')
diff --git a/yuyu/project/invoice/tables.py b/yuyu/project/invoice/tables.py
index 18f0f39..666817a 100644
--- a/yuyu/project/invoice/tables.py
+++ b/yuyu/project/invoice/tables.py
@@ -10,7 +10,7 @@ class DetailAction(tables.LinkAction):
def get_link_url(self, datum=None, *args, **kwargs):
print(datum, args, kwargs)
- return reverse("horizon:project:invoice:download_pdf", kwargs={"id": datum['id']})
+ return reverse("horizon:project:invoice:invoice_detail", kwargs={"id": datum['id']})
class InvoiceTable(tables.DataTable):
diff --git a/yuyu/project/invoice/templates/invoice/base_invoice.html b/yuyu/project/invoice/templates/invoice/base_invoice.html
new file mode 100644
index 0000000..9d9002e
--- /dev/null
+++ b/yuyu/project/invoice/templates/invoice/base_invoice.html
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
invoice
+ order #{{ invoice.id }}
+
+
+
+
+
+
+
+ {{ setting.company_name }}
+ {{ setting.company_address }}
+
+
+
+
+ Invoice Month:
+ {{ invoice.start_date|date:"M Y" }}
+
+
+ Invoice State:
+ {{ invoice.state_text }}
+
+
+
+
+
+
ORDER SUMMARY
+
+
+
+ # |
+ COMPONENT |
+ TOTAL COST |
+
+
+
+
+ 1 |
+ Instance |
+ {{ instance_cost }} |
+
+
+ 2 |
+ Volume |
+ {{ volume_cost }} |
+
+
+ 3 |
+ Floating IP |
+ {{ fip_cost }} |
+
+
+ 4 |
+ Router |
+ {{ router_cost }} |
+
+
+ 5 |
+ Snapshot |
+ {{ snapshot_cost }} |
+
+
+ 6 |
+ Image |
+ {{ image_cost }} |
+
+
+ Subtotal |
+ {{ invoice.subtotal_money }} |
+
+ {% if invoice.state != 1 %}
+
+ Tax |
+ {{ invoice.tax_money }} |
+
+
+ Total |
+ {{ invoice.total_money }} |
+
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/yuyu/project/invoice/templates/invoice/download_pdf.html b/yuyu/project/invoice/templates/invoice/download_pdf.html
deleted file mode 100644
index ee6ee2e..0000000
--- a/yuyu/project/invoice/templates/invoice/download_pdf.html
+++ /dev/null
@@ -1,116 +0,0 @@
-{% extends 'base.html' %}
-{% block title %}{{ page_title }}{% endblock %}
-{% block main %}
-
-
-
-
-
-
-
- - Invoice Month
- -
-
{{ invoice.start_date|date:"M Y" }}
-
-
-
Invoice State: {{ invoice.state_text }}
-
-
-
-
- Component |
- Total Cost |
-
-
-
-
- Instance |
- {{ instance_cost }} |
-
-
- Volume |
- {{ volume_cost }} |
-
-
- Floating IP |
- {{ fip_cost }} |
-
-
- Router |
- {{ router_cost }} |
-
-
- Snapshot |
- {{ snapshot_cost }} |
-
-
- Image |
- {{ image_cost }} |
-
-
- |
- |
-
-
- |
- Subtotal: {{ invoice.subtotal_money }} |
-
- {% if invoice.state != 1 %}
-
- |
- Tax: {{ invoice.tax_money }} |
-
-
- |
- Total: {{ invoice.total_money }} |
-
- {% endif %}
-
-
-
-{% endblock %}
-{% block js %}
- {{ block.super }}
-
-
-{% endblock %}
\ No newline at end of file
diff --git a/yuyu/project/invoice/templates/invoice/invoice.html b/yuyu/project/invoice/templates/invoice/invoice.html
new file mode 100644
index 0000000..4b70a81
--- /dev/null
+++ b/yuyu/project/invoice/templates/invoice/invoice.html
@@ -0,0 +1,21 @@
+{% extends 'base.html' %}
+{% block title %}{{ page_title }}{% endblock %}
+{% block main %}
+ Download PDF
+
+
+ {% include 'admin/projects_invoice/base_invoice.html' %}
+{% endblock %}
+{% block js %}
+ {{ block.super }}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/yuyu/project/invoice/templates/invoice/invoice_download.html b/yuyu/project/invoice/templates/invoice/invoice_download.html
new file mode 100644
index 0000000..cadcbab
--- /dev/null
+++ b/yuyu/project/invoice/templates/invoice/invoice_download.html
@@ -0,0 +1,13 @@
+
+
+ Invoice Download
+ {% include "_stylesheets.html" %}
+
+
+{% include 'project/invoice/base_invoice.html' %}
+{% include "horizon/_scripts.html" %}
+
+
+
\ No newline at end of file
diff --git a/yuyu/project/invoice/urls.py b/yuyu/project/invoice/urls.py
index ae2dfdf..c5d703a 100644
--- a/yuyu/project/invoice/urls.py
+++ b/yuyu/project/invoice/urls.py
@@ -17,5 +17,5 @@ from openstack_dashboard.dashboards.yuyu.project.invoice import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
- url(r'^invoice/pdf/(?P[^/]+)/$', views.InvoiceView.as_view(), name='download_pdf'),
+ url(r'^invoice/detail/(?P[^/]+)/$', views.InvoiceView.as_view(), name='invoice_detail'),
]
diff --git a/yuyu/project/invoice/views.py b/yuyu/project/invoice/views.py
index 425b92c..ce27b5d 100644
--- a/yuyu/project/invoice/views.py
+++ b/yuyu/project/invoice/views.py
@@ -25,6 +25,7 @@ from horizon import views
from openstack_dashboard import api
from openstack_dashboard.dashboards.yuyu.cases.invoice_use_case import InvoiceUseCase
from .tables import InvoiceTable
+from ...cases.setting_use_case import SettingUseCase
from ...core.utils.invoice_utils import state_to_text
@@ -55,15 +56,22 @@ class IndexView(tables.DataTableView):
class InvoiceView(views.APIView):
page_title = _("Invoice")
- template_name = "project/invoice/download_pdf.html"
invoice_uc = InvoiceUseCase()
+ setting_uc = SettingUseCase()
+
+ def get_template_names(self):
+ if self.request.GET.get('print', None):
+ return ['project/invoice/invoice_download.html']
+ else:
+ return ['project/invoice/invoice.html']
+
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
invoice = self.invoice_uc.get_invoice(self.request, self.kwargs['id'])
context['invoice'] = invoice
-
+ context['setting'] = self.setting_uc.get_settings(self.request)
context['instance_cost'] = self.get_sum_price(invoice, 'instances')
context['volume_cost'] = self.get_sum_price(invoice, 'volumes')
context['fip_cost'] = self.get_sum_price(invoice, 'floating_ips')