[website] [minor] moving to framework
This commit is contained in:
parent
6035165b69
commit
bb4c6eb630
@ -1,8 +0,0 @@
|
||||
Module for website management.
|
||||
|
||||
Contains:
|
||||
|
||||
- DocTypes for Web Page, Blogs
|
||||
- Templates
|
||||
- Settings
|
||||
- Generators for Item, Blog Post, Item Group
|
@ -1,20 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
install_docs = [
|
||||
{"doctype":"Role", "role_name":"Blogger", "name":"Blogger"},
|
||||
{"doctype":"Role", "role_name":"Website Manager", "name":"Website Manager"},
|
||||
]
|
||||
|
||||
import webnotes
|
||||
|
||||
|
||||
def get_site_address():
|
||||
from webnotes.utils import get_request_site_address
|
||||
url = get_request_site_address()
|
||||
|
||||
if not url or url=='http://localhost':
|
||||
new_url = webnotes.conn.get_value('Website Settings', 'Website Settings',
|
||||
'subdomain')
|
||||
if new_url:
|
||||
url = "http://" + new_url
|
||||
|
||||
return url
|
@ -1,204 +0,0 @@
|
||||
.container {
|
||||
max-width: 728px !important;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
margin-top: 20px;
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
.missing-image {
|
||||
background-color: #eee;
|
||||
padding: 40px;
|
||||
width: 112px;
|
||||
font-size: 32px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.social-icons {
|
||||
font-size: 120%;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
.social-icons a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.social-icons a i:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.social-icons i {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
div.web-footer {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul li {
|
||||
display: inline;
|
||||
padding: 2px 14px 2px 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
background-color: #ddd;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
|
||||
.avatar-small {
|
||||
margin-right: 5px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
-webkit-border-radius: 30px;
|
||||
}
|
||||
.avatar-small img {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
.avatar-medium {
|
||||
margin-right: 5px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 48px;
|
||||
-moz-border-radius: 48px;
|
||||
-webkit-border-radius: 48px;
|
||||
}
|
||||
.avatar-medium img {
|
||||
width: 48px;
|
||||
}
|
||||
|
||||
.avatar-large {
|
||||
margin-right: 10px;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 72px;
|
||||
-moz-border-radius: 72px;
|
||||
-webkit-border-radius: 72px;
|
||||
}
|
||||
.avatar-large img {
|
||||
width: 72px;
|
||||
}
|
||||
|
||||
.avatar-x-large {
|
||||
margin-right: 10px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 100px;
|
||||
-moz-border-radius: 100px;
|
||||
-webkit-border-radius: 100px;
|
||||
}
|
||||
.avatar-x-large img {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.carousel-control .icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
z-index: 5;
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: -10px;
|
||||
margin-left: -10px;
|
||||
}
|
||||
|
||||
.hidden-sm-inline {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.hidden-sm-inline {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-heading,
|
||||
.panel-body {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
|
||||
.breadcrumb {
|
||||
margin: 0px -20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* buttons */
|
||||
|
||||
.btn-default {
|
||||
color: #ffffff;
|
||||
background-color: #a7a9aa;
|
||||
border-color: #a7a9aa;
|
||||
}
|
||||
|
||||
.dropup .btn-default .caret,
|
||||
.btn-default .caret {
|
||||
border-bottom-color: #ffffff;
|
||||
border-top-color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-default:hover,
|
||||
.btn-default:focus,
|
||||
.btn-default:active,
|
||||
.btn-default.active,
|
||||
.open .dropdown-toggle.btn-default {
|
||||
background-color: #9a9c9d;
|
||||
border-color: #8d9091;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn-default.disabled,
|
||||
.btn-default[disabled],
|
||||
fieldset[disabled] .btn-default,
|
||||
.btn-default.disabled:hover,
|
||||
.btn-default[disabled]:hover,
|
||||
fieldset[disabled] .btn-default:hover,
|
||||
.btn-default.disabled:focus,
|
||||
.btn-default[disabled]:focus,
|
||||
fieldset[disabled] .btn-default:focus,
|
||||
.btn-default.disabled:active,
|
||||
.btn-default[disabled]:active,
|
||||
fieldset[disabled] .btn-default:active,
|
||||
.btn-default.disabled.active,
|
||||
.btn-default[disabled].active,
|
||||
fieldset[disabled] .btn-default.active {
|
||||
background-color: #a7a9aa;
|
||||
border-color: #a7a9aa;
|
||||
}
|
||||
|
||||
.label {
|
||||
padding-top: 0.3em;
|
||||
}
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1 +0,0 @@
|
||||
Configuration for "About" page in the website that shows company, history and team.
|
@ -1,21 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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 on_update(self):
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache("about")
|
||||
|
||||
def get_args():
|
||||
obj = webnotes.get_obj("About Us Settings")
|
||||
return {
|
||||
"obj": obj
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-19 12:02:15",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:23:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"description": "Settings for the About Us Page",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"icon": "icon-group",
|
||||
"issingle": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "About Us Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "About Us Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Website Manager",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "About Us Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "help",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Help",
|
||||
"options": "<div class=\"alert\">Link for About Us Page is \"/about\"</div>"
|
||||
},
|
||||
{
|
||||
"description": "Introduce your company to the website visitor.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company_introduction",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Company Introduction"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb0",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Company History"
|
||||
},
|
||||
{
|
||||
"description": "\"Company History\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company_history_heading",
|
||||
"fieldtype": "Data",
|
||||
"label": "Company History Heading"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company_history",
|
||||
"fieldtype": "Table",
|
||||
"label": "Company History",
|
||||
"options": "Company History"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb1",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Team Members"
|
||||
},
|
||||
{
|
||||
"description": "\"Team Members\" or \"Management\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "team_members_heading",
|
||||
"fieldtype": "Data",
|
||||
"label": "Team Members Heading"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "team_members",
|
||||
"fieldtype": "Table",
|
||||
"label": "Team Members",
|
||||
"options": "About Us Team Member"
|
||||
},
|
||||
{
|
||||
"description": "More content for the bottom of the page.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "footer",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Footer"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -1,34 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% set title="About Us" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12">
|
||||
{{ obj.doc.company_introduction or "<h2>About Us</h2><p>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</p>" }}
|
||||
{% if obj.doclist.get({"doctype":"Company History"}) %}
|
||||
<h3>{{ obj.doc.company_history_heading or "Company History" }}</h3>
|
||||
{% for d in obj.doclist.get({"doctype":"Company History"}) %}
|
||||
<div class="row">
|
||||
<span class="col-md-2"><h4 style="margin:0px;">{{ d.year }}</h4></span>
|
||||
<span class="col-md-10"><p>{{ d.highlight }}</p></span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if obj.doclist.get({"doctype":"About Us Team Member"}) %}
|
||||
<h3>{{ obj.doc.team_members_heading or "Team Members" }}</h3>
|
||||
{% for d in obj.doclist.get({"doctype":"About Us Team Member"}) %}
|
||||
<div class="row" itemscope itemtype="http://schema.org/Person">
|
||||
<span class="col-md-2">
|
||||
<div class="avatar avatar-large">
|
||||
<img class="avatar" src="{{ d.image_link }}" style="" itemprop="image">
|
||||
</div>
|
||||
</span>
|
||||
<span class="col-md-10"><h4 itemprop="name">{{ d.full_name }}</h4>
|
||||
<p itemprop="description">{{ d.bio }}</p>
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{{ obj.doc.footer or "" }}
|
||||
</div>
|
||||
{% endblock %}
|
@ -1 +0,0 @@
|
||||
Details of team member for About Us page.
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,52 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-07 11:55:11",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:03",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"in_list_view": 1,
|
||||
"name": "__common__",
|
||||
"parent": "About Us Team Member",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "About Us Team Member"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "full_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Full Name",
|
||||
"reqd": 1,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "image_link",
|
||||
"fieldtype": "Select",
|
||||
"label": "Image Link",
|
||||
"options": "attach_files:",
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "bio",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Bio",
|
||||
"reqd": 1,
|
||||
"width": "200px"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Blog category.
|
@ -1,17 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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 on_update(self):
|
||||
# for blog footer
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache()
|
||||
|
@ -1,56 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-08 09:41:11",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:27:02",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "field:category_name",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"icon": "icon-tag",
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "category_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Category Name",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Category",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Category",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Blog Category"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Blogger"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Blog post for "Blogs" section of website.
|
@ -1,61 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
"""
|
||||
Generate RSS feed for blog
|
||||
"""
|
||||
|
||||
rss = u"""<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>%(title)s</title>
|
||||
<description>%(description)s</description>
|
||||
<link>%(link)s</link>
|
||||
<lastBuildDate>%(modified)s</lastBuildDate>
|
||||
<pubDate>%(modified)s</pubDate>
|
||||
<ttl>1800</ttl>
|
||||
%(items)s
|
||||
</channel>
|
||||
</rss>"""
|
||||
|
||||
rss_item = u"""
|
||||
<item>
|
||||
<title>%(title)s</title>
|
||||
<description>%(content)s</description>
|
||||
<link>%(link)s</link>
|
||||
<guid>%(name)s</guid>
|
||||
<pubDate>%(published_on)s</pubDate>
|
||||
</item>"""
|
||||
|
||||
def generate():
|
||||
"""generate rss feed"""
|
||||
import os, urllib
|
||||
import webnotes
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.utils import escape_html
|
||||
|
||||
host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST')
|
||||
|
||||
items = ''
|
||||
blog_list = webnotes.conn.sql("""\
|
||||
select page_name as name, published_on, modified, title, content from `tabBlog Post`
|
||||
where ifnull(published,0)=1
|
||||
order by published_on desc limit 20""", as_dict=1)
|
||||
|
||||
for blog in blog_list:
|
||||
blog.link = urllib.quote(host + '/' + blog.name + '.html')
|
||||
blog.content = escape_html(blog.content or "")
|
||||
|
||||
items += rss_item % blog
|
||||
|
||||
modified = max((blog['modified'] for blog in blog_list))
|
||||
|
||||
ws = Document('Website Settings', 'Website Settings')
|
||||
return (rss % {
|
||||
'title': ws.title_prefix,
|
||||
'description': ws.description or (ws.title_prefix + ' Blog'),
|
||||
'modified': modified,
|
||||
'items': items,
|
||||
'link': host + '/blog.html'
|
||||
}).encode('utf-8', 'ignore')
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
if(!doc.__islocal && doc.published && !doc.email_sent) {
|
||||
cur_frm.add_custom_button('Email Subscribers', function() {
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
@ -1,176 +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
|
||||
import webnotes.webutils
|
||||
from webnotes import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def autoname(self):
|
||||
from webnotes.webutils import page_name
|
||||
self.doc.name = page_name(self.doc.title)
|
||||
|
||||
def validate(self):
|
||||
if self.doc.blog_intro:
|
||||
self.doc.blog_intro = self.doc.blog_intro[:140]
|
||||
|
||||
# update posts
|
||||
webnotes.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post`
|
||||
where ifnull(blogger,'')=tabBlogger.name)
|
||||
where name=%s""", self.doc.blogger)
|
||||
|
||||
def on_update(self):
|
||||
webnotes.webutils.update_page_name(self.doc, self.doc.title)
|
||||
webnotes.webutils.delete_page_cache("writers")
|
||||
|
||||
def prepare_template_args(self):
|
||||
import webnotes.utils
|
||||
import markdown2
|
||||
|
||||
# this is for double precaution. usually it wont reach this code if not published
|
||||
if not webnotes.utils.cint(self.doc.published):
|
||||
raise Exception, "This blog has not been published yet!"
|
||||
|
||||
# temp fields
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
self.doc.full_name = get_fullname(self.doc.owner)
|
||||
self.doc.updated = global_date_format(self.doc.published_on)
|
||||
self.doc.content_html = self.doc.content
|
||||
|
||||
if self.doc.blogger:
|
||||
self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
|
||||
|
||||
self.doc.description = self.doc.blog_intro or self.doc.content[:140]
|
||||
self.doc.meta_description = self.doc.description
|
||||
|
||||
self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
|
||||
|
||||
self.doc.texts = {
|
||||
"comments": _("Comments"),
|
||||
"first_comment": _("Be the first one to comment"),
|
||||
"add_comment": _("Add Comment"),
|
||||
"submit": _("Submit"),
|
||||
"all_posts_by": _("All posts by"),
|
||||
}
|
||||
|
||||
comment_list = webnotes.conn.sql("""\
|
||||
select comment, comment_by_fullname, creation
|
||||
from `tabComment` where comment_doctype="Blog Post"
|
||||
and comment_docname=%s order by creation""", self.doc.name, as_dict=1)
|
||||
|
||||
self.doc.comment_list = comment_list or []
|
||||
for comment in self.doc.comment_list:
|
||||
comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
|
||||
comment['comment'] = markdown2.markdown(comment['comment'])
|
||||
|
||||
def clear_blog_cache():
|
||||
for blog in webnotes.conn.sql_list("""select page_name from
|
||||
`tabBlog Post` where ifnull(published,0)=1"""):
|
||||
webnotes.webutils.delete_page_cache(blog)
|
||||
|
||||
webnotes.webutils.delete_page_cache("writers")
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_blog_list(start=0, by=None, category=None):
|
||||
import webnotes
|
||||
condition = ""
|
||||
if by:
|
||||
condition = " and t1.blogger='%s'" % by.replace("'", "\'")
|
||||
if category:
|
||||
condition += " and t1.blog_category='%s'" % category.replace("'", "\'")
|
||||
query = """\
|
||||
select
|
||||
t1.title, t1.name, t1.page_name, t1.published_on as creation,
|
||||
ifnull(t1.blog_intro, t1.content) as content,
|
||||
t2.full_name, t2.avatar, t1.blogger,
|
||||
(select count(name) from `tabComment` where
|
||||
comment_doctype='Blog Post' and comment_docname=t1.name) as comments
|
||||
from `tabBlog Post` t1, `tabBlogger` t2
|
||||
where ifnull(t1.published,0)=1
|
||||
and t1.blogger = t2.name
|
||||
%(condition)s
|
||||
order by published_on desc, name asc
|
||||
limit %(start)s, 20""" % {"start": start, "condition": condition}
|
||||
|
||||
result = webnotes.conn.sql(query, as_dict=1)
|
||||
|
||||
# strip html tags from content
|
||||
import webnotes.utils
|
||||
|
||||
for res in result:
|
||||
from webnotes.utils import global_date_format
|
||||
res['published'] = global_date_format(res['creation'])
|
||||
if not res['content']:
|
||||
res['content'] = webnotes.webutils.get_html(res['page_name'])
|
||||
res['content'] = res['content'][:140]
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def add_comment(args=None):
|
||||
"""
|
||||
args = {
|
||||
'comment': '',
|
||||
'comment_by': '',
|
||||
'comment_by_fullname': '',
|
||||
'comment_doctype': '',
|
||||
'comment_docname': '',
|
||||
'page_name': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
import webnotes.utils, markdown2
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
args['comment'] = unicode(markdown2.markdown(args.get('comment') or ''))
|
||||
args['doctype'] = "Comment"
|
||||
|
||||
page_name = args.get("page_name")
|
||||
if "page_name" in args:
|
||||
del args["page_name"]
|
||||
if "cmd" in args:
|
||||
del args["cmd"]
|
||||
|
||||
comment = webnotes.bean(args)
|
||||
comment.ignore_permissions = True
|
||||
comment.insert()
|
||||
|
||||
# since comments are embedded in the page, clear the web cache
|
||||
webnotes.webutils.clear_cache(page_name)
|
||||
|
||||
args['comment_date'] = webnotes.utils.global_date_format(comment.doc.creation)
|
||||
template_args = { 'comment_list': [args], 'template': 'app/website/templates/html/comment.html' }
|
||||
|
||||
# get html of comment row
|
||||
comment_html = webnotes.webutils.build_html(template_args)
|
||||
|
||||
# notify commentors
|
||||
commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where
|
||||
comment_doctype='Blog Post' and comment_docname=%s and
|
||||
ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))]
|
||||
|
||||
blog = webnotes.doc("Blog Post", args.get("comment_docname"))
|
||||
blogger_profile = webnotes.conn.get_value("Blogger", blog.blogger, "profile")
|
||||
blogger_email = webnotes.conn.get_value("Profile", blogger_profile, "email")
|
||||
|
||||
from webnotes.utils.email_lib.bulk import send
|
||||
send(recipients=list(set(commentors + [blogger_email])),
|
||||
doctype='Comment',
|
||||
email_field='comment_by',
|
||||
subject='New Comment on Blog: ' + blog.title,
|
||||
message='%(comment)s<p>By %(comment_by_fullname)s</p>' % args,
|
||||
ref_doctype='Blog Post', ref_docname=blog.name)
|
||||
|
||||
return comment_html.replace("\n", "")
|
||||
|
||||
def get_blog_template_args():
|
||||
args = {
|
||||
"categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
|
||||
}
|
||||
args.update(webnotes.doc("Blog Settings", "Blog Settings").fields)
|
||||
return args
|
@ -1,135 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-28 10:35:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 15:08:30",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"allow_import": 1,
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-quote-left",
|
||||
"max_attachments": 5,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Post",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Post",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Blog Post"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "published",
|
||||
"fieldtype": "Check",
|
||||
"label": "Published"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "published_on",
|
||||
"fieldtype": "Date",
|
||||
"label": "Published On"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "blogger",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Blogger",
|
||||
"options": "Blogger",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "blog_category",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Blog Category",
|
||||
"options": "Blog Category"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_5",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"description": "Description for listing page, in plain text, only a couple of lines. (max 140 characters)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "blog_intro",
|
||||
"fieldtype": "Small Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Blog Intro",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "content",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Content",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Page Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "email_sent",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Email Sent"
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Blogger",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Guest",
|
||||
"write": 0
|
||||
}
|
||||
]
|
@ -1,33 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "app/website/templates/js/blog.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "app/website/templates/css/blog.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% set title="Blog" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12">
|
||||
<h2 id="blog-title">{{ blog_title }}</h2>
|
||||
{% if blog_introduction %}
|
||||
<p>{{ blog_introduction }}</p>
|
||||
{% endif %}
|
||||
<h3 id="blot-subtitle" style="display:none;"></h3>
|
||||
<br>
|
||||
<div class="progress progress-striped active">
|
||||
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
|
||||
</div>
|
||||
<div id="blog-list">
|
||||
<!-- blog list will be generated dynamically -->
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<button id="next-page" class="btn btn-default"
|
||||
style="display:none;">More...</button>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'app/website/templates/html/blog_footer.html' %}
|
||||
{% endblock %}
|
@ -1,58 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "app/website/templates/js/blog_page.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "app/website/templates/css/blog_page.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12" itemscope itemtype="http://schema.org/BlogPost">
|
||||
<h2 itemprop="name headline">{{ title }}</h2>
|
||||
|
||||
<!-- begin blog content -->
|
||||
<div class="help" style="color: #aaa">
|
||||
<span itemprop="author">{{ blogger_info and blogger_info.full_name or full_name }}</span> /
|
||||
<span itemprop="dateCreated">{{ updated }}</span></div>
|
||||
<br>
|
||||
<div itemprop="articleBody">
|
||||
{{ content_html }}
|
||||
</div>
|
||||
<!-- end blog content -->
|
||||
{% if blogger_info %}
|
||||
<hr />
|
||||
{% include "app/website/templates/html/blogger.html" %}
|
||||
{% endif %}
|
||||
<hr>
|
||||
<h3>{{ texts.comments }}</h3><br>
|
||||
<div class="blog-comments">
|
||||
|
||||
{% if not comment_list %}
|
||||
<div class="no-comment">
|
||||
<p>{{ texts.first_comment }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'app/website/templates/html/comment.html' %}
|
||||
</div>
|
||||
<div><button class="btn btn-default add-comment">{{ texts.add_comment }}</button></div>
|
||||
<div style="display: none; margin-top: 10px; max-width: 400px;"
|
||||
id="comment-form">
|
||||
<div class="alert" style="display:none;"></div>
|
||||
<form>
|
||||
<fieldset>
|
||||
<input class="form-control" name="comment_by_fullname" placeholder="Your Name" type="text"/><br>
|
||||
<input class="form-control" name="comment_by"
|
||||
placeholder="Your Email Id" type="text"/><br>
|
||||
<textarea class="form-control" name="comment" rows=10
|
||||
placeholder="Comment"/>
|
||||
</textarea><br>
|
||||
<button class="btn btn-info" id="submit-comment">{{ texts.submit }}</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'app/website/templates/html/blog_footer.html' %}
|
||||
{% endblock %}
|
@ -1,7 +0,0 @@
|
||||
<style>
|
||||
h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
|
||||
h2 > a:hover, h2 > a:focus {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
@ -1,86 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
// js inside blog page
|
||||
|
||||
$(document).ready(function() {
|
||||
// make list of blogs
|
||||
blog.get_list();
|
||||
|
||||
$("#next-page").click(function() {
|
||||
blog.get_list();
|
||||
})
|
||||
|
||||
if(get_url_arg("by_name")) {
|
||||
$("#blot-subtitle").html("Posts by " + get_url_arg("by_name")).toggle(true);
|
||||
}
|
||||
|
||||
if(get_url_arg("category")) {
|
||||
$("#blot-subtitle").html("Posts filed under " + get_url_arg("category")).toggle(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var blog = {
|
||||
start: 0,
|
||||
get_list: function() {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "server.py",
|
||||
data: {
|
||||
cmd: "website.doctype.blog_post.blog_post.get_blog_list",
|
||||
start: blog.start,
|
||||
by: get_url_arg("by"),
|
||||
category: get_url_arg("category")
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$(".progress").toggle(false);
|
||||
if(data.exc) console.log(data.exc);
|
||||
blog.render(data.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
render: function(data) {
|
||||
var $wrap = $("#blog-list");
|
||||
$.each(data, function(i, b) {
|
||||
// comments
|
||||
if(!b.comments) {
|
||||
b.comment_text = 'No comments yet.'
|
||||
} else if (b.comments===1) {
|
||||
b.comment_text = '1 comment.'
|
||||
} else {
|
||||
b.comment_text = b.comments + ' comments.'
|
||||
}
|
||||
|
||||
b.page_name = encodeURIComponent(b.page_name);
|
||||
|
||||
$(repl('<div class="row">\
|
||||
<div class="col-md-1">\
|
||||
<div class="avatar avatar-medium" style="margin-top: 6px;">\
|
||||
<img src="%(avatar)s" />\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="col-md-11">\
|
||||
<h4><a href="%(page_name)s">%(title)s</a></h4>\
|
||||
<p>%(content)s</p>\
|
||||
<p style="color: #aaa; font-size: 90%">\
|
||||
<a href="blog?by=%(blogger)s&by_name=%(full_name)s">\
|
||||
%(full_name)s</a> wrote this on %(published)s / %(comment_text)s</p>\
|
||||
</div>\
|
||||
</div><hr>', b)).appendTo($wrap);
|
||||
});
|
||||
blog.start += (data.length || 0);
|
||||
if(!data.length || data.length < 20) {
|
||||
if(blog.start) {
|
||||
$("#next-page").toggle(false)
|
||||
.parent().append("<div class='text-muted'>Nothing more to show.</div>");
|
||||
} else {
|
||||
$("#next-page").toggle(false)
|
||||
.parent().append("<div class='alert alert-warning'>No blogs written yet.</div>");
|
||||
}
|
||||
} else {
|
||||
$("#next-page").toggle(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
{% if categories %}
|
||||
<h5>Explore posts by categories</h5>
|
||||
<ul class="breadcrumb" style="background-color: transparent; padding-left: 20px;">
|
||||
{% for category in categories %}
|
||||
<li><a href="blog?category={{ category }}">{{ category }}</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<br><br>
|
||||
{% endif %}
|
||||
<p>Show posts by <a href="blog">everyone</a>. Meet the <a href="writers">writers</a> of this blog</p>
|
||||
</div>
|
@ -1,13 +0,0 @@
|
||||
<style>
|
||||
.comment-title {
|
||||
color:#777;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 240px;
|
||||
}
|
||||
</style>
|
@ -1,65 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
// js inside blog page
|
||||
|
||||
$(document).ready(function() {
|
||||
var n_comments = $(".comment-row").length;
|
||||
|
||||
if(n_comments) {
|
||||
$(".no_comment").toggle(false);
|
||||
}
|
||||
if(n_comments > 50) {
|
||||
$(".add-comment").toggle(false)
|
||||
.parent().append("<div class='alert alert-warning'>Comments are closed.</div>")
|
||||
}
|
||||
$(".add-comment").click(function() {
|
||||
$(this).toggle(false);
|
||||
$("#comment-form").toggle();
|
||||
$("#comment-form input, #comment-form, textarea").val("");
|
||||
})
|
||||
$("#submit-comment").click(function() {
|
||||
var args = {
|
||||
comment_by_fullname: $("[name='comment_by_fullname']").val(),
|
||||
comment_by: $("[name='comment_by']").val(),
|
||||
comment: $("[name='comment']").val(),
|
||||
cmd: "website.doctype.blog_post.blog_post.add_comment",
|
||||
comment_doctype: "Blog Post",
|
||||
comment_docname: "{{ name }}",
|
||||
page_name: "{{ page_name }}",
|
||||
_type: "POST"
|
||||
}
|
||||
|
||||
$("#comment-form .alert").toggle(false);
|
||||
|
||||
if(!args.comment_by_fullname || !args.comment_by || !args.comment) {
|
||||
$("#comment-form .alert")
|
||||
.html("All fields are necessary to submit the comment.")
|
||||
.toggle(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "server.py",
|
||||
data: args,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.exc) {
|
||||
$("#comment-form .alert")
|
||||
.html(data.exc)
|
||||
.toggle(true)
|
||||
} else {
|
||||
$(data.message).appendTo(".blog-comments");
|
||||
$(".no_comment").toggle(false);
|
||||
$(".add-comment").toggle(false);
|
||||
$("#comment-form")
|
||||
.replaceWith("<div class='alert alert-success'>Thank you for your comment!</div>")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return false;
|
||||
})
|
||||
})
|
@ -1,9 +0,0 @@
|
||||
<h4>Subscribe</h4>
|
||||
<br>
|
||||
<p>
|
||||
<button class="btn btn-warning btn-blog-subscribe">Get Updates via Email</button>
|
||||
</p>
|
||||
<p>
|
||||
<img src="app/images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
@ -1,13 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<div class="avatar avatar-large">
|
||||
<img itemprop="thumbnailUrl" src="{{ blogger_info.avatar }}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<h4>{{ blogger_info.full_name }}</h4>
|
||||
<p style="color: #999">{{ blogger_info.bio }}</p>
|
||||
<p><a href="blog?by={{ blogger_info.name }}&by_name={{ blogger_info.full_name }}">
|
||||
{{ texts.all_posts_by }} {{ blogger_info.full_name }}</a></p>
|
||||
</div>
|
||||
</div>
|
@ -1,17 +0,0 @@
|
||||
{#
|
||||
this template generates comment rows for a blog
|
||||
it is to be included in the blog/blog.html template
|
||||
#}
|
||||
|
||||
<div itemscope itemtype="http://schema.org/UserComments">
|
||||
{% for comment in comment_list %}
|
||||
<div class="comment-row">
|
||||
<div class="comment-title">
|
||||
<span itemprop="name" class="author">{{ comment.comment_by_fullname }}</span> /
|
||||
<span itemprop="commentTime">{{ comment.comment_date }}</span>:
|
||||
</div>
|
||||
<p class="comment-content" itemprop="commentText">{{ comment.comment }}</p>
|
||||
<hr>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
@ -1 +0,0 @@
|
||||
Blog titles and introduction texts.
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,62 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-11 17:48:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:27:31",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Blog Settings",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Blog Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Blog Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "blog_title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Blog Title"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "blog_introduction",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Blog Introduction"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "writers_introduction",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Writers Introduction"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Profile of blog writer in "Blog" section.
|
@ -1,41 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def on_update(self):
|
||||
"if profile is set, then update all older blogs"
|
||||
|
||||
from website.doctype.blog_post.blog_post import clear_blog_cache
|
||||
clear_blog_cache()
|
||||
|
||||
if self.doc.profile:
|
||||
for blog in webnotes.conn.sql_list("""select name from `tabBlog Post` where owner=%s
|
||||
and ifnull(blogger,'')=''""", self.doc.profile):
|
||||
b = webnotes.bean("Blog Post", blog)
|
||||
b.doc.blogger = self.doc.name
|
||||
b.save()
|
||||
|
||||
def get_writers_args():
|
||||
bloggers = webnotes.conn.sql("""select * from `tabBlogger`
|
||||
where ifnull(posts,0) > 0 and ifnull(disabled,0)=0
|
||||
order by posts desc""", as_dict=1)
|
||||
|
||||
args = {
|
||||
"bloggers": bloggers,
|
||||
"texts": {
|
||||
"all_posts_by": _("All posts by")
|
||||
},
|
||||
"categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
|
||||
}
|
||||
|
||||
args.update(webnotes.doc("Blog Settings", "Blog Settings").fields)
|
||||
return args
|
@ -1,102 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-25 16:00:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-30 16:35:24",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"autoname": "field:short_name",
|
||||
"description": "Profile of a Blogger",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"icon": "icon-user",
|
||||
"max_attachments": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Blogger",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Blogger",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Blogger"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "disabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Disabled"
|
||||
},
|
||||
{
|
||||
"description": "Will be used in url (usually first name).",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "short_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Short Name",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "full_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Full Name",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "profile",
|
||||
"fieldtype": "Link",
|
||||
"label": "Profile",
|
||||
"options": "Profile"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "bio",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Bio"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "avatar",
|
||||
"fieldtype": "Select",
|
||||
"label": "Avatar",
|
||||
"options": "attach_files:"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "posts",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"label": "Posts",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Website Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"match": "owner:profile",
|
||||
"role": "Blogger"
|
||||
}
|
||||
]
|
@ -1,17 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% set title="Blog Writers" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12">
|
||||
<h2 id="blog-title">Blog Writers</h2>
|
||||
{% if writers_introduction %}
|
||||
<p>{{ writers_introduction }}</p>
|
||||
{% endif %}
|
||||
<hr>
|
||||
{% for blogger_info in bloggers %}
|
||||
{% include "app/website/templates/html/blogger.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% include 'app/website/templates/html/blog_footer.html' %}
|
||||
{% endblock %}
|
@ -1 +0,0 @@
|
||||
Company history detail for "About Us" section.
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,42 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-22 01:28:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:06",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"in_list_view": 1,
|
||||
"name": "__common__",
|
||||
"parent": "Company History",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Company History"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "year",
|
||||
"fieldtype": "Data",
|
||||
"label": "Year"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "highlight",
|
||||
"fieldtype": "Text",
|
||||
"label": "Highlight",
|
||||
"print_width": "300px",
|
||||
"width": "300px"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Settings, introduction for "Contact Us" section.
|
@ -1,24 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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.query_options = filter(None, self.doc.query_options.replace(",", "\n").split())
|
||||
else:
|
||||
self.query_options = ["Sales", "Support", "General"]
|
||||
if self.doc.address:
|
||||
self.address = webnotes.bean("Address", self.doc.address).doc
|
||||
|
||||
def on_update(self):
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache("contact")
|
@ -1,82 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-21 20:12:42",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:32:24",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Settings for Contact Us Page",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Contact Us Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Contact Us Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Website Manager",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Contact Us Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "help",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Help",
|
||||
"options": "<div class=\"alert\">Link for Contact Page is \"/contact\"</div>"
|
||||
},
|
||||
{
|
||||
"description": "Address to be displayed on the Contact Page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address",
|
||||
"fieldtype": "Link",
|
||||
"label": "Address",
|
||||
"options": "Address"
|
||||
},
|
||||
{
|
||||
"description": "Default: \"Contact Us\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "heading",
|
||||
"fieldtype": "Data",
|
||||
"label": "Heading"
|
||||
},
|
||||
{
|
||||
"description": "Introductory information for the Contact Us Page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "introduction",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Introduction"
|
||||
},
|
||||
{
|
||||
"description": "Contact options, like \"Sales Query, Support Query\" etc each on a new line or separated by commas.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "query_options",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Query Options"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -1,60 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "app/website/templates/js/contact.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% set title="Contact Us" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12">
|
||||
<h3>{{ obj.doc.heading or "Contact Us"}}</h3>
|
||||
<div class="row">
|
||||
<div class="web-form col-md-8">
|
||||
<p id="contact-alert" class="alert alert-warning"
|
||||
style="display: none;"> </p>
|
||||
<p>
|
||||
<select name="subject" class="form-control">
|
||||
{% for option in obj.query_options %}
|
||||
<option value="{{ option }}">{{ option }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<input class="form-control" name="email" type="text"
|
||||
placeholder="Your Email Address" />
|
||||
</p>
|
||||
<p>
|
||||
<textarea rows="10" name="message" class="form-control"></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<button class="btn btn-primary btn-send">Send</button>
|
||||
</p>
|
||||
</div>
|
||||
{% if obj.doc.address %}
|
||||
<div class="col-md-3 col-md-offset-1 alert alert-warning" style="margin-top: 20px;" itemscope itemtype="http://schema.org/PostalAddress">
|
||||
<h4><i class="icon-map-marker"></i> {{ obj.address.address_title }}</h4>
|
||||
{% if obj.address.address_line1 %}
|
||||
<span itemprop="streetAddress">{{ obj.address.address_line1 }}</span><br>
|
||||
{% endif %}
|
||||
{% if obj.address.address_line2 %}
|
||||
<span itemprop="streetAddress">{{ obj.address.address_line2 }}</span><br>
|
||||
{% endif %}
|
||||
{% if obj.address.city %}
|
||||
<span itemprop="addressLocality">{{ obj.address.city }}</span><br>
|
||||
{% endif %}
|
||||
{% if obj.address.state %}
|
||||
<span itemprop="addressRegion">{{ obj.address.state }}</span><br>
|
||||
{% endif %}
|
||||
{% if obj.address.pincode %}
|
||||
<span itemprop="postalCode">{{ obj.address.pincode }}</span><br>
|
||||
{% endif %}
|
||||
{% if obj.address.country %}
|
||||
<span itemprop="addressCountry">{{ obj.address.country }}</span><br>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{{ obj.doc.introduction }}
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,45 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$(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) {
|
||||
if(r.status==="okay") {
|
||||
msgprint(r.message || "Thank you for your message.")
|
||||
} else {
|
||||
msgprint("There were errors");
|
||||
console.log(r.exc);
|
||||
}
|
||||
$(':input').val('');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var msgprint = function(txt) {
|
||||
if(txt) $("#contact-alert").html(txt).toggle(true);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,36 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-06-20 16:00:18",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-09 14:47:12",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "selling_price_list",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Price List",
|
||||
"name": "__common__",
|
||||
"options": "Price List",
|
||||
"parent": "Shopping Cart Price List",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Shopping Cart Price List"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
}
|
||||
]
|
@ -1,10 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
onload: function() {
|
||||
if(cur_frm.doc.__quotation_series) {
|
||||
cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,149 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes.utils import comma_and
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class ShoppingCartSetupError(webnotes.ValidationError): pass
|
||||
|
||||
class DocType(DocListController):
|
||||
def onload(self):
|
||||
self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series")
|
||||
|
||||
def validate(self):
|
||||
if self.doc.enabled:
|
||||
self.validate_price_lists()
|
||||
self.validate_tax_masters()
|
||||
self.validate_exchange_rates_exist()
|
||||
|
||||
def on_update(self):
|
||||
webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0)
|
||||
webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series"))
|
||||
|
||||
def validate_overlapping_territories(self, parentfield, fieldname):
|
||||
# for displaying message
|
||||
doctype = self.meta.get_field(parentfield).options
|
||||
|
||||
# specify atleast one entry in the table
|
||||
self.validate_table_has_rows(parentfield, raise_exception=ShoppingCartSetupError)
|
||||
|
||||
territory_name_map = self.get_territory_name_map(parentfield, fieldname)
|
||||
for territory, names in territory_name_map.items():
|
||||
if len(names) > 1:
|
||||
msgprint(_("Error for") + " " + _(doctype) + ": " + comma_and(names) +
|
||||
" " + _("have a common territory") + ": " + territory,
|
||||
raise_exception=ShoppingCartSetupError)
|
||||
|
||||
return territory_name_map
|
||||
|
||||
def validate_price_lists(self):
|
||||
territory_name_map = self.validate_overlapping_territories("price_lists",
|
||||
"selling_price_list")
|
||||
|
||||
# validate that a Shopping Cart Price List exists for the root territory
|
||||
# as a catch all!
|
||||
from setup.utils import get_root_of
|
||||
root_territory = get_root_of("Territory")
|
||||
|
||||
if root_territory not in territory_name_map.keys():
|
||||
msgprint(_("Please specify a Price List which is valid for Territory") +
|
||||
": " + root_territory, raise_exception=ShoppingCartSetupError)
|
||||
|
||||
def validate_tax_masters(self):
|
||||
self.validate_overlapping_territories("sales_taxes_and_charges_masters",
|
||||
"sales_taxes_and_charges_master")
|
||||
|
||||
def get_territory_name_map(self, parentfield, fieldname):
|
||||
territory_name_map = {}
|
||||
|
||||
# entries in table
|
||||
names = [doc.fields.get(fieldname) for doc in self.doclist.get({"parentfield": parentfield})]
|
||||
|
||||
if names:
|
||||
# for condition in territory check
|
||||
parenttype = self.meta.get_field(fieldname, parentfield=parentfield).options
|
||||
|
||||
# to validate territory overlap
|
||||
# make a map of territory: [list of names]
|
||||
# if list against each territory has more than one element, raise exception
|
||||
territory_name = webnotes.conn.sql("""select `territory`, `parent`
|
||||
from `tabFor Territory`
|
||||
where `parenttype`=%s and `parent` in (%s)""" %
|
||||
("%s", ", ".join(["%s"]*len(names))), tuple([parenttype] + names))
|
||||
|
||||
for territory, name in territory_name:
|
||||
territory_name_map.setdefault(territory, []).append(name)
|
||||
|
||||
if len(territory_name_map[territory]) > 1:
|
||||
territory_name_map[territory].sort(key=lambda val: names.index(val))
|
||||
|
||||
return territory_name_map
|
||||
|
||||
def validate_exchange_rates_exist(self):
|
||||
"""check if exchange rates exist for all Price List currencies (to company's currency)"""
|
||||
company_currency = webnotes.conn.get_value("Company", self.doc.company, "default_currency")
|
||||
if not company_currency:
|
||||
msgprint(_("Please specify currency in Company") + ": " + self.doc.company,
|
||||
raise_exception=ShoppingCartSetupError)
|
||||
|
||||
price_list_currency_map = webnotes.conn.get_values("Price List",
|
||||
[d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})],
|
||||
"currency")
|
||||
|
||||
expected_to_exist = [currency + "-" + company_currency
|
||||
for currency in price_list_currency_map.values()
|
||||
if currency != company_currency]
|
||||
|
||||
if expected_to_exist:
|
||||
exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange`
|
||||
where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),),
|
||||
tuple(expected_to_exist))
|
||||
|
||||
missing = list(set(expected_to_exist).difference(exists))
|
||||
|
||||
if missing:
|
||||
msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)),
|
||||
raise_exception=ShoppingCartSetupError)
|
||||
|
||||
def get_name_from_territory(self, territory, parentfield, fieldname):
|
||||
name = None
|
||||
territory_name_map = self.get_territory_name_map(parentfield, fieldname)
|
||||
|
||||
if territory_name_map.get(territory):
|
||||
name = territory_name_map.get(territory)
|
||||
else:
|
||||
territory_ancestry = self.get_territory_ancestry(territory)
|
||||
for ancestor in territory_ancestry:
|
||||
if territory_name_map.get(ancestor):
|
||||
name = territory_name_map.get(ancestor)
|
||||
break
|
||||
|
||||
return name
|
||||
|
||||
def get_price_list(self, billing_territory):
|
||||
price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list")
|
||||
return price_list and price_list[0] or None
|
||||
|
||||
def get_tax_master(self, billing_territory):
|
||||
tax_master = self.get_name_from_territory(billing_territory, "sales_taxes_and_charges_masters",
|
||||
"sales_taxes_and_charges_master")
|
||||
return tax_master and tax_master[0] or None
|
||||
|
||||
def get_shipping_rules(self, shipping_territory):
|
||||
return self.get_name_from_territory(shipping_territory, "shipping_rules", "shipping_rule")
|
||||
|
||||
def get_territory_ancestry(self, territory):
|
||||
from setup.utils import get_ancestors_of
|
||||
|
||||
if not hasattr(self, "_territory_ancestry"):
|
||||
self._territory_ancestry = {}
|
||||
|
||||
if not self._territory_ancestry.get(territory):
|
||||
self._territory_ancestry[territory] = get_ancestors_of("Territory", territory)
|
||||
|
||||
return self._territory_ancestry[territory]
|
@ -1,125 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-06-19 15:57:32",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-15 17:33:05",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Default settings for Shopping Cart",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-shopping-cart",
|
||||
"issingle": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Shopping Cart Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Shopping Cart Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Shopping Cart Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Shopping Cart"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_2",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"label": "Company",
|
||||
"options": "Company",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "default_territory",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Territory",
|
||||
"options": "Territory",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "default_customer_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Customer Group",
|
||||
"options": "Customer Group",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "quotation_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Quotation Series",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_6",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_lists",
|
||||
"fieldtype": "Table",
|
||||
"label": "Shopping Cart Price Lists",
|
||||
"options": "Shopping Cart Price List",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "shipping_rules",
|
||||
"fieldtype": "Table",
|
||||
"label": "Shopping Cart Shipping Rules",
|
||||
"options": "Shopping Cart Shipping Rule",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_10",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_taxes_and_charges_masters",
|
||||
"fieldtype": "Table",
|
||||
"label": "Shopping Cart Taxes and Charges Masters",
|
||||
"options": "Shopping Cart Taxes and Charges Master",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -1,81 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import unittest
|
||||
from website.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError
|
||||
|
||||
class TestShoppingCartSettings(unittest.TestCase):
|
||||
def setUp(self):
|
||||
webnotes.conn.sql("""delete from `tabSingles` where doctype="Shipping Cart Settings" """)
|
||||
webnotes.conn.sql("""delete from `tabShopping Cart Price List`""")
|
||||
webnotes.conn.sql("""delete from `tabShopping Cart Taxes and Charges Master`""")
|
||||
webnotes.conn.sql("""delete from `tabShopping Cart Shipping Rule`""")
|
||||
|
||||
def get_cart_settings(self):
|
||||
return webnotes.bean({"doctype": "Shopping Cart Settings",
|
||||
"company": "_Test Company"})
|
||||
|
||||
def test_price_list_territory_overlap(self):
|
||||
cart_settings = self.get_cart_settings()
|
||||
|
||||
def _add_price_list(price_list):
|
||||
cart_settings.doclist.append({
|
||||
"doctype": "Shopping Cart Price List",
|
||||
"parentfield": "price_lists",
|
||||
"selling_price_list": price_list
|
||||
})
|
||||
|
||||
for price_list in ("_Test Price List Rest of the World", "_Test Price List India",
|
||||
"_Test Price List"):
|
||||
_add_price_list(price_list)
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
controller.validate_overlapping_territories("price_lists", "selling_price_list")
|
||||
|
||||
_add_price_list("_Test Price List 2")
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories,
|
||||
"price_lists", "selling_price_list")
|
||||
|
||||
return cart_settings
|
||||
|
||||
def test_taxes_territory_overlap(self):
|
||||
cart_settings = self.get_cart_settings()
|
||||
|
||||
def _add_tax_master(tax_master):
|
||||
cart_settings.doclist.append({
|
||||
"doctype": "Shopping Cart Taxes and Charges Master",
|
||||
"parentfield": "sales_taxes_and_charges_masters",
|
||||
"sales_taxes_and_charges_master": tax_master
|
||||
})
|
||||
|
||||
for tax_master in ("_Test Sales Taxes and Charges Master", "_Test India Tax Master"):
|
||||
_add_tax_master(tax_master)
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
controller.validate_overlapping_territories("sales_taxes_and_charges_masters",
|
||||
"sales_taxes_and_charges_master")
|
||||
|
||||
_add_tax_master("_Test Sales Taxes and Charges Master 2")
|
||||
|
||||
controller = cart_settings.make_controller()
|
||||
self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories,
|
||||
"sales_taxes_and_charges_masters", "sales_taxes_and_charges_master")
|
||||
|
||||
def test_exchange_rate_exists(self):
|
||||
webnotes.conn.sql("""delete from `tabCurrency Exchange`""")
|
||||
|
||||
cart_settings = self.test_price_list_territory_overlap()
|
||||
controller = cart_settings.make_controller()
|
||||
self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist)
|
||||
|
||||
from setup.doctype.currency_exchange.test_currency_exchange import test_records as \
|
||||
currency_exchange_records
|
||||
webnotes.bean(currency_exchange_records[0]).insert()
|
||||
controller.validate_exchange_rates_exist()
|
||||
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,36 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-07-03 13:15:34",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "shipping_rule",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Shipping Rule",
|
||||
"name": "__common__",
|
||||
"options": "Shipping Rule",
|
||||
"parent": "Shopping Cart Shipping Rule",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Shopping Cart Shipping Rule"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
}
|
||||
]
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,36 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-06-20 16:57:03",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:23",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_taxes_and_charges_master",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Tax Master",
|
||||
"name": "__common__",
|
||||
"options": "Sales Taxes and Charges Master",
|
||||
"parent": "Shopping Cart Taxes and Charges Master",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Shopping Cart Taxes and Charges Master"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
}
|
||||
]
|
@ -1,6 +0,0 @@
|
||||
Style settings for website. Includes settings for:
|
||||
|
||||
- Site colours (background, toolbars)
|
||||
- Fonts (family and size)
|
||||
- Background (image if any)
|
||||
- Custom CSS
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,235 +0,0 @@
|
||||
{% if doc.at_import %}
|
||||
{{ doc.at_import }}
|
||||
{% endif %}
|
||||
|
||||
body {
|
||||
{% if doc.background_image %}
|
||||
background: url("../{{ doc.background_image }}") repeat;
|
||||
{% elif doc.background_color %}
|
||||
background-color: #{{ doc.background_color }};
|
||||
background-image: none;
|
||||
{% else %}
|
||||
background-color: #ffffff;
|
||||
{% endif %}
|
||||
{% if doc.font or doc.google_web_font_for_text %}
|
||||
font-family: '{{ doc.google_web_font_for_text or doc.font }}', 'Helvetica Neue', Arial, Sans !important;
|
||||
{% endif %}
|
||||
{% if doc.font_size %}font-size: {{ doc.font_size }} !important;{% endif %}
|
||||
{% if doc.page_text %}color: #{{ doc.page_text }};{% endif %}
|
||||
}
|
||||
|
||||
{% if doc.page_links %}a, a:hover {
|
||||
color: #{{ doc.page_links }};
|
||||
}{% endif %}
|
||||
|
||||
{% if doc.font_size %}
|
||||
.small {
|
||||
font-size: {{ doc.small_font_size }} !important;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
div.outer {
|
||||
background-color: #{{ doc.page_background }};
|
||||
}
|
||||
|
||||
{% if doc.google_web_font_for_heading or doc.heading_font %}h1, h2, h3, h4, h5 {
|
||||
font-family: '{{ doc.google_web_font_for_heading or doc.heading_font }}', 'Helvetica Neue', Arial !important;
|
||||
}{% endif %}
|
||||
|
||||
{% if doc.heading_text_style %}h1, h2, h3, h4, h5 {
|
||||
text-transform: {{ doc.heading_text_style }};
|
||||
}{% endif %}
|
||||
|
||||
{% if doc.page_headings %}h1, h2, h3, h4, h5 {
|
||||
color: #{{ doc.page_headings }};
|
||||
}{% endif %}
|
||||
|
||||
{% if doc.page_border %}
|
||||
/* Page Border*/
|
||||
div.outer {
|
||||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
||||
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
||||
-webkibox-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
{% else %}
|
||||
{% if doc.background_color.lower() == doc.page_background.lower() %}
|
||||
div.web-footer {
|
||||
border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
padding-top: 10px;
|
||||
}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
div.web-footer, div.web-footer a {
|
||||
font-size: 90%;
|
||||
color: #{{ get_hex_shade(doc.background_color, 70) }};
|
||||
}
|
||||
|
||||
/* Bootstrap Navbar */
|
||||
.navbar-default {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
box-shadow: none;
|
||||
border-radius: 0px;
|
||||
background-color: #{{ doc.top_bar_background}};
|
||||
background-repeat: repeat-x;
|
||||
background-image: none;
|
||||
border-bottom: 1px solid {% if doc.top_bar_background.lower() == doc.page_background.lower() -%}
|
||||
#{{ get_hex_shade(doc.page_background, 15) }};
|
||||
{%- else -%}
|
||||
transparent;
|
||||
{%- endif %}
|
||||
}
|
||||
|
||||
.navbar .navbar-brand,
|
||||
.navbar .navbar-brand:hover,
|
||||
.navbar .navbar-brand:focus,
|
||||
.navbar .nav > li > a {
|
||||
color: #{{ doc.top_bar_foreground }};
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.navbar .nav > li > a:hover,
|
||||
.navbar .nav > li > a:focus {
|
||||
color: #{{ doc.top_bar_foreground }};
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.navbar .navbar-text {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.navbar .nav .active > a,
|
||||
.navbar .nav .active > a:hover,
|
||||
.navbar .nav .active > a:focus {
|
||||
color: #{{ doc.top_bar_foreground }};
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.navbar .navbar-link {
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.navbar .navbar-link:hover,
|
||||
.navbar .navbar-link:focus {
|
||||
color: #{{ doc.top_bar_foreground}};
|
||||
}
|
||||
|
||||
.navbar-fixed-top,
|
||||
.navbar-static-top {
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
|
||||
}
|
||||
.navbar .nav > .active > a,
|
||||
.navbar .nav > .active > a:hover,
|
||||
.navbar .nav > .active > a:focus {
|
||||
color: #424242;
|
||||
text-decoration: none;
|
||||
background-color: transparent;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown > .dropdown-toggle .caret,
|
||||
.navbar .nav li.dropdown > .dropdown-toggle:hover .caret {
|
||||
border-top-color: #{{ doc.top_bar_foreground}};
|
||||
border-bottom-color: #{{ doc.top_bar_foreground}};
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
|
||||
.navbar .nav li.dropdown.open > .dropdown-toggle:hover .caret {
|
||||
border-top-color: #{{ doc.top_bar_background}};
|
||||
border-bottom-color: #{{ doc.top_bar_background}};
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown.open > .dropdown-toggle {
|
||||
color: #{{ doc.top_bar_background}};
|
||||
background-color: #{{ doc.top_bar_foreground}};
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.navbar .nav-collapse .nav > li > a,
|
||||
.navbar .nav-collapse .dropdown-menu a {
|
||||
background-color: #{{ doc.top_bar_background}};
|
||||
color: #{{ doc.top_bar_foreground}};
|
||||
}
|
||||
.navbar .nav-collapse .nav > li > a:hover,
|
||||
.navbar .nav-collapse .dropdown-menu a:hover {
|
||||
background-color: #{{ doc.top_bar_foreground}};
|
||||
color: #{{ doc.top_bar_background}};
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown > .dropdown-toggle .caret {
|
||||
border-top-color: #{{ doc.top_bar_foreground }};
|
||||
border-bottom-color: #{{ doc.top_bar_foreground }};
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown > .dropdown-toggle:hover .caret {
|
||||
border-top-color: #{{ doc.top_bar_foreground }};
|
||||
border-bottom-color: #{{ doc.top_bar_foreground }};
|
||||
}
|
||||
|
||||
.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
|
||||
.navbar .nav li.dropdown.open > .dropdown-toggle:hover .caret {
|
||||
border-top-color: #{{ doc.top_bar_background }};
|
||||
border-bottom-color: #{{ doc.top_bar_background }};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.navbar-default .navbar-toggle .icon-bar {
|
||||
background-color: #{{ doc.top_bar_foreground }};
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
background-color: #{{ get_hex_shade(doc.page_background, 5) }};
|
||||
}
|
||||
|
||||
.breadcrumb > li {
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
|
||||
.table-striped tbody > tr:nth-child(odd) > td,
|
||||
.table-striped tbody > tr:nth-child(odd) > th {
|
||||
background-color: #{{ get_hex_shade(doc.page_background, 5) }};
|
||||
}
|
||||
|
||||
.table-hover tbody tr:hover td,
|
||||
.table-hover tbody tr:hover th {
|
||||
background-color: #{{ get_hex_shade(doc.page_background, 10) }};
|
||||
}
|
||||
|
||||
.table-bordered {
|
||||
border: 1px solid #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
}
|
||||
|
||||
.table-bordered th,
|
||||
.table-bordered td {
|
||||
border-left: 1px solid #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
}
|
||||
|
||||
|
||||
|
||||
.hero-unit {
|
||||
background-color: #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
}
|
||||
|
||||
pre, code {
|
||||
background-color: #{{ get_hex_shade(doc.page_background, 5) }};
|
||||
}
|
||||
|
||||
hr {
|
||||
border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }};
|
||||
border-bottom: 1px solid #{{ get_hex_shade(doc.page_background, 5) }};
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
cur_frm.cscript.onload_post_render = function() {
|
||||
wn.require('lib/public/js/lib/jscolor/jscolor.js');
|
||||
$.each(["background_color", "page_background", "page_text", "page_links",
|
||||
"top_bar_background", "top_bar_foreground", "page_headings"], function(i, v) {
|
||||
$(cur_frm.fields_dict[v].input).addClass('color');
|
||||
})
|
||||
jscolor.bind();
|
||||
}
|
@ -1,98 +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, cstr
|
||||
from webnotes import _
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
"""make custom css"""
|
||||
from jinja2 import Template
|
||||
from webnotes.webutils import get_hex_shade
|
||||
import os
|
||||
|
||||
default_colours = {
|
||||
"background_color": "FFFFFF",
|
||||
"page_background": "FFFFFF",
|
||||
"top_bar_background": "FFFFFF",
|
||||
"top_bar_foreground": "444444",
|
||||
"page_headings": "222222",
|
||||
"page_text": "000000"
|
||||
}
|
||||
|
||||
for d in default_colours:
|
||||
if not self.doc.fields.get(d):
|
||||
self.doc.fields[d] = default_colours[d]
|
||||
|
||||
self.validate_colors()
|
||||
|
||||
with open(os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'custom_template.css'), 'r') as f:
|
||||
temp = Template(f.read())
|
||||
|
||||
self.prepare()
|
||||
|
||||
self.doc.custom_css = temp.render(doc = self.doc, get_hex_shade=get_hex_shade)
|
||||
if self.doc.add_css:
|
||||
self.doc.custom_css += '\n\n/* User CSS */\n\n' + self.doc.add_css
|
||||
|
||||
from webnotes.sessions import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache()
|
||||
|
||||
for f in ["small_font_size", "at_import", "heading_text_style"]:
|
||||
if f in self.doc.fields:
|
||||
del self.doc.fields[f]
|
||||
|
||||
def validate_colors(self):
|
||||
if (self.doc.page_background or self.doc.page_text) and \
|
||||
self.doc.page_background==self.doc.page_text:
|
||||
webnotes.msgprint(_("Page text and background is same color. Please change."),
|
||||
raise_exception=1)
|
||||
|
||||
if (self.doc.top_bar_background or self.doc.top_bar_foreground) and \
|
||||
self.doc.top_bar_background==self.doc.top_bar_foreground:
|
||||
webnotes.msgprint(_("Top Bar text and background is same color. Please change."),
|
||||
raise_exception=1)
|
||||
|
||||
|
||||
def prepare(self):
|
||||
if not self.doc.font_size:
|
||||
self.doc.font_size = '13px'
|
||||
|
||||
self.doc.small_font_size = cstr(cint(self.doc.font_size[:-2])-2) + 'px'
|
||||
self.doc.page_border = cint(self.doc.page_border)
|
||||
|
||||
fonts = []
|
||||
if self.doc.google_web_font_for_heading:
|
||||
fonts.append(self.doc.google_web_font_for_heading)
|
||||
if self.doc.google_web_font_for_text:
|
||||
fonts.append(self.doc.google_web_font_for_text)
|
||||
|
||||
fonts = list(set(fonts))
|
||||
|
||||
if self.doc.heading_text_as:
|
||||
self.doc.heading_text_style = {
|
||||
"UPPERCASE": "uppercase",
|
||||
"Title Case":"capitalize",
|
||||
"lowercase": "lowercase"
|
||||
}.get(self.doc.heading_text_as) or ""
|
||||
|
||||
self.doc.at_import = ""
|
||||
for f in fonts:
|
||||
self.doc.at_import += "\n@import url(https://fonts.googleapis.com/css?family=%s:400,700);" % f.replace(" ", "+")
|
||||
|
||||
|
||||
def on_update(self):
|
||||
"""rebuild pages"""
|
||||
from website.doctype.website_settings.make_web_include_files import make
|
||||
make()
|
@ -1,201 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-25 16:01:33",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 14:57:01",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"description": "Set your background color, font and image (tiled)",
|
||||
"doctype": "DocType",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"max_attachments": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Style Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Style Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"role": "Website Manager",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Style Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "color",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Color"
|
||||
},
|
||||
{
|
||||
"description": "If image is selected, color will be ignored (attach first)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "background_image",
|
||||
"fieldtype": "Select",
|
||||
"label": "Background Image",
|
||||
"options": "attach_files:"
|
||||
},
|
||||
{
|
||||
"description": "Solid background color (default light gray)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "background_color",
|
||||
"fieldtype": "Data",
|
||||
"label": "Background Color"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_background",
|
||||
"fieldtype": "Data",
|
||||
"label": "Page Background"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_border",
|
||||
"fieldtype": "Check",
|
||||
"label": "Page Border"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_headings",
|
||||
"fieldtype": "Data",
|
||||
"label": "Page Headings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_text",
|
||||
"fieldtype": "Data",
|
||||
"label": "Page Text"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_links",
|
||||
"fieldtype": "Data",
|
||||
"label": "Page Links"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb0",
|
||||
"fieldtype": "Column Break",
|
||||
"label": "Top Bar",
|
||||
"print_width": "50%",
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "top_bar_background",
|
||||
"fieldtype": "Data",
|
||||
"label": "Top Bar Background"
|
||||
},
|
||||
{
|
||||
"description": "000 is black, fff is white",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "top_bar_foreground",
|
||||
"fieldtype": "Data",
|
||||
"label": "Top Bar Text"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "fonts",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Fonts"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "heading_font",
|
||||
"fieldtype": "Select",
|
||||
"label": "Font (Heading)",
|
||||
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "font",
|
||||
"fieldtype": "Select",
|
||||
"label": "Font (Text)",
|
||||
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "font_size",
|
||||
"fieldtype": "Select",
|
||||
"label": "Font Size (Text)",
|
||||
"options": "\n12px\n13px\n14px\n15px\n16px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "heading_text_as",
|
||||
"fieldtype": "Select",
|
||||
"label": "Heading Text As",
|
||||
"options": "\nUPPERCASE\nTitle Case\nlowercase"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_13",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"description": "Add the name of <a href=\"http://google.com/webfonts\" target=\"_blank\">Google Web Font</a> e.g. \"Open Sans\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "google_web_font_for_heading",
|
||||
"fieldtype": "Data",
|
||||
"label": "Google Web Font (Heading)"
|
||||
},
|
||||
{
|
||||
"description": "Add the name of <a href=\"http://google.com/webfonts\" target=\"_blank\">Google Web Font</a> e.g. \"Open Sans\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "google_web_font_for_text",
|
||||
"fieldtype": "Data",
|
||||
"label": "Google Web Font (Text)"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "css",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "CSS"
|
||||
},
|
||||
{
|
||||
"description": "add your own CSS (careful!)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "add_css",
|
||||
"fieldtype": "Code",
|
||||
"label": "Add CSS"
|
||||
},
|
||||
{
|
||||
"description": "Auto generated",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "custom_css",
|
||||
"fieldtype": "Code",
|
||||
"label": "Custom CSS",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Link in the header or footer of the website.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,9 +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
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
@ -1,57 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-22 01:28:08",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:25",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"in_list_view": 1,
|
||||
"name": "__common__",
|
||||
"parent": "Top Bar Item",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Top Bar Item"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "label",
|
||||
"fieldtype": "Data",
|
||||
"label": "Label",
|
||||
"print_width": "120px",
|
||||
"width": "120px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "url",
|
||||
"fieldtype": "Data",
|
||||
"label": "URL",
|
||||
"print_width": "200px",
|
||||
"width": "200px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "target",
|
||||
"fieldtype": "Select",
|
||||
"label": "Target",
|
||||
"options": "\ntarget = \"_blank\""
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "parent_label",
|
||||
"fieldtype": "Select",
|
||||
"label": "Parent Label"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Static (HTML / JS / CSS) page created by the user for the website.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1 +0,0 @@
|
||||
{% extends "app/website/templates/html/web_page.html" %}
|
@ -1,14 +0,0 @@
|
||||
{% extends "app/website/templates/html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% if insert_code %}
|
||||
{{ javascript }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-12" style="margin-top: 15px;">
|
||||
{% include "app/website/templates/html/slideshow.html" %}
|
||||
{{ main_section }}
|
||||
</div>
|
||||
{% endblock %}
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
layout: function(doc) {
|
||||
if(!doc.__islocal) {
|
||||
if(doc.insert_code) {
|
||||
if(!doc.javascript) {
|
||||
cur_frm.set_value("javascript",
|
||||
'wn.pages["'+doc.name+'"].onload = function(wrapper) { }');
|
||||
}
|
||||
}
|
||||
if(doc.insert_style) {
|
||||
if(!doc.css) {
|
||||
cur_frm.set_value("css", '#page-'+doc.name+' { }');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
refresh: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
},
|
||||
insert_style: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
},
|
||||
insert_code: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
}
|
||||
})
|
@ -1,35 +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
|
||||
|
||||
class DocType():
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def autoname(self):
|
||||
from webnotes.webutils import page_name
|
||||
self.doc.name = page_name(self.doc.title)
|
||||
|
||||
def on_update(self):
|
||||
from webnotes.webutils import update_page_name
|
||||
update_page_name(self.doc, self.doc.title)
|
||||
self.if_home_clear_cache()
|
||||
|
||||
def if_home_clear_cache(self):
|
||||
"""if home page, clear cache"""
|
||||
if webnotes.conn.get_value("Website Settings", None, "home_page")==self.doc.name:
|
||||
from webnotes.sessions import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache(self.doc.page_name)
|
||||
clear_cache('index')
|
||||
|
||||
def prepare_template_args(self):
|
||||
if self.doc.slideshow:
|
||||
from website.doctype.website_slideshow.website_slideshow import get_slideshow
|
||||
get_slideshow(self)
|
||||
|
||||
self.doc.meta_description = self.doc.description
|
@ -1,154 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-03-28 10:35:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 15:02:45",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"description": "Page to show on the website\n",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Transaction",
|
||||
"icon": "icon-file-alt",
|
||||
"max_attachments": 20,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Web Page",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Web Page",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"read": 1,
|
||||
"role": "Website Manager",
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Web Page"
|
||||
},
|
||||
{
|
||||
"description": "Title / headline of your page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb1",
|
||||
"fieldtype": "Column Break",
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "published",
|
||||
"fieldtype": "Check",
|
||||
"label": "Published"
|
||||
},
|
||||
{
|
||||
"description": "Page url name (auto-generated) (add \".html\")",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "page_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Page Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"description": "Page content",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb1",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Content"
|
||||
},
|
||||
{
|
||||
"description": "Begin this page with a slideshow of images",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "slideshow",
|
||||
"fieldtype": "Link",
|
||||
"label": "Slideshow",
|
||||
"options": "Website Slideshow"
|
||||
},
|
||||
{
|
||||
"description": "Description for page header.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"description": "Content in markdown format that appears on the main side of your page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "main_section",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Main Section"
|
||||
},
|
||||
{
|
||||
"description": "Link to other pages in the side bar and next section",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb2",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "text_align",
|
||||
"fieldtype": "Select",
|
||||
"label": "Text Align",
|
||||
"options": "Left\nCenter\nRight"
|
||||
},
|
||||
{
|
||||
"description": "Add code as <script>",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "insert_code",
|
||||
"fieldtype": "Check",
|
||||
"label": "Insert Code"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "javascript",
|
||||
"fieldtype": "Code",
|
||||
"label": "Javascript",
|
||||
"options": "Javascript"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "insert_style",
|
||||
"fieldtype": "Check",
|
||||
"label": "Insert Style"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "css",
|
||||
"fieldtype": "Code",
|
||||
"label": "CSS",
|
||||
"options": "CSS"
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Alternate grouping of parent Item (for website, so an Item can be listed under multiple groups).
|
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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
|
@ -1,37 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-22 01:28:09",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 14:54:25",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Cross Listing of Item in multiple groups",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"istable": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Item Group",
|
||||
"name": "__common__",
|
||||
"options": "Item Group",
|
||||
"parent": "Website Item Group",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Website Item Group"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Custom javascript to be appended at the end of the page. Used to include 3rd party tracking / analytics tools.
|
@ -1,16 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# 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 on_update(self):
|
||||
# make js and css
|
||||
from website.doctype.website_settings.make_web_include_files import make
|
||||
make()
|
@ -1,52 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2012-12-27 11:51:24",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-05 15:02:48",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Script to attach to all web pages.",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"icon": "icon-code",
|
||||
"issingle": 1,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "javascript",
|
||||
"fieldtype": "Code",
|
||||
"label": "Javascript",
|
||||
"name": "__common__",
|
||||
"options": "Javascript",
|
||||
"parent": "Website Script",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Website Script",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Website Script"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Overall website settings. Including banners, items appearing in the top and bottom menus, tracking code for Google Analytics etc.
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,60 +0,0 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import os
|
||||
import webnotes
|
||||
|
||||
def make():
|
||||
from startup.webutils import get_home_page
|
||||
|
||||
if not webnotes.conn:
|
||||
webnotes.connect()
|
||||
|
||||
home_page = get_home_page()
|
||||
|
||||
fname = 'js/wn-web.js'
|
||||
if os.path.basename(os.path.abspath('.'))!='public':
|
||||
fname = os.path.join('public', fname)
|
||||
|
||||
with open(fname, 'w') as f:
|
||||
f.write(get_web_script())
|
||||
|
||||
fname = 'css/wn-web.css'
|
||||
if os.path.basename(os.path.abspath('.'))!='public':
|
||||
fname = os.path.join('public', fname)
|
||||
|
||||
# style - wn.css
|
||||
with open(fname, 'w') as f:
|
||||
f.write(get_web_style())
|
||||
|
||||
def get_web_script():
|
||||
"""returns web startup script"""
|
||||
user_script = ""
|
||||
|
||||
ws = webnotes.doc("Website Settings", "Website Settings")
|
||||
|
||||
if ws.google_analytics_id:
|
||||
user_script += google_analytics_template % ws.google_analytics_id
|
||||
|
||||
user_script += (webnotes.conn.get_value('Website Script', None, 'javascript') or '')
|
||||
|
||||
return user_script
|
||||
|
||||
def get_web_style():
|
||||
"""returns web css"""
|
||||
return webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
|
||||
|
||||
google_analytics_template = """
|
||||
|
||||
// Google Analytics template
|
||||
|
||||
window._gaq = window._gaq || [];
|
||||
window._gaq.push(['_setAccount', '%s']);
|
||||
window._gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
"""
|
@ -1,64 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
// update parent select
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
refresh: function(doc) {
|
||||
cur_frm.add_custom_button("Auto Build Website", function() {
|
||||
cur_frm.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "make_website"
|
||||
})
|
||||
}, 'icon-magic')
|
||||
},
|
||||
onload_post_render: function(doc) {
|
||||
this.set_parent_label_options();
|
||||
},
|
||||
|
||||
label: function(doc, cdt, cdn) {
|
||||
var item = wn.model.get_doc(cdt, cdn);
|
||||
if(item.parentfield === "top_bar_items") {
|
||||
this.set_parent_label_options();
|
||||
}
|
||||
},
|
||||
|
||||
parent_label: function(doc, cdt, cdn) {
|
||||
this.label(doc, cdt, cdn);
|
||||
},
|
||||
|
||||
url: function(doc, cdt, cdn) {
|
||||
this.label(doc, cdt, cdn);
|
||||
},
|
||||
|
||||
set_parent_label_options: function() {
|
||||
wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options =
|
||||
this.get_parent_options("top_bar_items");
|
||||
|
||||
if($(cur_frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) {
|
||||
cur_frm.fields_dict.top_bar_items.grid.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
// get labels of parent items
|
||||
get_parent_options: function(table_field) {
|
||||
var items = getchildren('Top Bar Item', cur_frm.doc.name, table_field);
|
||||
var main_items = [''];
|
||||
for(var i in items) {
|
||||
var d = items[i];
|
||||
if(!d.parent_label && !d.url && d.label) {
|
||||
main_items.push(d.label);
|
||||
}
|
||||
}
|
||||
return main_items.join('\n');
|
||||
}
|
||||
});
|
||||
|
||||
cur_frm.cscript.set_banner_from_image = function(doc) {
|
||||
if(!doc.banner_image) {
|
||||
msgprint(wn._("Select a Banner Image first."));
|
||||
}
|
||||
var src = doc.banner_image;
|
||||
cur_frm.set_value("banner_html", "<a href='/'><img src='"+ src
|
||||
+"' style='max-width: 200px;'></a>");
|
||||
}
|
@ -1,78 +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 import _, msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
self.set_home_page()
|
||||
self.validate_top_bar_items()
|
||||
self.validate_footer_items()
|
||||
|
||||
def make_website(self):
|
||||
# set item pages
|
||||
for name in webnotes.conn.sql_list("""select name from tabItem where
|
||||
ifnull(show_in_website, 0)=0 and is_sales_item ='Yes' """):
|
||||
webnotes.msgprint("Setting 'Show in Website' for:" + name)
|
||||
item = webnotes.bean("Item", name)
|
||||
item.doc.show_in_website = 1
|
||||
item.doc.website_warehouse = item.doc.default_warehouse
|
||||
item.doc.website_image = item.doc.image
|
||||
item.save()
|
||||
|
||||
# set item group pages
|
||||
for name in webnotes.conn.sql_list("""select name from `tabItem Group` where
|
||||
ifnull(show_in_website, 0)=0 and exists (select name from tabItem where
|
||||
ifnull(show_in_website, 0)=1)"""):
|
||||
webnotes.msgprint("Setting 'Show in Website' for:" + name)
|
||||
item_group = webnotes.bean("Item Group", name)
|
||||
item_group.doc.show_in_website = 1
|
||||
item_group.save()
|
||||
|
||||
def validate_top_bar_items(self):
|
||||
"""validate url in top bar items"""
|
||||
for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}):
|
||||
if top_bar_item.parent_label:
|
||||
parent_label_item = self.doclist.get({"parentfield": "top_bar_items",
|
||||
"label": top_bar_item.parent_label})
|
||||
|
||||
if not parent_label_item:
|
||||
# invalid item
|
||||
msgprint(_(self.meta.get_label("parent_label", parentfield="top_bar_items")) +
|
||||
(" \"%s\": " % top_bar_item.parent_label) + _("does not exist"), raise_exception=True)
|
||||
|
||||
elif not parent_label_item[0] or parent_label_item[0].url:
|
||||
# parent cannot have url
|
||||
msgprint(_("Top Bar Item") + (" \"%s\": " % top_bar_item.parent_label) +
|
||||
_("cannot have a URL, because it has child item(s)"), raise_exception=True)
|
||||
|
||||
def validate_footer_items(self):
|
||||
"""clear parent label in footer"""
|
||||
for footer_item in self.doclist.get({"parentfield": "footer_items"}):
|
||||
footer_item.parent_label = None
|
||||
|
||||
def on_update(self):
|
||||
# make js and css
|
||||
from website.doctype.website_settings.make_web_include_files import make
|
||||
make()
|
||||
|
||||
# clear web cache (for menus!)
|
||||
from webnotes.webutils import clear_cache
|
||||
clear_cache()
|
||||
|
||||
def set_home_page(self):
|
||||
from webnotes.model.doc import Document
|
||||
webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""")
|
||||
|
||||
d = Document('Default Home Page')
|
||||
d.parent = 'Control Panel'
|
||||
d.parenttype = 'Control Panel'
|
||||
d.parentfield = 'default_home_pages'
|
||||
d.role = 'Guest'
|
||||
d.home_page = self.doc.home_page
|
||||
d.save()
|
@ -1,249 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-04-30 12:58:46",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-10 20:37:38",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Other",
|
||||
"icon": "icon-cog",
|
||||
"issingle": 1,
|
||||
"max_attachments": 10,
|
||||
"module": "Website",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Website Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Website Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"read": 1,
|
||||
"report": 0,
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Website Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb0",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Landing Page"
|
||||
},
|
||||
{
|
||||
"description": "The \"Web Page\" that is the website home page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "home_page",
|
||||
"fieldtype": "Link",
|
||||
"label": "Home Page",
|
||||
"options": "Web Page",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"description": "The name of your company / website as you want to appear on browser title bar. All pages will have this as the prefix to the title.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "title_prefix",
|
||||
"fieldtype": "Data",
|
||||
"label": "Title Prefix"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "cb4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"description": "If checked, the Home page will be the default Item Group for the website.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "home_page_is_products",
|
||||
"fieldtype": "Check",
|
||||
"label": "Home Page is Products"
|
||||
},
|
||||
{
|
||||
"description": "Add a banner to the site. (small banners are usually good)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "banner",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Banner"
|
||||
},
|
||||
{
|
||||
"description": "Select an image of approx width 150px with a transparent background for best results.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "banner_image",
|
||||
"fieldtype": "Select",
|
||||
"label": "Banner Image",
|
||||
"options": "attach_files:"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "set_banner_from_image",
|
||||
"fieldtype": "Button",
|
||||
"label": "Set Banner from Image"
|
||||
},
|
||||
{
|
||||
"description": "Banner is above the Top Menu Bar.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "banner_html",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Banner HTML"
|
||||
},
|
||||
{
|
||||
"description": "Menu items in the Top Bar. For setting the color of the Top Bar, go to <a href=\"#Form/Style Settings\">Style Settings</a>",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "top_bar",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Top Bar"
|
||||
},
|
||||
{
|
||||
"description": "Brand is what appears on the top-right of the toolbar. If it is an image, make sure it\nhas a transparent background and use the <img /> tag. Keep size as 200px x 30px",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "brand_html",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Brand HTML"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "top_bar_items",
|
||||
"fieldtype": "Table",
|
||||
"label": "Top Bar Items",
|
||||
"options": "Top Bar Item"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "footer",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Footer"
|
||||
},
|
||||
{
|
||||
"description": "Address and other legal information you may want to put in the footer.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "address",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Address"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "copyright",
|
||||
"fieldtype": "Data",
|
||||
"label": "Copyright"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "footer_items",
|
||||
"fieldtype": "Table",
|
||||
"label": "Footer Items",
|
||||
"options": "Top Bar Item"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "integrations",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Integrations"
|
||||
},
|
||||
{
|
||||
"description": "Add Google Analytics ID: eg. UA-89XXX57-1. Please search help on Google Analytics for more information.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "google_analytics_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "Google Analytics ID"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_17",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "google_plus_one",
|
||||
"fieldtype": "Check",
|
||||
"label": "Google Plus One"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "facebook_share",
|
||||
"fieldtype": "Check",
|
||||
"label": "Facebook Share"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "linked_in_share",
|
||||
"fieldtype": "Check",
|
||||
"label": "Linked In Share"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "twitter_share",
|
||||
"fieldtype": "Check",
|
||||
"label": "Twitter Share"
|
||||
},
|
||||
{
|
||||
"description": "Tweet will be shared via your user account (if specified)",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "twitter_share_via",
|
||||
"fieldtype": "Data",
|
||||
"label": "Twitter Share via"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "misc_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Misc"
|
||||
},
|
||||
{
|
||||
"description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [<a href=\"http://favicon-generator.org/\" target=\"_blank\">favicon-generator.org</a>]",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "favicon",
|
||||
"fieldtype": "Select",
|
||||
"label": "FavIcon",
|
||||
"options": "attach_files:"
|
||||
},
|
||||
{
|
||||
"description": "Sub-domain provided by erpnext.com",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "subdomain",
|
||||
"fieldtype": "Text",
|
||||
"label": "Subdomain",
|
||||
"read_only": 1,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_28",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"description": "Disable Customer Signup link in Login page",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "disable_signup",
|
||||
"fieldtype": "Check",
|
||||
"label": "Disable Signup"
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Website Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "All"
|
||||
}
|
||||
]
|
@ -1 +0,0 @@
|
||||
Image slide show for Web Page, Product (Item) page, Item Group page.
|
@ -1,39 +0,0 @@
|
||||
{% if slideshow %}
|
||||
{{ slideshow_header }}
|
||||
|
||||
|
||||
<div id="the-carousel" class="carousel slide">
|
||||
<!-- Indicators -->
|
||||
<ol class="carousel-indicators">
|
||||
{% for slide in obj.slides %}
|
||||
<li data-target="#the-carousel" data-slide-to="0"
|
||||
{%- if loop.index==0 %}class="active"{% endif %}></li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
|
||||
<!-- Wrapper for slides -->
|
||||
<div class="carousel-inner">
|
||||
{% for slide in obj.slides %}
|
||||
<div class="{% if slide.idx==1 %}active {% endif %}item">
|
||||
<img src="{{ slide.image }}" />
|
||||
{% if slide.heading or slide.description %}
|
||||
<div class="carousel-caption">
|
||||
{% if slide.heading %}<h4>{{ slide.heading }}</h4>{% endif %}
|
||||
{% if slide.description %}<p>{{ slide.description }}</p>{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Controls -->
|
||||
<a class="left carousel-control" href="#the-carousel" data-slide="prev">
|
||||
<span class="icon icon-chevron-left"></span>
|
||||
</a>
|
||||
<a class="right carousel-control" href="#the-carousel" data-slide="next">
|
||||
<span class="icon icon-chevron-right"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<script>$(".carousel").carousel();</script>
|
||||
{% endif %}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user