added blog subscriber, unsubscribe

This commit is contained in:
Rushabh Mehta 2012-01-27 18:00:14 +05:30
parent ad10c695ff
commit 3a751e8f82
17 changed files with 190 additions and 10 deletions

View File

@ -1,6 +1,5 @@
pscript.onload_dashboard = function() {
// load jqplot
$.scriptPath = 'js/'
wn.require('lib/css/jqpot.css');
wn.require('lib/js/legacy/jquery/jquery.jqplot.min.js');
wn.require('lib/js/legacy/jquery/jqplot-plugins/jqplot.barRenderer.js');

View File

@ -16,10 +16,14 @@ def execute():
reload_doc('website', 'doctype', 'top_bar_item')
reload_doc('website', 'doctype', 'contact_us_settings')
reload_doc('website', 'doctype', 'about_us_settings')
reload_doc('website', 'doctype', 'blog')
reload_doc('website', 'doctype', 'blog_subscriber')
reload_doc('website', 'page', 'home')
reload_doc('website', 'page', 'contact')
reload_doc('website', 'page', 'about')
reload_doc('website', 'page', 'blog')
reload_doc('website', 'page', 'unsubscribe')
def add_website_manager():
"""add website manager to system manager"""

View File

@ -5,11 +5,10 @@ pscript['onload_Sales Dashboard'] = function() {
$dh(pscript.mnt_div);
$dh(pscript.mnt_div1);
//pscript.dx_axis = [];
if($.jqplot) pscript.all_onchnge();
else
// import the library
$c_js('jquery/jquery.jqplot.min.js', pscript.all_onchnge);
wn.require('lib/css/jqpot.css');
wn.require('lib/js/legacy/jquery/jquery.jqplot.min.js');
pscript.all_onchnge();
}
//=======================================================================
pscript.make_filters = function(){

View File

@ -42,7 +42,7 @@ def boot_session(bootinfo):
if webnotes.session['user']=='Guest':
bootinfo['topbar'] = webnotes.model.doc.getsingle('Top Bar Settings')
bootinfo['topbaritems'] = webnotes.conn.sql("""select label, std_page, custom_page, parent_label
from `tabTop Bar Item`""", as_dict=1)
from `tabTop Bar Item` where parent='Top Bar Settings' order by idx asc""", as_dict=1)
else:
bootinfo['letter_heads'] = get_letter_heads()

View File

@ -0,0 +1,29 @@
# DocType, Blog Subscriber
[
# These values are common in all dictionaries
{
'creation': '2012-01-27 17:18:33',
'docstatus': 0,
'modified': '2012-01-27 17:18:33',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'module': 'Website',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 1
},
# DocType, Blog Subscriber
{
'doctype': 'DocType',
'name': 'Blog Subscriber'
}
]

View File

@ -20,7 +20,7 @@ erpnext.topbar.TopBar = Class.extend({
$('header').append('<div class="topbar">\
<div class="topbar-inner">\
<div class="container">\
<a class="brand">[brand]</a>\
<a class="brand" href="#!home">[brand]</a>\
<ul class="nav">\
</ul>\
<img src="lib/images/ui/spinner.gif" id="spinner"/>\

View File

@ -0,0 +1,14 @@
<div class="layout_wrapper">
<div class="web-content" id="content-blog">
<h1>Blog</h1>
<br>
<div class="web-main-section">
</div>
<div class="web-side-section">
<h4>Get Updates</h4>
<input name="blog-subscribe">
<button class="btn" id="blog-subscribe">Subscribe</button>
</div>
<div style="clear: both"></div>
</div>
</div>

View File

@ -0,0 +1,39 @@
wn.require('lib/js/lib/prettydate.js')
pscript.onload_blog = function(wrapper) {
wrapper.blog_list = new wn.widgets.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
from tabProfile, tabBlog\
where ifnull(published,1)=1 and tabBlog.owner = tabProfile.name',
hide_refresh: true,
render_row: function(parent, data) {
if(data.content.length==300) data.content += '...';
data.date = prettyDate(data.modified);
parent.innerHTML = repl('<h4><a href="#!%(name)s">%(title)s</a></h4>\
<div class="help">By %(first_name)s %(last_name)s on %(date)s</div>\
<p><div class="comment">%(content)s</div></p><br>', data);
},
page_length: 10
});
wrapper.blog_list.run();
// subscribe button
$('#blog-subscribe').click(function() {
var email = $(wrapper).find('input[name="blog-subscribe"]').val();
if(!validate_email(email)) {
msgprint('Please enter a valid email!');
}
wn.call({
module:'website',
page:'blog',
method:'subscribe',
args:email,
btn: this,
callback: function() {
$(wrapper).find('input[name="blog-subscribe"]').val('');
}
});
})
}

View File

@ -0,0 +1,11 @@
import webnotes
def subscribe(arg):
"""subscribe to blog (blog_subscriber)"""
if webnotes.conn.sql("""select name from `tabBlog Subscriber` where name=%s""", arg):
webnotes.msgprint("Already a subscriber. Thanks!")
else:
from webnotes.model.doc import Document
d = Document('Blog Subscriber')
d.name = arg
d.save()
webnotes.msgprint("Thank you for subscribing!")

View File

@ -0,0 +1,13 @@
<div class="layout_wrapper">
<div class="web-content">
<h1>Unsubscribe</h1>
<br>
<div class="web-main-section">
<input name="unsubscribe">
<button class="btn" id="btn-unsubscribe">Unsubscribe</button>
</div>
<div class="web-side-section">
</div>
<div style="clear: both"></div>
</div>
</div>

View File

@ -0,0 +1,21 @@
pscript.onload_unsubscribe = function(wrapper) {
var email = window.location.hash.split('/').splice(-1);
$(wrapper).find('input[name="unsubscribe"]').val(email)
$('#btn-unsubscribe').click(function() {
var email = $(wrapper).find('input[name="unsubscribe"]').val();
if(email) {
var btn = this;
wn.call({
module:'website',
page:'unsubscribe',
method:'unsubscribe',
args:email,
btn: this,
callback: function() {
$(wrapper).find('input[name="unsubscribe"]').val('');
}
});
}
});
}

View File

@ -0,0 +1,8 @@
def unsubscribe(arg):
"""unsubscribe from lists"""
import webnotes
lists = [['Blog Subscriber', 'name']]
for l in lists:
webnotes.conn.sql("""delete from `tab%s` where %s=%s""" % (l[0], l[1], '%s'), arg)
webnotes.msgprint('Unsubscribed!')

View File

@ -0,0 +1,43 @@
# Page, unsubscribe
[
# These values are common in all dictionaries
{
'creation': '2012-01-27 17:19:02',
'docstatus': 0,
'modified': '2012-01-27 17:19:02',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': 'Website',
'name': '__common__',
'page_name': 'unsubscribe',
'standard': 'Yes',
'title': 'Unsubscribe'
},
# These values are common for all Page Role
{
'doctype': 'Page Role',
'name': '__common__',
'parent': 'unsubscribe',
'parentfield': 'roles',
'parenttype': 'Page',
'role': 'Guest'
},
# Page, unsubscribe
{
'doctype': 'Page',
'name': 'unsubscribe'
},
# Page Role
{
'doctype': 'Page Role'
}
]

View File

@ -3,7 +3,7 @@
<meta charset="utf-8">
<title>ERPNext</title>
<meta name="author" content="">
<script type="text/javascript">window._version_number="228";
<script type="text/javascript">window._version_number="233";
/*
* lib/js/wn/class.js

View File

@ -1 +1 @@
228
233