From 27c4079ff9de023b154f7e26a940905b266f7e52 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 3 Apr 2013 15:21:44 +0530 Subject: [PATCH] [framework] [cleanup] desktop, todo, messages, modules setup moved to framework --- config.json | 79 +++++++ home/page/activity/activity.txt | 29 ++- .../april_2013/p04_reverse_modules_list.py | 11 + patches/patch_list.py | 2 +- public/build.json | 1 - public/js/modules.js | 105 --------- public/js/startup.js | 6 +- public/js/toolbar.js | 7 +- setup/page/modules_setup/__init__.py | 1 - setup/page/modules_setup/modules_setup.css | 0 setup/page/modules_setup/modules_setup.html | 14 -- setup/page/modules_setup/modules_setup.js | 51 ----- setup/page/modules_setup/modules_setup.py | 9 - setup/page/modules_setup/modules_setup.txt | 32 --- startup/boot.py | 4 +- utilities/page/messages/__init__.py | 1 - utilities/page/messages/messages.css | 32 --- utilities/page/messages/messages.html | 0 utilities/page/messages/messages.js | 214 ------------------ utilities/page/messages/messages.py | 117 ---------- utilities/page/messages/messages.txt | 21 -- utilities/page/todo/__init__.py | 1 - utilities/page/todo/todo.css | 51 ----- utilities/page/todo/todo.html | 11 - utilities/page/todo/todo.js | 212 ----------------- utilities/page/todo/todo.py | 64 ------ utilities/page/todo/todo.txt | 21 -- 27 files changed, 116 insertions(+), 980 deletions(-) create mode 100644 config.json create mode 100644 patches/april_2013/p04_reverse_modules_list.py delete mode 100644 public/js/modules.js delete mode 100644 setup/page/modules_setup/__init__.py delete mode 100644 setup/page/modules_setup/modules_setup.css delete mode 100644 setup/page/modules_setup/modules_setup.html delete mode 100644 setup/page/modules_setup/modules_setup.js delete mode 100644 setup/page/modules_setup/modules_setup.py delete mode 100644 setup/page/modules_setup/modules_setup.txt delete mode 100644 utilities/page/messages/__init__.py delete mode 100644 utilities/page/messages/messages.css delete mode 100644 utilities/page/messages/messages.html delete mode 100644 utilities/page/messages/messages.js delete mode 100644 utilities/page/messages/messages.py delete mode 100644 utilities/page/messages/messages.txt delete mode 100644 utilities/page/todo/__init__.py delete mode 100644 utilities/page/todo/todo.css delete mode 100644 utilities/page/todo/todo.html delete mode 100644 utilities/page/todo/todo.js delete mode 100644 utilities/page/todo/todo.py delete mode 100644 utilities/page/todo/todo.txt diff --git a/config.json b/config.json new file mode 100644 index 0000000000..0f6bd0a5f9 --- /dev/null +++ b/config.json @@ -0,0 +1,79 @@ +{ + "modules": { + "Selling": { + "link": "selling-home", + "color": "#3f4901", + "icon": "icon-tag", + "type": "module" + }, + "Accounts": { + "link": "accounts-home", + "color": "#025770", + "icon": "icon-money", + "type": "module" + }, + "Stock": { + "type": "module", + "link": "stock-home", + "color": "#a66a02", + "icon": "icon-truck" + }, + "Buying": { + "type": "module", + "link": "buying-home", + "color": "#8F0222", + "icon": "icon-shopping-cart" + }, + "Support": { + "type": "module", + "link": "support-home", + "color": "#410169", + "icon": "icon-phone" + }, + "Projects": { + "type": "module", + "link": "projects-home", + "color": "#473b7f", + "icon": "icon-tasks" + }, + "Manufacturing": { + "type": "module", + "link": "manufacturing-home", + "color": "#590116", + "icon": "icon-magic" + }, + "Website": { + "type": "module", + "link": "website-home", + "color": "#968c00", + "icon": "icon-globe" + }, + "HR": { + "type": "module", + "link": "hr-home", + "color": "#018d6c", + "label": "Human Resources", + "icon": "icon-group" + }, + "Setup": { + "type": "setup", + "link": "Setup", + "color": "#484848", + "icon": "icon-wrench" + }, + "Activity": { + "type": "page", + "link": "activity", + "color": "#633501", + "icon": "icon-play", + "label": "Activity" + }, + "Knowledge Base": { + "type": "page", + "link": "questions", + "color": "#01372b", + "label": "Knowledge Base", + "icon": "icon-question-sign" + } + } +} \ No newline at end of file diff --git a/home/page/activity/activity.txt b/home/page/activity/activity.txt index ec39d011a0..57f4b7a082 100644 --- a/home/page/activity/activity.txt +++ b/home/page/activity/activity.txt @@ -1,21 +1,32 @@ [ { - "owner": "Administrator", + "creation": "2012-06-14 18:44:56", "docstatus": 0, - "creation": "2012-02-29 11:59:13", + "modified": "2013-04-03 14:59:38", "modified_by": "Administrator", - "modified": "2012-02-29 12:11:46" + "owner": "Administrator" }, { - "name": "__common__", - "title": "Activity", - "module": "Home", "doctype": "Page", + "module": "Home", + "name": "__common__", "page_name": "activity", - "standard": "Yes" + "standard": "Yes", + "title": "Activity" }, { - "name": "activity", - "doctype": "Page" + "doctype": "Page Role", + "name": "__common__", + "parent": "activity", + "parentfield": "roles", + "parenttype": "Page", + "role": "All" + }, + { + "doctype": "Page", + "name": "activity" + }, + { + "doctype": "Page Role" } ] \ No newline at end of file diff --git a/patches/april_2013/p04_reverse_modules_list.py b/patches/april_2013/p04_reverse_modules_list.py new file mode 100644 index 0000000000..9215fea5d9 --- /dev/null +++ b/patches/april_2013/p04_reverse_modules_list.py @@ -0,0 +1,11 @@ +import webnotes, json +import webnotes.utils + +def execute(): + modules = webnotes.get_config().modules + + ml = json.loads(webnotes.conn.get_global("modules_list") or "[]") + + webnotes.conn.set_global("hidden_modules", + json.dumps(list(set(modules.keys()).difference(set(ml))))) + \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 28d735c43d..4c69e303a4 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -234,5 +234,5 @@ patch_list = [ 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Classic") # 2013-04-02', 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Modern") # 2013-04-02', 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Spartan") # 2013-04-02', - + "patches.april_2013.p04_reverse_modules_list", ] \ No newline at end of file diff --git a/public/build.json b/public/build.json index 05d603f4b9..24abde20b2 100644 --- a/public/build.json +++ b/public/build.json @@ -13,7 +13,6 @@ "public/js/all-app.min.js": [ "app/public/js/startup.js", "app/public/js/conf.js", - "app/public/js/modules.js", "app/public/js/toolbar.js", "app/public/js/feature_setup.js", "app/public/js/utils.js", diff --git a/public/js/modules.js b/public/js/modules.js deleted file mode 100644 index dc9548f8d7..0000000000 --- a/public/js/modules.js +++ /dev/null @@ -1,105 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -wn.home_page = "desktop"; -wn.provide("wn.module_page"); - -$.extend(wn.modules, { - "Selling": { - link: "selling-home", - color: "#3f4901", - icon: "icon-tag" - }, - "Accounts": { - link: "accounts-home", - color: "#025770", - icon: "icon-money" - }, - "Stock": { - link: "stock-home", - color: "#a66a02", - icon: "icon-truck" - }, - "Buying": { - link: "buying-home", - color: "#8F0222", - icon: "icon-shopping-cart" - }, - "Support": { - link: "support-home", - color: "#410169", - icon: "icon-phone" - }, - "Projects": { - link: "projects-home", - color: "#473b7f", - icon: "icon-tasks" - }, - "Manufacturing": { - link: "manufacturing-home", - color: "#590116", - icon: "icon-magic" - }, - "Website": { - link: "website-home", - color: "#968c00", - icon: "icon-globe" - }, - "HR": { - link: "hr-home", - color: "#018d6c", - label: wn._("Human Resources"), - icon: "icon-group" - }, - "Setup": { - link: "Setup", - color: "#484848", - icon: "icon-wrench" - }, - "Activity": { - link: "activity", - color: "#633501", - icon: "icon-play", - label: wn._("Activity"), - }, - "To Do": { - link: "todo", - color: "#febf04", - label: wn._("To Do"), - icon: "icon-check" - }, - "Calendar": { - link: "Calendar/Event", - color: "#026584", - label: wn._("Calendar"), - icon: "icon-calendar" - }, - "Messages": { - link: "messages", - color: "#8d016e", - label: wn._("Messages"), - icon: "icon-comments" - }, - "Knowledge Base": { - link: "questions", - color: "#01372b", - label: wn._("Knowledge Base"), - icon: "icon-question-sign" - }, - -}); - -wn.provide('erpnext.module_page'); \ No newline at end of file diff --git a/public/js/startup.js b/public/js/startup.js index 1ae3feb613..0a6580be94 100644 --- a/public/js/startup.js +++ b/public/js/startup.js @@ -31,11 +31,7 @@ erpnext.startup.start = function() { if(user != 'Guest'){ erpnext.setup_mousetrap(); - - // always allow apps - wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat( - ['To Do', 'Knowledge Base', 'Calendar', 'Activity', 'Messages']) - + // setup toolbar erpnext.toolbar.setup(); diff --git a/public/js/toolbar.js b/public/js/toolbar.js index bcd2ddd388..03d7d0aba9 100644 --- a/public/js/toolbar.js +++ b/public/js/toolbar.js @@ -74,12 +74,11 @@ erpnext.toolbar.add_modules = function() { } // add to dropdown - for(var i in modules_list) { - var m = modules_list[i] - if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1 && wn.modules[m]) { + $.each(modules_list,function(i, m) { + if(m!='Setup') { $('.navbar .modules').append(_get_list_item(m)); } - } + }) // setup for system manager if(user_roles.indexOf("System Manager")!=-1) { diff --git a/setup/page/modules_setup/__init__.py b/setup/page/modules_setup/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/setup/page/modules_setup/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/setup/page/modules_setup/modules_setup.css b/setup/page/modules_setup/modules_setup.css deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/setup/page/modules_setup/modules_setup.html b/setup/page/modules_setup/modules_setup.html deleted file mode 100644 index 26130de6f8..0000000000 --- a/setup/page/modules_setup/modules_setup.html +++ /dev/null @@ -1,14 +0,0 @@ -
- × -

