Browse Source

Merge branch 'master' of github.com:webnotes/wnframework

version-14
Anand Doshi 14 years ago
parent
commit
eb5a04c07d
9 changed files with 67 additions and 44 deletions
  1. +3
    -0
      .gitignore
  2. +2
    -1
      cgi-bin/core/doctype/profile/profile.py
  3. +4
    -0
      cgi-bin/core/doctype/search_criteria/search_criteria.py
  4. +28
    -15
      cgi-bin/webnotes/install_lib/install.py
  5. +25
    -1
      cgi-bin/webnotes/modules/__init__.py
  6. +0
    -24
      cgi-bin/webnotes/modules/module_manager.py
  7. +3
    -1
      cgi-bin/webnotes/utils/email_lib/form_email.py
  8. +1
    -1
      js/form.compressed.js
  9. +1
    -1
      js/widgets/form/form_container.js

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
*.pyc
*.comp.js
*.DS_Store

+ 2
- 1
cgi-bin/core/doctype/profile/profile.py View File

@@ -25,7 +25,8 @@ class DocType:
if not validate_email_add(self.doc.email):
msgprint("%s is not a valid email id" % self.doc.email)
raise Exception
self.doc.name = self.doc.email
self.doc.name = self.doc.email
def on_update(self):
# owner is always name


+ 4
- 0
cgi-bin/core/doctype/search_criteria/search_criteria.py View File

@@ -26,6 +26,10 @@ class DocType:
doctype_module = sql("select module from tabDocType where name = '%s'" % (self.doc.doc_type))
webnotes.conn.set(self.doc,'module',doctype_module and doctype_module[0][0] or 'NULL')

def validate(self):
if sql("select name from `tabSearch Criteria` where criteria_name=%s and name!=%s", (self.doc.criteria_name, self.doc.name)):
webnots.msgprint("Criteria Name '%s' already used, please use another name" % self.doc.criteria_name, raise_exception = 1)

def on_update(self):
self.set_module()
self.export_doc()


+ 28
- 15
cgi-bin/webnotes/install_lib/install.py View File

@@ -21,6 +21,10 @@ def copy_defs():
#
class Installer:
def __init__(self, root_login, root_password):

import webnotes
import webnotes.db
import webnotes.defs
self.root_password = root_password
from webnotes.model.db_schema import DbManager
@@ -29,12 +33,14 @@ class Installer:
webnotes.conn=self.conn
webnotes.session= {'user':'Administrator'}
self.dbman = DbManager(self.conn)
self.mysql_path = hasattr(defs, 'mysql_path') and webnotes.defs.mysql_path or ''
self.mysql_path = hasattr(webnotes.defs, 'mysql_path') and webnotes.defs.mysql_path or ''

#
# run framework related cleanups
#
def framework_cleanups(self, target):

import webnotes
self.dbman.drop_table('__DocTypeCache')
webnotes.conn.sql("create table `__DocTypeCache` (name VARCHAR(120), modified DATETIME, content TEXT, server_code_compiled TEXT)")

