From d0b7f79068c7b8bf105ec24ebc55c5dd6ddea9b7 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 5 Feb 2014 20:09:52 +0530 Subject: [PATCH] Fixes in Templates (#421) --- webnotes/__init__.py | 8 ++++ webnotes/cli.py | 3 +- .../doctype/communication/communication.py | 9 ++++ webnotes/hooks.txt | 3 ++ webnotes/patches.txt | 3 +- .../patches/4_0/website_sitemap_hierarchy.py | 22 ++++++++++ webnotes/templates/base.html | 44 ++++++++++--------- webnotes/templates/generators/web_page.html | 6 ++- webnotes/templates/generators/web_page.py | 7 ++- webnotes/templates/includes/blog.js | 38 ++++++++-------- webnotes/templates/includes/login.js | 4 +- webnotes/templates/includes/slideshow.html | 4 +- webnotes/templates/pages/contact.py | 4 +- webnotes/templates/pages/style_settings.css | 26 +++++------ webnotes/templates/pages/style_settings.py | 7 +-- webnotes/utils/install.py | 10 ++++- webnotes/website/css/website.css | 16 +++---- .../website/doctype/web_page/web_page.txt | 9 +++- .../doctype/website_group/website_group.txt | 4 +- .../website_sitemap/website_sitemap.py | 1 + .../website_slideshow/website_slideshow.py | 11 +++-- webnotes/website/js/website.js | 5 +++ webnotes/webutils.py | 35 +++++++-------- 23 files changed, 174 insertions(+), 105 deletions(-) create mode 100644 webnotes/patches/4_0/website_sitemap_hierarchy.py diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 6ffae8fd8a..30faa8dd96 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -533,6 +533,7 @@ def get_jenv(): global jenv if not jenv: from jinja2 import Environment, ChoiceLoader, PackageLoader, DebugUndefined + import webnotes.utils apps = get_installed_apps() apps.remove("webnotes") @@ -543,10 +544,16 @@ def get_jenv(): set_filters(jenv) + jenv.globals.update({ + "webnotes": sys.modules[__name__], + "webnotes.utils": webnotes.utils + }) + return jenv def set_filters(jenv): from webnotes.utils import global_date_format, scrub_relative_url + from webnotes.webutils import get_hex_shade from markdown2 import markdown from json import dumps @@ -554,6 +561,7 @@ def set_filters(jenv): jenv.filters["markdown"] = markdown jenv.filters["json"] = dumps jenv.filters["scrub_relative_url"] = scrub_relative_url + jenv.filters["get_hex_shade"] = get_hex_shade # load jenv_filters from hooks.txt for app in get_all_apps(True): diff --git a/webnotes/cli.py b/webnotes/cli.py index 026b47013a..abe4ae66f5 100755 --- a/webnotes/cli.py +++ b/webnotes/cli.py @@ -237,7 +237,8 @@ def use(): # install @cmd def install(db_name, root_login="root", root_password=None, source_sql=None, - admin_password = 'admin', verbose=True, force=False, site_config=None, reinstall=False): + admin_password = 'admin', verbose=True, force=False, site_config=None, reinstall=False): + print db_name, source_sql from webnotes.installer import install_db, install_app, make_site_dirs install_db(root_login=root_login, root_password=root_password, db_name=db_name, source_sql=source_sql, admin_password = admin_password, verbose=verbose, force=force, site_config=site_config, reinstall=reinstall) diff --git a/webnotes/core/doctype/communication/communication.py b/webnotes/core/doctype/communication/communication.py index 64199c4537..def068ba59 100644 --- a/webnotes/core/doctype/communication/communication.py +++ b/webnotes/core/doctype/communication/communication.py @@ -36,6 +36,15 @@ def make(doctype=None, name=None, content=None, subject=None, sent_or_received = if doctype and name and not webnotes.has_permission(doctype, "email", name): raise webnotes.PermissionError("You are not allowed to send emails related to: {doctype} {name}".format( doctype=doctype, name=name)) + + _send(doctype=doctype, name=name, content=content, subject=subject, sent_or_received=sent_or_received, + sender=sender, recipients=recipients, communication_medium=communication_medium, send_email=send_email, + print_html=print_html, attachments=attachments, send_me_a_copy=send_me_a_copy, set_lead=set_lead, + date=date) + +def _make(doctype=None, name=None, content=None, subject=None, sent_or_received = "Sent", + sender=None, recipients=None, communication_medium="Email", send_email=False, + print_html=None, attachments='[]', send_me_a_copy=False, set_lead=True, date=None): # add to Communication sent_via = None diff --git a/webnotes/hooks.txt b/webnotes/hooks.txt index 7a361a83f6..769619f150 100644 --- a/webnotes/hooks.txt +++ b/webnotes/hooks.txt @@ -6,6 +6,7 @@ app_icon = icon-cog app_version = 4.0.0-wip app_color = #3498db +before_install = webnotes.utils.install.before_install after_install = webnotes.utils.install.after_install # website @@ -14,6 +15,8 @@ app_include_css = assets/webnotes/css/splash.css app_include_css = assets/css/webnotes.css web_include_js = assets/js/webnotes-web.min.js web_include_css = assets/css/webnotes-web.css +web_include_js = website_script.js +web_include_css = style_settings.css website_group_handler:Forum = webnotes.templates.website_group.forum website_group_handler:Events = webnotes.templates.website_group.events diff --git a/webnotes/patches.txt b/webnotes/patches.txt index d8781cab77..1a64ee71fe 100644 --- a/webnotes/patches.txt +++ b/webnotes/patches.txt @@ -9,4 +9,5 @@ execute:webnotes.reload_doc('core', 'doctype', 'report') #2013-13-26 webnotes.patches.4_0.remove_index_sitemap webnotes.patches.4_0.add_delete_permission webnotes.patches.4_0.move_match_to_restricted -webnotes.patches.4_0.set_todo_checked_as_closed \ No newline at end of file +webnotes.patches.4_0.set_todo_checked_as_closed +webnotes.patches.4_0.website_sitemap_hierarchy \ No newline at end of file diff --git a/webnotes/patches/4_0/website_sitemap_hierarchy.py b/webnotes/patches/4_0/website_sitemap_hierarchy.py new file mode 100644 index 0000000000..4fdb32af09 --- /dev/null +++ b/webnotes/patches/4_0/website_sitemap_hierarchy.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# MIT License. See license.txt + +from __future__ import unicode_literals + +import webnotes + +def execute(): + webnotes.reload_doc("website", "doctype", "website_sitemap") + webnotes.reload_doc("website", "doctype", "website_sitemap_permission") + webnotes.reload_doc("website", "doctype", "website_group") + webnotes.reload_doc("website", "doctype", "post") + webnotes.reload_doc("website", "doctype", "user_vote") + + webnotes.conn.sql("""update `tabWebsite Sitemap` ws set ref_doctype=(select wsc.ref_doctype + from `tabWebsite Sitemap Config` wsc where wsc.name=ws.website_sitemap_config) + where ifnull(page_or_generator, '')!='Page'""") + + home_page = webnotes.conn.get_value("Website Settings", "Website Settings", "home_page") + home_page = webnotes.conn.get_value("Website Sitemap", {"docname": home_page}) or home_page + webnotes.conn.set_value("Website Settings", "Website Settings", "home_page", + home_page) diff --git a/webnotes/templates/base.html b/webnotes/templates/base.html index ae39c365b1..e61e5e4d47 100644 --- a/webnotes/templates/base.html +++ b/webnotes/templates/base.html @@ -10,33 +10,32 @@ - {%- block head -%} + {% block head -%} {%- if meta_description is defined -%} {%- endif -%} {%- for link in web_include_js -%} - + {%- endfor -%} {%- for link in web_include_css -%} - + {%- endfor -%} - {%- endblock -%} - - {%- block javascript -%} - {%- if javascript is defined -%} - - {%- endif -%} - {%- endblock -%} - - {%- block css -%} - {%- if css is defined -%} - - {%- endif -%} - {%- endblock -%} + + {% block script -%} + + {%- endblock %} - {%- block style -%}{%- endblock -%} + {% block style -%} + + {%- endblock %} + + {%- endblock %}
@@ -60,12 +59,15 @@
-
- {%- block content -%}{{ content }}{%- endblock -%} -
-
+ +
+ + {%- block content -%}{{ content }}{%- endblock -%} +