Modules Setup

-
-
- Select checkbox to show / hide module. -
-
-
-
- -
-
\ No newline at end of file diff --git a/setup/page/modules_setup/modules_setup.js b/setup/page/modules_setup/modules_setup.js deleted file mode 100644 index 5868b46244..0000000000 --- a/setup/page/modules_setup/modules_setup.js +++ /dev/null @@ -1,51 +0,0 @@ -wn.require('lib/js/lib/jquery/jquery.ui.sortable.js'); - -$.extend(wn.pages.modules_setup, { - modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Manufacturing', 'Projects', - 'Support', 'HR', 'Website', 'To Do', 'Messages', 'Calendar', 'Knowledge Base'], - onload: function(wrapper) { - wn.pages.modules_setup.refresh_page(JSON.parse(wn.boot.modules_list || "[]")); - }, - refresh_page: function(ml) { - $('#modules-list').empty(); - - // Hide Setup and Dashboard modules - ml.indexOf('Setup')!=-1 && ml.splice(ml.indexOf('Setup'), 1); - - // checked modules - for(i in ml) { - $('#modules-list').append(repl('

\ - \ - %(m)s

', {m:ml[i]})); - } - $('#modules-list [data-module]').attr('checked', true); - - // unchecked modules - var all = wn.pages.modules_setup.modules; - for(i in all) { - if(!$('#modules-list [data-module="'+all[i]+'"]').length) { - $('#modules-list').append(repl('

\ - \ - %(m)s

', {m:all[i]})); - } - } - - }, - update: function() { - var ml = []; - $('#modules-list [data-module]').each(function() { - if($(this).attr('checked')) - ml.push($(this).attr('data-module')); - }); - - wn.call({ - method: 'setup.page.modules_setup.modules_setup.update', - args: { - ml: JSON.stringify(ml) - }, - callback: function(r) { - }, - btn: $('#modules-update').get(0) - }); - } -}); diff --git a/setup/page/modules_setup/modules_setup.py b/setup/page/modules_setup/modules_setup.py deleted file mode 100644 index 3a3504a226..0000000000 --- a/setup/page/modules_setup/modules_setup.py +++ /dev/null @@ -1,9 +0,0 @@ -from __future__ import unicode_literals -import webnotes - -@webnotes.whitelist() -def update(arg=None): - """update modules""" - webnotes.conn.set_global('modules_list', webnotes.form_dict['ml']) - webnotes.msgprint('Updated') - webnotes.clear_cache() \ No newline at end of file diff --git a/setup/page/modules_setup/modules_setup.txt b/setup/page/modules_setup/modules_setup.txt deleted file mode 100644 index a20e9df98b..0000000000 --- a/setup/page/modules_setup/modules_setup.txt +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-06-14 15:07:28", - "modified_by": "Administrator", - "modified": "2012-10-04 16:55:31" - }, - { - "name": "__common__", - "title": "Modules Setup", - "module": "Setup", - "doctype": "Page", - "page_name": "modules_setup", - "standard": "Yes" - }, - { - "parent": "modules_setup", - "name": "__common__", - "doctype": "Page Role", - "parenttype": "Page", - "role": "System Manager", - "parentfield": "roles" - }, - { - "name": "modules_setup", - "doctype": "Page" - }, - { - "doctype": "Page Role" - } -] \ No newline at end of file diff --git a/startup/boot.py b/startup/boot.py index 574646f959..4774a903aa 100644 --- a/startup/boot.py +++ b/startup/boot.py @@ -26,9 +26,7 @@ def boot_session(bootinfo): import webnotes.model.doctype bootinfo['notification_settings'] = webnotes.doc("Notification Control", "Notification Control").get_values() - - bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') - + # if no company, show a dialog box to create a new company bootinfo['setup_complete'] = webnotes.conn.sql("""select name from tabCompany limit 1""") and 'Yes' or 'No' diff --git a/utilities/page/messages/__init__.py b/utilities/page/messages/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/utilities/page/messages/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/utilities/page/messages/messages.css b/utilities/page/messages/messages.css deleted file mode 100644 index 88bbde7e86..0000000000 --- a/utilities/page/messages/messages.css +++ /dev/null @@ -1,32 +0,0 @@ -#message-post-text { -} - -#message-list { -} - -.message { - padding: 7px; - padding-left: 17px; - border-bottom: 1px solid #ccc; -} - -.message-mark { - margin-left: -17px; - width: 9px; - position: absolute; - height: 30px; -} - -.message .help { - margin-bottom: 0px; - padding-bottom: 0px; - color: #888; - font-size: 11px; -} - -.message-other { -} - -.message-self { - background-color: #eee; -} \ No newline at end of file diff --git a/utilities/page/messages/messages.html b/utilities/page/messages/messages.html deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/utilities/page/messages/messages.js b/utilities/page/messages/messages.js deleted file mode 100644 index 4d77e16e6d..0000000000 --- a/utilities/page/messages/messages.js +++ /dev/null @@ -1,214 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -wn.provide('erpnext.messages'); - -wn.pages.messages.onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: "Messages" - }); - - $('
\ -
\ -

Everyone

\ -

\ -
\ - \ -

\ -
\ -
').appendTo($(wrapper).find('.layout-main-section')); - - wrapper.appframe.add_home_breadcrumb(); - wrapper.appframe.add_breadcrumb(wn.modules["Messages"].icon); - - erpnext.messages = new erpnext.Messages(wrapper); - erpnext.toolbar.set_new_comments(0); -} - -$(wn.pages.messages).bind('show', function() { - // remove alerts - $('#alert-container .alert').remove(); - - erpnext.toolbar.set_new_comments(0); - erpnext.messages.show(); - setTimeout("erpnext.messages.refresh()", 17000); -}) - -erpnext.Messages = Class.extend({ - init: function(wrapper) { - this.wrapper = wrapper; - this.show_active_users(); - this.make_post_message(); - this.make_list(); - //this.update_messages('reset'); //Resets notification icons - }, - make_post_message: function() { - var me = this; - $('#post-message textarea').keydown(function(e) { - if(e.which==13) { - $('#post-message .btn').click(); - return false; - } - }); - - $('#post-message .btn').click(function() { - var txt = $('#post-message textarea').val(); - if(txt) { - wn.call({ - module:'utilities', - page:'messages', - method:'post', - args: { - txt: txt, - contact: me.contact - }, - callback:function(r,rt) { - $('#post-message textarea').val('') - me.list.run(); - }, - btn: this - }); - } - }); - }, - show: function() { - var contact = this.get_contact() || this.contact || user; - - $('#message-title').html(contact==user ? "Everyone" : - wn.user_info(contact).fullname) - - $('#avatar-image').attr("src", wn.utils.get_file_link(wn.user_info(contact).image)); - - $("#show-everyone").toggle(contact!=user); - - $("#post-message button").text(contact==user ? "Post Publicly" : "Post to user") - - this.contact = contact; - this.list.opts.args.contact = contact; - this.list.run(); - - }, - // check for updates every 5 seconds if page is active - refresh: function() { - setTimeout("erpnext.messages.refresh()", 17000); - if(wn.container.page.label != 'Messages') return; - this.show(); - }, - get_contact: function() { - var route = location.hash; - if(route.indexOf('/')!=-1) { - var name = decodeURIComponent(route.split('/')[1]); - if(name.indexOf('__at__')!=-1) { - name = name.replace('__at__', '@'); - } - return name; - } - }, - make_list: function() { - this.list = new wn.ui.Listing({ - parent: $(this.wrapper).find('.all-messages'), - method: 'utilities.page.messages.messages.get_list', - args: { - contact: null - }, - hide_refresh: true, - no_loading: true, - render_row: function(wrapper, data) { - $(wrapper).removeClass('list-row'); - - data.creation = dateutil.comment_when(data.creation); - data.comment_by_fullname = wn.user_info(data.owner).fullname; - data.image = wn.utils.get_file_link(wn.user_info(data.owner).image); - data.mark_html = ""; - - data.reply_html = ''; - if(data.owner==user) { - data.cls = 'message-self'; - data.comment_by_fullname = 'You'; - } else { - data.cls = 'message-other'; - } - - // delete - data.delete_html = ""; - if(data.owner==user || data.comment.indexOf("assigned to")!=-1) { - data.delete_html = repl('×', data); - } - - if(data.owner==data.comment_docname && data.parenttype!="Assignment") { - data.mark_html = "
" - } - - wrapper.innerHTML = repl('
%(mark_html)s\ - %(comment)s\ - %(delete_html)s\ -
by %(comment_by_fullname)s, %(creation)s
\ -
\ -
', data); - } - }); - }, - delete: function(ele) { - $(ele).parent().css('opacity', 0.6); - wn.call({ - method:'utilities.page.messages.messages.delete', - args: {name : $(ele).attr('data-name')}, - callback: function() { - $(ele).parent().toggle(false); - } - }); - }, - show_active_users: function() { - var me = this; - wn.call({ - module:'utilities', - page:'messages', - method:'get_active_users', - callback: function(r,rt) { - var $body = $(me.wrapper).find('.layout-side-section'); - $('

Users


\ - \ - ').appendTo($body); - r.message.sort(function(a, b) { return b.has_session - a.has_session; }); - for(var i in r.message) { - var p = r.message[i]; - if(p.name != user) { - p.fullname = wn.user_info(p.name).fullname; - p.image = wn.utils.get_file_link(wn.user_info(p.name).image); - p.name = p.name.replace('@', '__at__'); - p.status_color = p.has_session ? "green" : "#ddd"; - p.status = p.has_session ? "Online" : "Offline"; - $(repl('

\ - \ - %(fullname)s\ -

', p)) - .appendTo($body); - } - } - } - }); - } -}); - - diff --git a/utilities/page/messages/messages.py b/utilities/page/messages/messages.py deleted file mode 100644 index 90f5e9152f..0000000000 --- a/utilities/page/messages/messages.py +++ /dev/null @@ -1,117 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes - -@webnotes.whitelist() -def get_list(arg=None): - """get list of messages""" - webnotes.form_dict['limit_start'] = int(webnotes.form_dict['limit_start']) - webnotes.form_dict['limit_page_length'] = int(webnotes.form_dict['limit_page_length']) - webnotes.form_dict['user'] = webnotes.session['user'] - - # set all messages as read - webnotes.conn.begin() - webnotes.conn.sql("""UPDATE `tabComment` - set docstatus = 1 where comment_doctype in ('My Company', 'Message') - and comment_docname = %s - """, webnotes.user.name) - webnotes.conn.commit() - - if webnotes.form_dict['contact'] == webnotes.session['user']: - # return messages - return webnotes.conn.sql("""select * from `tabComment` - where (owner=%(contact)s - or comment_docname=%(user)s - or (owner=comment_docname and ifnull(parenttype, "")!="Assignment")) - and comment_doctype ='Message' - order by creation desc - limit %(limit_start)s, %(limit_page_length)s""", webnotes.form_dict, as_dict=1) - else: - return webnotes.conn.sql("""select * from `tabComment` - where (owner=%(contact)s and comment_docname=%(user)s) - or (owner=%(user)s and comment_docname=%(contact)s) - or (owner=%(contact)s and comment_docname=%(contact)s) - and comment_doctype ='Message' - order by creation desc - limit %(limit_start)s, %(limit_page_length)s""", webnotes.form_dict, as_dict=1) - - -@webnotes.whitelist() -def get_active_users(arg=None): - return webnotes.conn.sql("""select name, - (select count(*) from tabSessions where user=tabProfile.name - and timediff(now(), lastupdate) < time("01:00:00")) as has_session - from tabProfile - where ifnull(enabled,0)=1 and - docstatus < 2 and - name not in ('Administrator', 'Guest') - order by first_name""", as_dict=1) - -@webnotes.whitelist() -def post(arg=None): - import webnotes - """post message""" - if not arg: - arg = {} - arg.update(webnotes.form_dict) - - if isinstance(arg, basestring): - import json - arg = json.loads(arg) - - from webnotes.model.doc import Document - d = Document('Comment') - d.parenttype = arg.get("parenttype") - d.comment = arg['txt'] - d.comment_docname = arg['contact'] - d.comment_doctype = 'Message' - d.save() - - import webnotes.utils - if webnotes.utils.cint(arg.get('notify')): - notify(arg) - -@webnotes.whitelist() -def delete(arg=None): - webnotes.conn.sql("""delete from `tabComment` where name=%s""", - webnotes.form_dict['name']); - -def notify(arg=None): - from webnotes.utils import cstr, get_fullname - from startup import get_url - - fn = get_fullname(webnotes.user.name) or webnotes.user.name - - url = get_url() - - message = '''You have a message from %s: - - %s - - To answer, please login to your erpnext account at \ - %s - ''' % (fn, arg['txt'], url, url) - - sender = webnotes.conn.get_value("Profile", webnotes.user.name, "email") \ - or webnotes.user.name - recipient = [webnotes.conn.get_value("Profile", arg["contact"], "email") \ - or arg["contact"]] - - from webnotes.utils.email_lib import sendmail - sendmail(recipient, sender, message, arg.get("subject") or "You have a message from %s" % (fn,)) - \ No newline at end of file diff --git a/utilities/page/messages/messages.txt b/utilities/page/messages/messages.txt deleted file mode 100644 index 32fab17f2d..0000000000 --- a/utilities/page/messages/messages.txt +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-02-24 11:21:57", - "modified_by": "Administrator", - "modified": "2012-02-24 11:21:57" - }, - { - "name": "__common__", - "title": "Messages", - "module": "Utilities", - "doctype": "Page", - "page_name": "messages", - "standard": "Yes" - }, - { - "name": "messages", - "doctype": "Page" - } -] \ No newline at end of file diff --git a/utilities/page/todo/__init__.py b/utilities/page/todo/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/utilities/page/todo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/utilities/page/todo/todo.css b/utilities/page/todo/todo.css deleted file mode 100644 index f67f729c4f..0000000000 --- a/utilities/page/todo/todo.css +++ /dev/null @@ -1,51 +0,0 @@ -.todoitem { - padding-bottom: 3px; - clear: both; -} - -.todoitem div { - float: left; - display: inline-block; - padding: 3px; -} - -.todoitem .label { - width: 50px; - margin-right: 11px; - margin-top: 3px; - text-align: center; -} - -.todoitem .todo-date { - margin-top: -2px; - margin-right: 7px; - color: #aaa; -} - -.todoitem .close { - margin-left: 5px; - font-size: 17px; -} - -.todoitem .close-span { - float: right; -} - -.todo-separator { - border-bottom: 1px solid #DEB85F; - margin-bottom: 5px; - clear: both; -} - -.todo-content { - padding-right: 15px; -} - -.todo-layout { - background-color: #FFFDC9; - min-height: 300px; -} - -.todoitem .popup-on-click { - margin: 0px 6px; -} \ No newline at end of file diff --git a/utilities/page/todo/todo.html b/utilities/page/todo/todo.html deleted file mode 100644 index e00f8ef35b..0000000000 --- a/utilities/page/todo/todo.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/utilities/page/todo/todo.js b/utilities/page/todo/todo.js deleted file mode 100644 index fa82002ea7..0000000000 --- a/utilities/page/todo/todo.js +++ /dev/null @@ -1,212 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -wn.provide('erpnext.todo'); - -erpnext.todo.refresh = function() { - wn.call({ - method: 'utilities.page.todo.todo.get', - callback: function(r,rt) { - var todo_list = $('#todo-list div.todo-content'); - var assigned_todo_list = $('#assigned-todo-list div.todo-content'); - todo_list.empty(); - assigned_todo_list.empty(); - - var nothing_to_do = function() { - $('#todo-list div.todo-content') - .html('
Nothing to do :)
'); - } - - - if(r.message) { - for(var i in r.message) { - new erpnext.todo.ToDoItem(r.message[i]); - } - if (!todo_list.html()) { nothing_to_do(); } - } else { - nothing_to_do(); - } - } - }); -} - -erpnext.todo.ToDoItem = Class.extend({ - init: function(todo) { - label_map = { - 'High': 'label-important', - 'Medium': 'label-info', - 'Low':'' - } - todo.labelclass = label_map[todo.priority]; - todo.userdate = dateutil.str_to_user(todo.date) || ''; - - todo.fullname = ''; - if(todo.assigned_by) { - var assigned_by = wn.boot.user_info[todo.assigned_by] - todo.fullname = repl("[By %(fullname)s] ".bold(), { - fullname: (assigned_by ? assigned_by.fullname : todo.assigned_by), - }); - } - - var parent_list = "#todo-list"; - if(todo.owner !== user) { - var owner = wn.boot.user_info[todo.owner]; - todo.fullname = repl("[To %(fullname)s] ".bold(), { - fullname: (owner ? owner.fullname : todo.owner), - }); - } - parent_list += " div.todo-content"; - - if(todo.reference_name && todo.reference_type) { - todo.link = repl('\ - %(reference_type)s: %(reference_name)s', todo); - } else if(todo.reference_type) { - todo.link = repl('
\ - %(reference_type)s', todo); - } else { - todo.link = ''; - } - if(!todo.description) todo.description = ''; - todo.description_display = todo.description.replace(/\n\n/g, "
").trim(); - - $(parent_list).append(repl('\ -
\ -
%(priority)s
\ - \ -
\ -
%(userdate)s
\ - %(fullname)s:\ -
\ -
%(description_display)s\ - %(link)s\ -
\ - \ -
\ -
', todo)); - $todo = $(parent_list + ' div.todoitem:last'); - - if(todo.checked) { - $todo.find('.description').css('text-decoration', 'line-through'); - } - - if(!todo.reference_type) - $todo.find('.ref_link').toggle(false); - - $todo.find('.popup-on-click') - .data('todo', todo) - .click(function() { - erpnext.todo.make_dialog($(this).data('todo')); - return false; - }); - - $todo.find('.close') - .data('name', todo.name) - .click(function() { - $(this).parent().css('opacity', 0.5); - wn.call({ - method:'utilities.page.todo.todo.delete', - args: {name: $(this).data('name')}, - callback: function() { - erpnext.todo.refresh(); - } - }); - return false; - }) - } -}); - -erpnext.todo.make_dialog = function(det) { - if(!erpnext.todo.dialog) { - var dialog = new wn.ui.Dialog({ - width: 480, - title: 'To Do', - fields: [ - {fieldtype:'Text', fieldname:'description', label:'Description', - reqd:1}, - {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, - {fieldtype:'Check', fieldname:'checked', label:'Completed'}, - {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, - {fieldtype:'Button', fieldname:'save', label:'Save (Ctrl+S)'} - ] - }); - - dialog.fields_dict.save.input.onclick = function() { - erpnext.todo.save(this); - } - erpnext.todo.dialog = dialog; - } - - if(det) { - erpnext.todo.dialog.set_values({ - date: det.date, - priority: det.priority, - description: det.description, - checked: det.checked - }); - erpnext.todo.dialog.det = det; - } - erpnext.todo.dialog.show(); - -} - -erpnext.todo.save = function(btn) { - var d = erpnext.todo.dialog; - var det = d.get_values(); - - if(!det) { - return; - } - - det.name = d.det.name || ''; - wn.call({ - method:'utilities.page.todo.todo.edit', - args: det, - btn: btn, - callback: function() { - erpnext.todo.dialog.hide(); - erpnext.todo.refresh(); - } - }); -} - -wn.pages.todo.onload = function(wrapper) { - // create app frame - wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'To Do'); - wrapper.appframe.add_home_breadcrumb(); - wrapper.appframe.add_breadcrumb(wn.modules["To Do"].icon); - wrapper.appframe.add_button('Refresh', erpnext.todo.refresh, 'icon-refresh'); - wrapper.appframe.add_button('Add', function() { - erpnext.todo.make_dialog({ - date:get_today(), priority:'Medium', checked:0, description:''}); - }, 'icon-plus'); - wrapper.appframe.add_ripped_paper_effect(wrapper); - - // show report button for System Manager - if(wn.boot.profile.roles.indexOf("System Manager") !== -1) { - wrapper.appframe.add_button("Report", function() { wn.set_route("query-report", "todo"); }, - "icon-table"); - } - - // load todos - erpnext.todo.refresh(); - - // save on click - wrapper.save_action = function() { - if(erpnext.todo.dialog && erpnext.todo.dialog.display) { - erpnext.todo.dialog.fields_dict.save.input.click(); - } - }; -} \ No newline at end of file diff --git a/utilities/page/todo/todo.py b/utilities/page/todo/todo.py deleted file mode 100644 index f0de04ec9b..0000000000 --- a/utilities/page/todo/todo.py +++ /dev/null @@ -1,64 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes -from webnotes.model.doc import Document - -@webnotes.whitelist() -def get(arg=None): - """get todo list""" - return webnotes.conn.sql("""select name, owner, description, date, - priority, checked, reference_type, reference_name, assigned_by - from `tabToDo` where (owner=%s or assigned_by=%s) - order by field(priority, 'High', 'Medium', 'Low') asc, date asc""", - (webnotes.session['user'], webnotes.session['user']), as_dict=1) - -@webnotes.whitelist() -def edit(arg=None): - import markdown2 - args = webnotes.form_dict - - d = Document('ToDo', args.get('name') or None) - d.description = args['description'] - d.date = args['date'] - d.priority = args['priority'] - d.checked = args.get('checked', 0) - if not d.owner: d.owner = webnotes.session['user'] - d.save(not args.get('name') and 1 or 0) - - if args.get('name') and d.checked: - notify_assignment(d) - - return d.name - -@webnotes.whitelist() -def delete(arg=None): - name = webnotes.form_dict['name'] - d = Document('ToDo', name) - if d and d.name and d.owner != webnotes.session['user']: - notify_assignment(d) - webnotes.conn.sql("delete from `tabToDo` where name = %s", name) - -def notify_assignment(d): - doc_type = d.reference_type - doc_name = d.reference_name - assigned_by = d.assigned_by - - if doc_type and doc_name and assigned_by: - from webnotes.widgets.form import assign_to - assign_to.notify_assignment(assigned_by, d.owner, doc_type, doc_name) - \ No newline at end of file diff --git a/utilities/page/todo/todo.txt b/utilities/page/todo/todo.txt deleted file mode 100644 index 523bb43337..0000000000 --- a/utilities/page/todo/todo.txt +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-02-23 13:59:03", - "modified_by": "Administrator", - "modified": "2012-02-23 13:59:03" - }, - { - "name": "__common__", - "title": "To Do", - "module": "Utilities", - "doctype": "Page", - "page_name": "todo", - "standard": "Yes" - }, - { - "name": "todo", - "doctype": "Page" - } -] \ No newline at end of file