-webnotes +frappe 💥

This commit is contained in:
Rushabh Mehta
2014-02-14 15:47:51 +05:30
parent 8ae051cb39
commit 793ba6bd37
729 changed files with 5194 additions and 9971 deletions

View File

@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint
import frappe
from frappe import msgprint
feed_dict = {
# Project
@@ -59,16 +59,16 @@ feed_dict = {
def make_feed(feedtype, doctype, name, owner, subject, color):
"makes a new Feed record"
#msgprint(subject)
from webnotes.model.doc import Document
from webnotes.utils import get_fullname
from frappe.model.doc import Document
from frappe.utils import get_fullname
if feedtype in ('Login', 'Comment', 'Assignment'):
# delete old login, comment feed
webnotes.conn.sql("""delete from tabFeed where
frappe.conn.sql("""delete from tabFeed where
datediff(curdate(), creation) > 7 and doc_type in ('Comment', 'Login', 'Assignment')""")
else:
# one feed per item
webnotes.conn.sql("""delete from tabFeed
frappe.conn.sql("""delete from tabFeed
where doc_type=%s and doc_name=%s
and ifnull(feed_type,'') != 'Comment'""", (doctype, name))

View File

@@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from frappe.model import db_exists
from frappe.model.bean import copy_doclist
@@ -15,8 +15,8 @@ class DocType:
self.doc, self.doclist = d, dl
def on_doctype_update():
if not webnotes.conn.sql("""show index from `tabFeed`
if not frappe.conn.sql("""show index from `tabFeed`
where Key_name="feed_doctype_docname_index" """):
webnotes.conn.commit()
webnotes.conn.sql("""alter table `tabFeed`
frappe.conn.commit()
frappe.conn.sql("""alter table `tabFeed`
add index feed_doctype_docname_index(doc_type, doc_name)""")

View File

@@ -1,15 +1,15 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.pages['activity'].onload = function(wrapper) {
wn.ui.make_app_page({
frappe.pages['activity'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: wn._("Activity"),
title: frappe._("Activity"),
single_column: true
})
wrapper.appframe.add_module_icon("Activity");
var list = new wn.ui.Listing({
var list = new frappe.ui.Listing({
hide_refresh: true,
appframe: wrapper.appframe,
method: 'erpnext.home.page.activity.activity.get_feed',
@@ -23,9 +23,9 @@ wn.pages['activity'].onload = function(wrapper) {
wrapper.appframe.set_title_right("Refresh", function() { list.run(); });
// Build Report Button
if(wn.boot.profile.can_get_report.indexOf("Feed")!=-1) {
wrapper.appframe.add_primary_action(wn._('Build Report'), function() {
wn.set_route('Report', "Feed");
if(frappe.boot.profile.can_get_report.indexOf("Feed")!=-1) {
wrapper.appframe.add_primary_action(frappe._('Build Report'), function() {
frappe.set_route('Report', "Feed");
}, 'icon-th')
}
}
@@ -42,12 +42,12 @@ erpnext.ActivityFeed = Class.extend({
%(link)s %(subject)s <span class="user-info">%(by)s</span></div>', data));
},
scrub_data: function(data) {
data.by = wn.user_info(data.owner).fullname;
data.imgsrc = wn.utils.get_file_link(wn.user_info(data.owner).image);
data.by = frappe.user_info(data.owner).fullname;
data.imgsrc = frappe.utils.get_file_link(frappe.user_info(data.owner).image);
// feedtype
if(!data.feed_type) {
data.feed_type = wn._(data.doc_type);
data.feed_type = frappe._(data.doc_type);
data.add_class = "label-info";
data.onclick = repl('onclick="window.location.href=\'#!List/%(feed_type)s\';"', data)
}
@@ -63,7 +63,7 @@ erpnext.ActivityFeed = Class.extend({
// link
if(data.doc_name && data.feed_type!='Login') {
data.link = wn.format(data.doc_name, {"fieldtype":"Link", "options":data.doc_type})
data.link = frappe.format(data.doc_name, {"fieldtype":"Link", "options":data.doc_type})
} else {
data.link = "";
}

View File

@@ -2,12 +2,12 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
@webnotes.whitelist()
@frappe.whitelist()
def get_feed(arg=None):
"""get feed"""
return webnotes.conn.sql("""select
return frappe.conn.sql("""select
distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner,
t1.modified
from tabFeed t1, tabDocPerm t2
@@ -16,6 +16,6 @@ def get_feed(arg=None):
and t2.permlevel = 0
and ifnull(t2.`read`,0) = 1
order by t1.modified desc
limit %s, %s""" % ("','".join(webnotes.get_roles()),
webnotes.form_dict['limit_start'], webnotes.form_dict['limit_page_length']),
limit %s, %s""" % ("','".join(frappe.get_roles()),
frappe.form_dict['limit_start'], frappe.form_dict['limit_page_length']),
as_dict=1)

View File

@@ -1 +0,0 @@
Update log.

View File

@@ -1,50 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.pages['latest-updates'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: wn._('Latest Updates'),
single_column: true
});
var parent = $(wrapper).find(".layout-main");
parent.html('<div class="progress progress-striped active">\
<div class="progress-bar" style="width: 100%;"></div></div>')
return wn.call({
method: "erpnext.home.page.latest_updates.latest_updates.get",
callback: function(r) {
parent.empty();
$("<p class='help'>"+wn._("Report issues at")+
"<a href='https://github.com/webnotes/erpnext/issues'>"+wn._("GitHub Issues")+"</a></p>\
<hr><h3>"+wn._("Commit Log")+"</h3>")
.appendTo(parent);
var $tbody = $('<table class="table table-bordered"><tbody></tbody></table>')
.appendTo(parent).find("tbody");
$.each(r.message, function(i, log) {
if(log.message.indexOf("minor")===-1
&& log.message.indexOf("docs")===-1
&& log.message.indexOf("[")!==-1) {
log.message = log.message.replace(/(\[[^\]]*\])/g,
function(match, p1, offset, string) {
match = match.toLowerCase();
var color_class = "";
$.each(["bug", "fix"], function(i, v) {
if(!color_class && match.indexOf(v)!==-1)
color_class = "label-danger";
});
return '<span class="label ' + color_class +'">' + p1.slice(1,-1) + '</span> '
});
log.repo = log.repo==="lib" ? "wnframework" : "erpnext";
$(repl('<tr>\
<td><b><a href="https://github.com/webnotes/%(repo)s/commit/%(commit)s" \
target="_blank">%(message)s</b>\
<br><span class="text-muted">By %(author)s on %(date)s</span></td></tr>', log)).appendTo($tbody);
}
})
}
})
};

View File

@@ -1,63 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes, os, subprocess, tempfile, json, datetime
@webnotes.whitelist()
def get():
with open("../app/home/page/latest_updates/latest_updates.json", "r") as lufile:
return json.loads(lufile.read())
def make():
def add_to_logs(out, repo):
out.seek(0)
last_commit = None
for l in out.readlines():
l = l.decode('utf-8')
if last_commit is not None:
if l.startswith("Date:"):
last_commit["date"] = l[8:-1]
last_commit["datetime"] = datetime.datetime.strptime(last_commit["date"][:-6], "%a %b %d %H:%M:%S %Y")
if l.startswith("Author:"):
last_commit["author"] = l[8:-1]
if l.startswith(" "):
last_commit["message"] = l[4:-1]
if l.startswith("commit"):
last_commit = {
"repo": repo,
"commit": l.split(" ")[1][:-1]
}
logs.append(last_commit)
os.chdir("lib")
logs = []
out_lib = tempfile.TemporaryFile()
subprocess.call("git --no-pager log -n 200 --no-color", shell=True, stdout=out_lib)
add_to_logs(out_lib, "lib")
os.chdir("../app")
out_app = tempfile.TemporaryFile()
subprocess.call("git --no-pager log -n 200 --no-color", shell=True, stdout=out_app)
add_to_logs(out_app, "app")
logs.sort(key=lambda a: a["datetime"], reverse=True)
for a in logs:
del a["datetime"]
for i in xrange(len(logs)):
if i and logs[i]["message"]==logs[i-1]["message"]:
logs[i]["delete"] = True
if logs[i]["message"].startswith("Merge branch") or "[" not in logs[i]["message"]:
logs[i]["delete"] = True
logs = filter(lambda a: a if not a.get("delete") else None, logs)
os.chdir("..")
with open("app/home/page/latest_updates/latest_updates.json", "w") as lufile:
lufile.write(json.dumps(logs, indent=1, sort_keys=True))
if __name__=="__main__":
make()

View File

@@ -1,33 +0,0 @@
[
{
"creation": "2012-11-19 12:06:54",
"docstatus": 0,
"modified": "2013-07-11 14:43:20",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Page",
"icon": "icon-asterisk",
"module": "Home",
"name": "__common__",
"page_name": "latest-updates",
"standard": "Yes",
"title": "Latest Updates"
},
{
"doctype": "Page Role",
"name": "__common__",
"parent": "latest-updates",
"parentfield": "roles",
"parenttype": "Page",
"role": "All"
},
{
"doctype": "Page",
"name": "latest-updates"
},
{
"doctype": "Page Role"
}
]