Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py
index ae0f217..243bbdd 100644
--- a/utilities/doctype/address/address.py
+++ b/utilities/doctype/address/address.py
@@ -25,23 +25,19 @@
self.doclist = doclist
def autoname(self):
- if self.doc.customer:
- self.doc.name = self.doc.customer + '-' + self.doc.address_type
- elif self.doc.supplier:
- self.doc.name = self.doc.supplier + '-' + self.doc.address_type
- elif self.doc.sales_partner:
- self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type
- elif self.doc.address_title:
- self.doc.address_title = self.doc.address_title + "-" + self.doc.address_type
+ if not self.doc.address_title:
+ self.doc.address_title = self.doc.customer or self.doc.supplier or self.doc.sales_partner
+
+ if self.doc.address_title:
+ self.doc.name = self.doc.address_title + "-" + self.doc.address_type
+
+ else:
+ webnotes.msgprint("""Address Title is mandatory.""", raise_exception=True)
+
def validate(self):
- self.validate_for_whom()
self.validate_primary_address()
self.validate_shipping_address()
-
- def validate_for_whom(self):
- if not (self.doc.customer or self.doc.supplier or self.doc.sales_partner):
- msgprint("Please enter value in atleast one of customer, supplier and sales partner field", raise_exception=1)
def validate_primary_address(self):
"""Validate that there can only be one primary address for particular customer, supplier"""
diff --git a/utilities/doctype/address/address.txt b/utilities/doctype/address/address.txt
index f77f397..8ab6431 100644
--- a/utilities/doctype/address/address.txt
+++ b/utilities/doctype/address/address.txt
@@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:30:41",
"modified_by": "Administrator",
- "modified": "2012-12-27 11:31:37"
+ "modified": "2012-12-27 18:08:55"
},
{
"name": "__common__",
@@ -55,6 +55,7 @@
"label": "Address Title",
"fieldname": "address_title",
"fieldtype": "Data",
+ "reqd": 1,
"permlevel": 0
},
{
@@ -218,60 +219,6 @@
"create": 1,
"doctype": "DocPerm",
"write": 1,
- "role": "System Manager",
- "cancel": 1,
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Sales Master Manager",
- "cancel": 1,
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Purchase Master Manager",
- "cancel": 1,
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Maintenance Manager",
- "cancel": 0,
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Accounts Manager",
- "cancel": 0,
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Sales Manager",
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
- "role": "Purchase Manager",
- "permlevel": 0
- },
- {
- "create": 1,
- "doctype": "DocPerm",
- "write": 1,
"role": "Sales User",
"permlevel": 0
},
diff --git a/website/doctype/about_us_settings/about_us_settings.txt b/website/doctype/about_us_settings/about_us_settings.txt
index 9facfbb..e0c1d4c 100644
--- a/website/doctype/about_us_settings/about_us_settings.txt
+++ b/website/doctype/about_us_settings/about_us_settings.txt
@@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-12-27 14:24:35",
"modified_by": "Administrator",
- "modified": "2012-12-27 15:51:11"
+ "modified": "2012-12-27 17:44:55"
},
{
"issingle": 1,
@@ -39,6 +39,13 @@
"doctype": "DocType"
},
{
+ "doctype": "DocField",
+ "label": "Help",
+ "fieldname": "help",
+ "fieldtype": "HTML",
+ "options": "<div class=\"alert\">Link for About Us Page is \"about.html\"</div>"
+ },
+ {
"description": "Introduce your company to the website visitor.",
"doctype": "DocField",
"label": "Company Introduction",
diff --git a/website/doctype/contact_us_settings/__init__.py b/website/doctype/contact_us_settings/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/website/doctype/contact_us_settings/__init__.py
diff --git a/website/doctype/contact_us_settings/contact_us_settings.py b/website/doctype/contact_us_settings/contact_us_settings.py
new file mode 100644
index 0000000..0d2625a
--- /dev/null
+++ b/website/doctype/contact_us_settings/contact_us_settings.py
@@ -0,0 +1,17 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
+
+ def onload(self):
+ """load address"""
+ if self.doc.query_options:
+ self.doc.query_options = filter(None, self.doc.query_options.replace(",", "\n").split())
+ else:
+ self.doc.query_options = ["Sales", "Support", "General"]
+ if self.doc.address:
+ self.address = webnotes.model_wrapper("Address", self.doc.address).doc
\ No newline at end of file
diff --git a/website/doctype/contact_us_settings/contact_us_settings.txt b/website/doctype/contact_us_settings/contact_us_settings.txt
new file mode 100644
index 0000000..cdad57a
--- /dev/null
+++ b/website/doctype/contact_us_settings/contact_us_settings.txt
@@ -0,0 +1,72 @@
+[
+ {
+ "owner": "Administrator",
+ "docstatus": 0,
+ "creation": "2012-12-27 17:43:10",
+ "modified_by": "Administrator",
+ "modified": "2012-12-27 17:57:55"
+ },
+ {
+ "issingle": 1,
+ "description": "Settings for Contact Us Page",
+ "doctype": "DocType",
+ "module": "Website",
+ "name": "__common__"
+ },
+ {
+ "name": "__common__",
+ "parent": "Contact Us Settings",
+ "doctype": "DocField",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "parentfield": "fields"
+ },
+ {
+ "parent": "Contact Us Settings",
+ "read": 1,
+ "name": "__common__",
+ "create": 1,
+ "doctype": "DocPerm",
+ "write": 1,
+ "parenttype": "DocType",
+ "role": "Website Manager",
+ "permlevel": 0,
+ "parentfield": "permissions"
+ },
+ {
+ "name": "Contact Us Settings",
+ "doctype": "DocType"
+ },
+ {
+ "doctype": "DocField",
+ "label": "Help",
+ "fieldname": "help",
+ "fieldtype": "HTML",
+ "options": "<div class=\"alert\">Link for Contact Page is \"contact.html\"</div>"
+ },
+ {
+ "description": "Address to be displayed on the Contact Page",
+ "doctype": "DocField",
+ "label": "Address",
+ "fieldname": "address",
+ "fieldtype": "Link",
+ "options": "Address"
+ },
+ {
+ "description": "Contact options, like \"Sales Query, Support Query\" etc each on a new line or separated by commas.",
+ "doctype": "DocField",
+ "label": "Query Options",
+ "fieldname": "query_options",
+ "fieldtype": "Small Text"
+ },
+ {
+ "description": "Introductory information for the Contact Us Page",
+ "doctype": "DocField",
+ "label": "Introduction",
+ "fieldname": "introduction",
+ "fieldtype": "Text Editor"
+ },
+ {
+ "doctype": "DocPerm"
+ }
+]
\ No newline at end of file
diff --git a/website/page/website_home/website_home.html b/website/page/website_home/website_home.html
index e4c86b0..0fde113 100644
--- a/website/page/website_home/website_home.html
+++ b/website/page/website_home/website_home.html
@@ -6,7 +6,7 @@
<p class="help">Static (content) web page.</p>
<br>
<h5><a href="#List/Blog">Blog</a></h5>
- <p class="help">Weblog (blog) entr.y</p>
+ <p class="help">Weblog (blog) entry.</p>
<br>
<h5><a href="#List/Website Slideshow">Website Slideshow</a></h5>
<p class="help">Slideshows for adding in website pages.</p>
@@ -23,6 +23,9 @@
<br>
<h5><a href="#Form/About Us Settings">About Us Settings</a></h5>
<p class="help">Settings for About Us Page.</p>
+ <br>
+ <h5><a href="#Form/Contact Us Settings">Contact Us Settings</a></h5>
+ <p class="help">Settings for the Contact Us Page.</p>
</div>
<div style="clear: both"></div>
</div>
diff --git a/website/templates/js/contact.js b/website/templates/js/contact.js
new file mode 100644
index 0000000..f7310ad
--- /dev/null
+++ b/website/templates/js/contact.js
@@ -0,0 +1,37 @@
+$(document).ready(function() {
+
+ $('.btn-send').click(function() {
+ var email = $('[name="email"]').val();
+ var message = $('[name="message"]').val();
+
+ if(!(email && message)) {
+ msgprint("Please enter both your email and message so that we \
+ can get back to you. Thanks!");
+ return false;
+ }
+
+ if(!valid_email(email)) {
+ msgprint("You seem to have written your name instead of your email. \
+ Please enter a valid email address so that we can get back.");
+ $('[name="email"]').focus();
+ return false;
+ }
+
+ $("#contact-alert").toggle(false);
+ erpnext.send_message({
+ subject: $('[name="subject"]').val(),
+ sender: email,
+ message: message,
+ callback: function(r) {
+ msgprint(r.message);
+ $(':input').val('');
+ }
+ });
+ return false;
+ });
+
+});
+
+var msgprint = function(txt) {
+ if(txt) $("#contact-alert").html(txt).toggle(true);
+}
diff --git a/website/templates/pages/about.html b/website/templates/pages/about.html
index f4b6e30..669aed9 100644
--- a/website/templates/pages/about.html
+++ b/website/templates/pages/about.html
@@ -1,11 +1,13 @@
{% extends "html/page.html" %}
+{% block title %}
+About Us
+{% endblock %}
+
{% block content %}
<div class="layout-wrapper">
<div class="layout-main">
- {% if obj.doc.company_introduction %}
- {{ obj.doc.company_introduction }}
- {% endif %}
+ {{ obj.doc.company_introduction or "Some Introduction about your company that you would like your website visitor to know. More people than you think will read your About page. People always like to know who the are doing business with. Be authentic and avoid using jargon like 'value added services' etc. Be sure to update your company history and list of key team members in Website > About Us Settings" }}
{% if obj.doclist.get({"doctype":"Company History"}) %}
<h3>{{ obj.doc.company_history_heading or "Company History" }}</h3>
<table class="table table-bordered" style="width: 100%; table-layout: fixed">
@@ -24,11 +26,11 @@
<table class="table table-bordered" style="width: 100%; table-layout: fixed">
<tbody>
{% for d in obj.doclist.get({"doctype":"Employee"}) %}
- <tr>
+ <tr itemscope itemtype="http://schema.org/Person">
<td style="text-align:right; width: 30%;">
- <img src="{{ d.image }}" style=""></td>
- <td><h4>{{ d.employee_name }}</h4>
- {{ d.bio }}</td>
+ <img src="{{ d.image }}" style="" itemprop="image"></td>
+ <td><h4 itemprop="name">{{ d.employee_name }}</h4>
+ <div itemprop="description">{{ d.bio }}</div></td>
</tr>
{% endfor %}
</tbody>
diff --git a/website/templates/pages/contact.html b/website/templates/pages/contact.html
new file mode 100644
index 0000000..e5ba27c
--- /dev/null
+++ b/website/templates/pages/contact.html
@@ -0,0 +1,56 @@
+{% extends "html/page.html" %}
+
+{% block javascript %}
+ {% include "js/contact.js" %}
+{% endblock %}
+
+{% block title %}
+Contact Us
+{% endblock %}
+
+{% block content %}
+<div class="layout-wrapper">
+ <div class="layout-main">
+ <div class="web-form span5 pull-left">
+ {{ obj.doc.introduction or "<h3>Contact Us</h3>"}}
+ <div class="span4" style="margin-left:0px;">
+ <p id="contact-alert" class="alert"
+ style="display: none;"> </p>
+ </div>
+ <div class="clearfix"></div>
+ <p><select class="span4" name="subject">
+ {% for option in obj.doc.query_options %}
+ <option value="{{ option }}">{{ option }}</option>
+ {% endfor %}
+ </select></p>
+ <p><input class="span4" name="email" type="text" placeholder="Your Email Address" /></p>
+ <p><textarea class="span4" rows="10" name="message"></textarea></p>
+ <p><button class="btn btn-primary btn-send">Send</button></p>
+ </div>
+ {% if obj.doc.address %}
+ <div class="pull-right span3" itemscope itemtype="http://schema.org/PostalAddress">
+ <h4>{{ obj.address.address_title }}</h4>
+ {% if obj.address.address_line1 %}
+ <p itemprop="streetAddress">{{ obj.address.address_line1 }}</p>
+ {% endif %}
+ {% if obj.address.address_line2 %}
+ <p itemprop="streetAddress">{{ obj.address.address_line2 }}</p>
+ {% endif %}
+ {% if obj.address.city %}
+ <p itemprop="addressLocality">{{ obj.address.city }}</p>
+ {% endif %}
+ {% if obj.address.state %}
+ <p itemprop="addressRegion">{{ obj.address.state }}</p>
+ {% endif %}
+ {% if obj.address.pincode %}
+ <p itemprop="postalCode">{{ obj.address.pincode }}</p>
+ {% endif %}
+ {% if obj.address.country %}
+ <p itemprop="addressCountry">{{ obj.address.country }}</p>
+ {% endif %}
+ </div>
+ {% endif %}
+ <div class="clearfix"></div>
+ </div>
+</div>
+{% endblock %}
\ No newline at end of file
diff --git a/website/utils.py b/website/utils.py
index 52a0898..ec33103 100644
--- a/website/utils.py
+++ b/website/utils.py
@@ -41,7 +41,8 @@
}
page_settings_map = {
- "about": "About Us Settings"
+ "about": "About Us Settings",
+ "contact": "Contact Us Settings"
}
def render(page_name):