moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,44 @@
.qv-body {
padding: 13px;
}
.qv-input {
font-size: 14px;
height: 2.5em;
width: 100%;
}
.qv-text {
font-size: 20px;
font-weight: bold;
}
.qv-ans-input {
height: 5em;
}
.qv-ans-text {
color: #444;
line-height: 1.7em;
}
.qv-question-wrapper {
}
.qv-add-answer {
width: 50%;
margin: 7px 0px;
padding: 7px;
background-color: #E2E2EE;
display: none;
}
.qv-add-answer textarea {
height: 17em;
font-size: 12px;
}
.qv-answer {
}

View File

@@ -0,0 +1,11 @@
<div class="layout-wrapper layout-wrapper-appframe">
<div class="layout-appframe"></div>
<div class="layout-main" style="min-height: 400px">
<div class="qv-question-wrapper">
</div>
<hr>
<div class="qv-answer-wrapper">
</div>
<div class="add-answer-area"></div>
</div>
</div>

View File

@@ -0,0 +1,189 @@
// 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 <http://www.gnu.org/licenses/>.
pscript['onload_question-view'] = function(wrapper) {
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
wrapper.appframe.title('<span class="breadcrumbs"><a href="#questions">Knowledge Base</a></span>');
wrapper.add_answer_area = $('.add-answer-area').get(0);
}
pscript['refresh_question-view'] = function(wrapper) {
// href
var qid = window.location.hash.split('/')[1];
if(qid) {
pscript.question_view(qid);
}
}
pscript.question_view = function(qid, qtext) {
var w = wn.pages['question-view'];
new KBQuestionView(w, qid, qtext);
}
KBQuestionView = function(w, qid, qtext) {
var me = this;
this.make_question = function() {
$(w).find('.qv-question-wrapper').empty();
$(w.add_answer_area).empty();
new EditableText({
parent: $(w).find('.qv-question-wrapper').get(0),
dt: 'Question',
dn: qid,
fieldname: 'question',
text: qtext,
inp_class: 'qv-input',
disp_class: 'qv-text'
});
// show tags
}
// answer list
this.make_answer_list = function() {
$(w).find('.qv-answer-wrapper').empty();
this.ans_list = new KBAnswerList({
parent: $(w).find('.qv-answer-wrapper').get(0),
qid: qid
})
}
// check if users has answered
// (if no) then add a box to add a new answer
this.make_add_answer = function() {
$c_page('utilities', 'question_view', 'has_answered', qid, function(r, rt) {
if(r.message=='No') {
me.make_answer_box_link();
}
});
}
// add a link to open add answer
this.make_answer_box_link = function() {
wn.pages['question-view'].appframe.add_button('Add your answer', function() {
$(this).toggle(false);
me.make_answer_box();
}, 'icon-plus');
}
// answer box
// text area + add button
this.make_answer_box = function() {
$ds(w.add_answer_area);
$(w.add_answer_area, '<h3>Add your Answer</h3>\
<div class="help">In markdown format</div>');
this.input = $a(w.add_answer_area, 'textarea');
//wn.tinymce.add_simple(this.input);
this.btn = $btn($a(w.add_answer_area, 'div'), 'Post', function() {
var v = $(me.input).val();
if(!v) { msgprint('Write something!'); return; }
me.btn.set_working();
$c_page('utilities', 'question_view', 'add_answer', {qid: qid, answer:v},
function(r, rt) {
me.btn.done_working();
me.ans_list.list.run();
$dh(w.add_answer_area);
}
);
});
}
this.setup = function() {
if(qtext) {
this.make();
}
else {
$c_page('utilities', 'question_view', 'get_question', qid, function(r, rt) {
qtext = r.message;
me.make();
});
}
}
this.make = function() {
set_title(qtext);
this.make_question();
this.make_answer_list();
this.make_add_answer();
}
this.setup();
}
// kb answer list
KBAnswerList = function(args) {
var me = this;
$.extend(this, args);
this.make_list = function() {
wn.pages['question-view'].appframe.clear_buttons();
this.list = new wn.ui.Listing({
parent: me.parent,
appframe: wn.pages['question-view'].appframe,
as_dict: 1,
no_result_message: 'No answers yet, be the first one to answer!',
render_row: function(body, data) {
new KBAnswer(body, data, me)
},
get_query: function() {
return repl("SELECT t1.name, t1.owner, t1.answer, t1._users_voted, t2.first_name, "
+"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 "
+"where question='%(qid)s' and t1.owner = t2.name "
+"order by t1.modified desc", {qid: me.qid})
}
});
this.list.run();
}
this.make_list();
}
// kb answer
// answer
// by xxx | on xxx
KBAnswer = function(body, data, ans_list) {
body.className = 'qv-answer';
var edtxt = new EditableText({
parent: body,
dt: 'Answer',
dn: data.name,
fieldname: 'answer',
text: data.answer,
inp_class: 'qv-ans-input',
disp_class: 'qv-ans-text',
height: '300px'
});
$(edtxt.wrapper).addClass('well');
var div = $a(body, 'div', '', {})
new KBItemToolbar({
parent: div,
det: data,
with_tags: 0,
doctype: 'Answer'
}, ans_list)
}
wn.require('erpnext/utilities/page/kb_common/kb_common.js');

View File

@@ -0,0 +1,48 @@
# 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 <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
from webnotes.utils import load_json, cstr, now
@webnotes.whitelist()
def update_item(args):
args = load_json(args)
webnotes.conn.sql("update `tab%s` set `%s`=%s, modified=%s where name=%s" \
% (args['dt'], args['fn'], '%s', '%s', '%s'), (args['text'], now(), args['dn']))
@webnotes.whitelist()
def has_answered(arg):
return webnotes.conn.sql("select name from tabAnswer where owner=%s and question=%s", (webnotes.user.name, arg)) and 'Yes' or 'No'
@webnotes.whitelist()
def get_question(arg):
return cstr(webnotes.conn.sql("select question from tabQuestion where name=%s", arg)[0][0])
@webnotes.whitelist()
def add_answer(args):
args = load_json(args)
from webnotes.model.doc import Document
a = Document('Answer')
a.answer = args['answer']
a.question = args['qid']
a.points = 1
a.save(1)
webnotes.conn.set_value('Question', args['qid'], 'modified', now())

View File

@@ -0,0 +1,27 @@
# Page, question-view
[
# These values are common in all dictionaries
{
'creation': '2011-05-04 11:09:50',
'docstatus': 0,
'modified': '2011-03-29 13:54:27',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': 'Utilities',
'name': '__common__',
'page_name': 'Question View',
'standard': 'Yes'
},
# Page, question-view
{
'doctype': 'Page',
'name': 'question-view'
}
]