diff --git a/patches/september_2013/p03_move_website_to_framework.py b/patches/september_2013/p03_move_website_to_framework.py index 4aac892d4b..cbfed7c178 100644 --- a/patches/september_2013/p03_move_website_to_framework.py +++ b/patches/september_2013/p03_move_website_to_framework.py @@ -10,7 +10,6 @@ def execute(): # remove pyc files utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc") if os.path.exists(utils_pyc): - print exists os.remove(utils_pyc) shutil.rmtree(os.path.join(get_base_path(), "app", "website")) diff --git a/portal/__init__.py b/portal/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/__init__.py b/portal/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/base.html b/portal/templates/base.html index 701d86c4cc..cdbc045848 100644 --- a/portal/templates/base.html +++ b/portal/templates/base.html @@ -1,20 +1,22 @@ {% extends "lib/website/templates/base.html" %} {% block toolbar %} -
- {% if shopping_cart_enabled -%} - - | - {%- endif %} - Login -
-
- | - {% if shopping_cart_enabled -%} - - | - {%- endif %} - +
+
+ {% if shopping_cart_enabled -%} + + | + {%- endif %} + Login +
+
+ | + {% if shopping_cart_enabled -%} + + | + {%- endif %} + +
{% endblock %} diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html index 1e61124337..23d5f812ea 100644 --- a/portal/templates/includes/transactions.html +++ b/portal/templates/includes/transactions.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block content -%}
@@ -19,6 +19,7 @@ {%- endblock %} {% block javascript -%} + -// var render = function(doc) { }; - + {% endblock %} \ No newline at end of file diff --git a/portal/templates/invoice.html b/portal/templates/invoice.html deleted file mode 100644 index 26ddea43d2..0000000000 --- a/portal/templates/invoice.html +++ /dev/null @@ -1,88 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% set title=doc.name %} - -{% block content %} -
- -

{{ doc.name }}