@@ -48,6 +54,7 @@ class Installer:
Imports the "Core" module from .txt file and creates
Creates profile Administrator
"""
import webnotes
from webnotes.modules.import_module import import_module
from webnotes.modules.module_manager import reload_doc

@@ -57,6 +64,10 @@ class Installer:

import_module('core')
def create_users(self):
"""
Create Administrator / Guest
"""
webnotes.conn.begin()
from webnotes.model.doc import Document
@@ -95,19 +106,13 @@ class Installer:
"""
a very simplified version, just for the time being..will eventually be deprecated once the framework stabilizes.
"""
#Storing passed source path
passed_source_path = source_path
import webnotes.defs
# get the path of the sql file to import
if not source_path:
source_path = os.path.join(os.path.sep.join(os.path.abspath(webnotes.__file__).split(os.path.sep)[:-3]), 'data', 'Framework.sql')

# delete user (if exists)
self.dbman.delete_user(target)

# create user and db
self.dbman.create_user(target,getattr(defs,'db_password',None))
self.dbman.create_user(target,getattr(webnotes.defs,'db_password',None))
if verbose: print "Created user %s" % target
# create a database
@@ -125,12 +130,20 @@ class Installer:
# import in target
if verbose: print "Starting database import..."

# get the path of the sql file to import
source_given = True
if not source_path:
source_given = False
source_path = os.path.join(os.path.sep.join(os.path.abspath(webnotes.__file__).split(os.path.sep)[:-3]), 'data', 'Framework.sql')

self.dbman.restore_database(target, source_path, self.root_password)
if verbose: print "Imported from database %s" % source_path

#If source path is passed
#i.e. importing from master sql, dont import core modules
if not passed_source_path: self.import_core_module()
if not source_given:
if verbose: print "Importing core module..."
self.import_core_module()
self.create_users()

# framework cleanups
self.framework_cleanups(target)
@@ -153,7 +166,7 @@ def make_scheduler(root_login, root_password, verbose):
dbman.delete_user('master_scheduler')

# create user and db
dbman.create_user('master_scheduler', getattr(defs,'db_password',None))
dbman.create_user('master_scheduler', getattr(webnotes.defs,'db_password',None))
if verbose: print "Created user master_scheduler"

# create a database
@@ -209,14 +222,14 @@ if __name__=='__main__':
try:
from webnotes import defs
import webnotes
import webnotes.db
import webnotes.defs
except ImportError:
copy_defs()
from webnotes import defs
import webnotes
import webnotes.db
import webnotes.defs

if len(args)==3:


+ 25
- 1
cgi-bin/webnotes/modules/__init__.py View File

@@ -62,4 +62,28 @@ def get_module_path(module):
# get module path by importing the module
modules_path = os.path.join(webnotes.defs.modules_path, scrub(module))
return modules_path
return modules_path
def switch_module(dt, dn, to, frm=None, export=None):
"""
Change the module of the given doctype, if export is true, then also export txt and copy
code files from src
"""
import os
webnotes.conn.sql("update `tab"+dt+"` set module=%s where name=%s", (to, dn))

if export:
export_doc(dt, dn)

# copy code files
if dt in ('DocType', 'Page', 'Search Criteria'):
from_path = os.path.join(get_module_path(frm), scrub(dt), scrub(dn), scrub(dn))
to_path = os.path.join(get_module_path(to), scrub(dt), scrub(dn), scrub(dn))

# make dire if exists
os.system('mkdir -p %s' % os.path.join(get_module_path(to), scrub(dt), scrub(dn)))

for ext in ('py','js','html','css'):
os.system('cp %s %s')



+ 0
- 24
cgi-bin/webnotes/modules/module_manager.py View File

@@ -1,27 +1,3 @@
#==============================================================================
# script to change the module name in the database & update svn
#==============================================================================

def change_module(dt, dn, from_module, to_module):
import os, webnotes.defs
from webnotes.modules import scrub
# change in db
webnotes.conn.sql("update `tab%s` set module=%s where name=%s" % (dt, '%s', '%s'), (to_module, dn))
# export files
from webnotes.modules.export_module import export_to_files
export_to_files(record_list = [[dt, dn]])
if dt in ['DocType','Page','Search Criteria']:
dt, dn = scrub(dt), scrub(dn)
# svn add
webnotes.msgprint(os.popen("svn add %s" % os.path.join(webnotes.defs.modules_path, scrub(to_module), dt, dn)).read())

# svn remove
webnotes.msgprint(os.popen("svn remove %s" % os.path.join(webnotes.defs.modules_path, scrub(from_module), dt, dn)).read())



#==============================================================================


+ 3
- 1
cgi-bin/webnotes/utils/email_lib/form_email.py View File

@@ -148,9 +148,11 @@ class FormEmail:
self.email.add_attachment(self.dn.replace(' ','').replace('/','-') + '.html', self.body)

# attachments
# self.with_attachments comes from http form variables
# i.e. with_attachments=1
if cint(self.with_attachments):
for a in self.set_attachments():
a and self.email.attach(a.split(',')[0])
a and self.email.attach_file(a.split(',')[0])

# cc
if self.cc:


+ 1
- 1
js/form.compressed.js View File

@@ -1,5 +1,5 @@

_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div');_f.frm_dialog=new _f.FrmDialog();}
_f.FrmContainer=function(){this.wrapper=page_body.add_page("Forms",function(){},function(){});this.last_displayed=null;$dh(this.wrapper);this.body=$a(this.wrapper,'div','frm_container');_f.frm_dialog=new _f.FrmDialog();}
_f.frm_dialog=null;_f.calling_doc_stack=[];_f.temp_access={};_f.FrmDialog=function(){var me=this;this.last_displayed=null;var d=new Dialog(640,null,'Edit Row');this.body=$a(d.body,'div','dialog_frm');$y(d.body,{backgroundColor:'#EEE'});d.done_btn_area=$a(d.body,'div','',{margin:'8px'});me.on_complete=function(){if(me.table_form){me.dialog.hide();}else{var callback=function(r){var dn=cur_frm.docname;if(!r.exc){me.dialog.hide();}
if(me.on_save_callback)
me.on_save_callback(dn);}


+ 1
- 1
js/widgets/form/form_container.js View File

@@ -5,7 +5,7 @@ _f.FrmContainer = function() {
// create hidden
$dh(this.wrapper);

this.body = $a(this.wrapper,'div');
this.body = $a(this.wrapper,'div','frm_container');
// make by twin
_f.frm_dialog = new _f.FrmDialog();


Loading…
Cancel
Save