-
- {%- if doc.status -%} -
-
-
-
{{ doc.status }}
-
-
- {{ utils.formatdate(doc.transaction_date) }} -
-
-
-
-
- - - - - - - - - - - - {%- for row in doclist.get({"doctype":"Sales Order Item"}) %} - - - - - - - - - - {% endfor -%} - -
SrItem NameDescriptionQtyUoMBasic RateAmount
{{ row.idx }}{{ row.item_name }}{{ row.description }}{{ row.qty }}{{ row.stock_uom }}{{ utils.fmt_money(row.export_rate, currency=doc.currency) }}{{ utils.fmt_money(row.export_amount, currency=doc.currency) }}
-
-
-
-
-
- - - - - - - {%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%} - {%- if not charge.included_in_print_rate -%} - - - - - {%- endif -%} - {%- endfor -%} - - - - - - - - - -
Net Total{{ - utils.fmt_money(doc.net_total/doc.conversion_rate, currency=doc.currency) - }}
{{ charge.description }}{{ utils.fmt_money(charge.tax_amount / doc.conversion_rate, currency=doc.currency) }}
Grand Total{{ utils.fmt_money(doc.grand_total_export, currency=doc.currency) }}
Rounded Total{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}
-
-
-
- {%- endif -%} -
-{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/__init__.py b/portal/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/account.html b/portal/templates/pages/account.html similarity index 95% rename from portal/templates/account.html rename to portal/templates/pages/account.html index 2a5acf67e3..da43dd24fa 100644 --- a/portal/templates/account.html +++ b/portal/templates/pages/account.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Account" %} diff --git a/portal/templates/cart.html b/portal/templates/pages/cart.html similarity index 97% rename from portal/templates/cart.html rename to portal/templates/pages/cart.html index 6708ad342b..372f5241b0 100644 --- a/portal/templates/cart.html +++ b/portal/templates/pages/cart.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block javascript %} {% include "app/website/templates/js/cart.js" %} diff --git a/portal/templates/pages/invoice.html b/portal/templates/pages/invoice.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/invoice.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/invoice.py b/portal/templates/pages/invoice.py new file mode 100644 index 0000000000..ed6e40a6e5 --- /dev/null +++ b/portal/templates/pages/invoice.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) + context.update({ + "parent_link": "invoices", + "parent_title": "Invoices" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/invoices.html b/portal/templates/pages/invoices.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/invoices.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/invoices.py b/portal/templates/pages/invoices.py new file mode 100644 index 0000000000..2bb6490903 --- /dev/null +++ b/portal/templates/pages/invoices.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "Invoices", + "method": "portal.templates.pages.invoices.get_invoices", + "icon": "icon-file-text", + "empty_list_message": "No Invoices Found", + "page": "invoice" + }) + return context + +@webnotes.whitelist() +def get_invoices(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Sales Invoice", start) \ No newline at end of file diff --git a/portal/templates/pages/order.html b/portal/templates/pages/order.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/order.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/order.py b/portal/templates/pages/order.py new file mode 100644 index 0000000000..47e2c68d82 --- /dev/null +++ b/portal/templates/pages/order.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Sales Order", webnotes.form_dict.name) + context.update({ + "parent_link": "orders", + "parent_title": "My Orders" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/orders.html b/portal/templates/pages/orders.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/orders.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/orders.py b/portal/templates/pages/orders.py new file mode 100644 index 0000000000..3c62d35b24 --- /dev/null +++ b/portal/templates/pages/orders.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "My Orders", + "method": "portal.templates.pages.orders.get_orders", + "icon": "icon-list", + "empty_list_message": "No Orders Yet", + "page": "order", + }) + return context + +@webnotes.whitelist() +def get_orders(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Sales Order", start) + \ No newline at end of file diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html new file mode 100644 index 0000000000..2fe03ba911 --- /dev/null +++ b/portal/templates/pages/profile.html @@ -0,0 +1,61 @@ +{% extends base_template %} + +{% set title="My Profile" %} + +{% block content %} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/shipment.html b/portal/templates/pages/shipment.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/shipment.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/shipment.py b/portal/templates/pages/shipment.py new file mode 100644 index 0000000000..5d9d1d1435 --- /dev/null +++ b/portal/templates/pages/shipment.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Delivery Note", webnotes.form_dict.name) + context.update({ + "parent_link": "shipments", + "parent_title": "Shipments" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/shipments.html b/portal/templates/pages/shipments.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/shipments.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/shipments.py b/portal/templates/pages/shipments.py new file mode 100644 index 0000000000..4847b9f2e3 --- /dev/null +++ b/portal/templates/pages/shipments.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "Shipments", + "method": "portal.templates.pages.shipments.get_shipments", + "icon": "icon-truck", + "empty_list_message": "No Shipments Found", + "page": "shipment" + }) + return context + +@webnotes.whitelist() +def get_shipments(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Delivery Note", start) diff --git a/portal/templates/profile.html b/portal/templates/profile.html index 4c03b400b9..e8e60b4cf6 100644 --- a/portal/templates/profile.html +++ b/portal/templates/profile.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Profile" %} @@ -9,7 +9,7 @@
  • My Account
  • My Profile
  • - +
    diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 1c03da261a..3a49684863 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc.name %} diff --git a/portal/templates/sales_transactions.html b/portal/templates/sales_transactions.html index 7215339c0d..10139c398b 100644 --- a/portal/templates/sales_transactions.html +++ b/portal/templates/sales_transactions.html @@ -1,25 +1,28 @@ -{% extends "app/website/templates/html/transactions.html" %} +{% extends "app/portal/templates/includes/transactions.html" %} {% block javascript -%} -global_number_format = "{{ global_number_format }}"; -currency = "{{ currency }}"; -wn.currency_symbols = {{ currency_symbols }}; + {{ super() }} -var render = function(doc) { - doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency); + {%- endblock %} \ No newline at end of file diff --git a/portal/templates/transaction_list.html b/portal/templates/transaction_list.html deleted file mode 100644 index 967a6a8324..0000000000 --- a/portal/templates/transaction_list.html +++ /dev/null @@ -1,77 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block content %} -
    - -
    -
    -
    -
    -
    -
    -
    -
    -{% endblock %} - -{% block javascript %} -global_number_format = "{{ global_number_format }}"; -currency = "{{ currency }}"; -wn.currency_symbols = {{ currency_symbols }}; - -$(document).ready(function() { - var start = 0; - var $list = $(".transaction-list"); - - var $show_more = $(".btn-show-more").on("click", function() { - get_transactions(this); - }); - - var get_transactions = function(btn) { - wn.call({ - method: "{{ method }}", - args: { start: start }, - btn: btn, - callback: function(r) { - $list.find(".progress").remove(); - $show_more.toggle(!(r.message && r.message.length===20)); - - if(!(r.message && r.message.length)) { - console.log("empty"); - if(!$list.html().trim()) { - $list.html("
    \ - {{ empty_list_message }}
    "); - } - return; - } - - start += r.message.length; - - $.each(r.message, function(i, doc) { - render(doc); - }); - } - }) - }; - - var render = function(doc) { - doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency); - - var $row = $(repl('\ -
    \ -
    \ -
    %(name)s
    \ -
    %(items)s...
    \ -
    \ -
    %(grand_total_export)s
    \ -
    %(creation)s
    \ -
    \ -
    ', doc)).appendTo($list); - }; - - get_transactions(); -}); -{% endblock %} \ No newline at end of file diff --git a/portal/website_transactions.py b/portal/website_transactions.py new file mode 100644 index 0000000000..21e9111254 --- /dev/null +++ b/portal/website_transactions.py @@ -0,0 +1,50 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint, formatdate +import json + +def get_transaction_list(doctype, start): + # find customer id + customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, + "customer") + + if customer: + transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export + from `tab%s` where customer=%s and docstatus=1 + order by creation desc + limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True) + for doc in transactions: + doc.items = ", ".join(webnotes.conn.sql_list("""select item_name + from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name)) + doc.creation = formatdate(doc.creation) + return transactions + else: + return [] + +def get_currency_context(): + return { + "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", + "currency": webnotes.conn.get_default("currency"), + "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol + from tabCurrency where ifnull(enabled,0)=1"""))) + } + +def get_transaction_context(doctype, name): + customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, + "customer") + + bean = webnotes.bean(doctype, name) + if bean.doc.customer != customer: + return { + "doc": {"name": "Not Allowed"} + } + else: + return { + "doc": bean.doc, + "doclist": bean.doclist, + "webnotes": webnotes, + "utils": webnotes.utils + } \ No newline at end of file diff --git a/public/build.json b/public/build.json index b8d7dd4452..77ad4dd76d 100644 --- a/public/build.json +++ b/public/build.json @@ -1,7 +1,6 @@ { "public/css/all-web.css": [ "app/public/js/startup.css", - "app/website/css/website.css" ], "public/css/all-app.css": [ "app/public/js/startup.css" diff --git a/stock/doctype/item/templates/includes/product_search_box.html b/stock/doctype/item/templates/includes/product_search_box.html index d808bf6144..b4fa3e8783 100644 --- a/stock/doctype/item/templates/includes/product_search_box.html +++ b/stock/doctype/item/templates/includes/product_search_box.html @@ -1,4 +1,4 @@ -
    +
    diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 5c38cc1a78..2cbd65e744 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -72,18 +72,4 @@ class DocType(TransactionBase): def set_status(name, status): st = webnotes.bean("Support Ticket", name) st.doc.status = status - st.save() - -def get_website_args(): - bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) - if bean.doc.raised_by != webnotes.session.user: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } + st.save() \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/__init__.py b/support/doctype/support_ticket/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/doctype/support_ticket/templates/pages/__init__.py b/support/doctype/support_ticket/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/doctype/support_ticket/templates/ticket.html b/support/doctype/support_ticket/templates/pages/ticket.html similarity index 97% rename from support/doctype/support_ticket/templates/ticket.html rename to support/doctype/support_ticket/templates/pages/ticket.html index 6622ed1589..1cfab9b00f 100644 --- a/support/doctype/support_ticket/templates/ticket.html +++ b/support/doctype/support_ticket/templates/pages/ticket.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc.name %} diff --git a/support/doctype/support_ticket/templates/pages/ticket.py b/support/doctype/support_ticket/templates/pages/ticket.py new file mode 100644 index 0000000000..2227a6a5cb --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/ticket.py @@ -0,0 +1,19 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) + if bean.doc.raised_by != webnotes.session.user: + return { + "doc": {"name": "Not Allowed"} + } + else: + return { + "doc": bean.doc, + "doclist": bean.doclist, + "webnotes": webnotes, + "utils": webnotes.utils + } diff --git a/support/doctype/support_ticket/templates/pages/tickets.html b/support/doctype/support_ticket/templates/pages/tickets.html new file mode 100644 index 0000000000..d3e316c5de --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/tickets.html @@ -0,0 +1,33 @@ +{% extends "app/portal/templates/includes/transactions.html" %} + +{% block javascript -%} +{{ super() }} + + +{%- endblock %} \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/pages/tickets.py b/support/doctype/support_ticket/templates/pages/tickets.py new file mode 100644 index 0000000000..21892a1cae --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/tickets.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint, formatdate + +def get_context(): + return { + "title": "My Tickets", + "method": "support.doctype.support_ticket.templates.pages.tickets.get_tickets", + "icon": "icon-ticket", + "empty_list_message": "No Tickets Raised", + "page": "ticket" + } + +@webnotes.whitelist() +def get_tickets(start=0): + tickets = webnotes.conn.sql("""select name, subject, status, creation + from `tabSupport Ticket` where raised_by=%s + order by modified desc + limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True) + for t in tickets: + t.creation = formatdate(t.creation) + + return tickets \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/tickets.html b/support/doctype/support_ticket/templates/tickets.html deleted file mode 100644 index 166dbcd4d4..0000000000 --- a/support/doctype/support_ticket/templates/tickets.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "app/website/templates/html/transactions.html" %} - -{% block javascript -%} -{{ super() }} - -var status_label = { - "Open": "label-success", - "Waiting for Customer": "label-danger", - "Closed": "label-default" -} - -var render = function(doc) { - doc.status = doc.status.trim(); - doc.label_class = status_label[doc.status] || "label-default"; - if(doc.status==="Waiting for Customer") doc.status = "To Reply"; - - $(repl('\ -
    \ -
    \ - %(status)s
    \ -
    \ -
    %(name)s
    \ -
    %(subject)s
    \ -
    \ -
    \ - %(creation)s\ -
    \ -
    \ -
    ', doc)).appendTo($list); -}; -{%- endblock %} \ No newline at end of file diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index 7ffb911417..69e81b8312 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -51,25 +51,3 @@ class DocType: webnotes.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" % (is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name)) break - -def get_website_args(): - def _get_fields(fieldnames): - return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], - [df.label, df.fieldname, df.fieldtype, df.options])) - for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] - - bean = None - if webnotes.form_dict.name: - bean = webnotes.bean("Address", webnotes.form_dict.name) - - return { - "doc": bean.doc if bean else None, - "meta": webnotes._dict({ - "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", - "city", "state", "pincode", "country"]), - "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", - "is_shipping_address"]) - }), - "cint": cint - } - diff --git a/utilities/doctype/address/templates/__init__.py b/utilities/doctype/address/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/address/templates/pages/__init__.py b/utilities/doctype/address/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/address/templates/address.html b/utilities/doctype/address/templates/pages/address.html similarity index 98% rename from utilities/doctype/address/templates/address.html rename to utilities/doctype/address/templates/pages/address.html index 6d4273c3a5..63c3748f2a 100644 --- a/utilities/doctype/address/templates/address.html +++ b/utilities/doctype/address/templates/pages/address.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc and doc.name or "New Address" %} {% set docname=(doc and doc.name or "") %} diff --git a/utilities/doctype/address/templates/pages/address.py b/utilities/doctype/address/templates/pages/address.py new file mode 100644 index 0000000000..d87974d0d8 --- /dev/null +++ b/utilities/doctype/address/templates/pages/address.py @@ -0,0 +1,28 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint + +def get_context(): + def _get_fields(fieldnames): + return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], + [df.label, df.fieldname, df.fieldtype, df.options])) + for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] + + bean = None + if webnotes.form_dict.name: + bean = webnotes.bean("Address", webnotes.form_dict.name) + + return { + "doc": bean.doc if bean else None, + "meta": webnotes._dict({ + "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", + "city", "state", "pincode", "country"]), + "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", + "is_shipping_address"]) + }), + "cint": cint + } + diff --git a/utilities/doctype/address/templates/addresses.html b/utilities/doctype/address/templates/pages/addresses.html similarity index 96% rename from utilities/doctype/address/templates/addresses.html rename to utilities/doctype/address/templates/pages/addresses.html index b19780ae38..e3a5b683d7 100644 --- a/utilities/doctype/address/templates/addresses.html +++ b/utilities/doctype/address/templates/pages/addresses.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Addresses" %} diff --git a/utilities/website_transactions.py b/utilities/website_transactions.py deleted file mode 100644 index f8710968fb..0000000000 --- a/utilities/website_transactions.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes.utils import cint, formatdate -import json - -def get_transaction_list(doctype, start): - # find customer id - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - if customer: - transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export - from `tab%s` where customer=%s and docstatus=1 - order by creation desc - limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True) - for doc in transactions: - doc.items = ", ".join(webnotes.conn.sql_list("""select item_name - from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name)) - doc.creation = formatdate(doc.creation) - return transactions - else: - return [] - -def get_common_args(): - return { - "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", - "currency": webnotes.conn.get_default("currency"), - "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol - from tabCurrency where ifnull(enabled,0)=1"""))) - } - -@webnotes.whitelist() -def get_orders(start=0): - return get_transaction_list("Sales Order", start) - -def order_list_args(): - args = get_common_args() - args.update({ - "title": "My Orders", - "method": "utilities.website_transactions.get_orders", - "icon": "icon-list", - "empty_list_message": "No Orders Yet", - "page": "order", - }) - return args - -@webnotes.whitelist() -def get_invoices(start=0): - return get_transaction_list("Sales Invoice", start) - -def invoice_list_args(): - args = get_common_args() - args.update({ - "title": "Invoices", - "method": "utilities.website_transactions.get_invoices", - "icon": "icon-file-text", - "empty_list_message": "No Invoices Found", - "page": "invoice" - }) - return args - -@webnotes.whitelist() -def get_shipments(start=0): - return get_transaction_list("Delivery Note", start) - -def shipment_list_args(): - args = get_common_args() - args.update({ - "title": "Shipments", - "method": "utilities.website_transactions.get_shipments", - "icon": "icon-truck", - "empty_list_message": "No Shipments Found", - "page": "shipment" - }) - return args - -@webnotes.whitelist() -def get_tickets(start=0): - tickets = webnotes.conn.sql("""select name, subject, status, creation - from `tabSupport Ticket` where raised_by=%s - order by modified desc - limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True) - for t in tickets: - t.creation = formatdate(t.creation) - - return tickets - -def ticket_list_args(): - return { - "title": "My Tickets", - "method": "utilities.website_transactions.get_tickets", - "icon": "icon-ticket", - "empty_list_message": "No Tickets Raised", - "page": "ticket" - } - -def get_transaction_args(doctype, name): - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - bean = webnotes.bean(doctype, name) - if bean.doc.customer != customer: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } - -def get_order_args(): - args = get_transaction_args("Sales Order", webnotes.form_dict.name) - args.update({ - "parent_link": "orders", - "parent_title": "My Orders" - }) - return args - -def get_invoice_args(): - args = get_transaction_args("Sales Invoice", webnotes.form_dict.name) - args.update({ - "parent_link": "invoices", - "parent_title": "Invoices" - }) - return args - -def get_shipment_args(): - args = get_transaction_args("Delivery Note", webnotes.form_dict.name) - args.update({ - "parent_link": "shipments", - "parent_title": "Shipments" - }) - return args