Ejemplo n.º 1
0
def reset_perms(site=None):
    webnotes.connect(site=site)
    for d in webnotes.conn.sql_list("""select name from `tabDocType`
		where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
        webnotes.clear_cache(doctype=d)
        webnotes.reset_perms(d)
    webnotes.destroy()
Ejemplo n.º 2
0
def reset_perms(site=None):
	webnotes.connect(site=site)
	for d in webnotes.conn.sql_list("""select name from `tabDocType`
		where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
			webnotes.clear_cache(doctype=d)
			webnotes.reset_perms(d)
	webnotes.destroy()
Ejemplo n.º 3
0
def execute():
	webnotes.reload_doc("core", "doctype", "file_data")
	webnotes.reset_perms("File Data")
	
	singles = get_single_doctypes()
	
	for doctype in webnotes.conn.sql_list("""select parent from tabDocField where 
		fieldname='file_list'"""):
		# the other scenario is handled in p07_update_file_data_2
		if doctype in singles:
			update_file_list(doctype, singles)
Ejemplo n.º 4
0
def execute():
	webnotes.reload_doc("core", "doctype", "file_data")
	webnotes.reset_perms("File Data")
	
	singles = get_single_doctypes()
	
	for doctype in webnotes.conn.sql_list("""select parent from tabDocField where 
		fieldname='file_list'"""):
		update_file_list(doctype, singles)
		
		webnotes.conn.sql("""delete from tabDocField where fieldname='file_list'
				and parent=%s""", doctype)
Ejemplo n.º 5
0
def execute():
	webnotes.reload_doc("utilities", "doctype", "address")

	webnotes.conn.sql("""update tabAddress set address_title = customer_name where ifnull(customer_name,'')!=''""")
	webnotes.conn.sql("""update tabAddress set address_title = supplier_name where ifnull(supplier_name,'')!=''""")
	webnotes.conn.sql("""update tabAddress set address_title = sales_partner where ifnull(sales_partner,'')!=''""")

	webnotes.reload_doc("website", "doctype", "product_settings")
	webnotes.reset_perms("Product Settings")
	
	# move code to new doctype
	webnotes.conn.set_value("Website Script", None, "javascript", 
		webnotes.conn.get_value("Website Settings", None, "startup_code"))
Ejemplo n.º 6
0
def execute():
    webnotes.reload_doc("utilities", "doctype", "address")

    webnotes.conn.sql(
        """update tabAddress set address_title = customer_name where ifnull(customer_name,'')!=''"""
    )
    webnotes.conn.sql(
        """update tabAddress set address_title = supplier_name where ifnull(supplier_name,'')!=''"""
    )
    webnotes.conn.sql(
        """update tabAddress set address_title = sales_partner where ifnull(sales_partner,'')!=''"""
    )

    webnotes.reload_doc("website", "doctype", "product_settings")
    webnotes.reset_perms("Product Settings")

    # move code to new doctype
    webnotes.conn.set_value(
        "Website Script", None, "javascript",
        webnotes.conn.get_value("Website Settings", None, "startup_code"))
Ejemplo n.º 7
0
			if f.endswith(".json"):
				with open(f, "r") as infile:
					b = webnotes.bean(json.loads(infile.read())).insert_or_update()
					print "Imported: " + b.doc.doctype + " / " + b.doc.name
					webnotes.conn.commit()
			if f.endswith(".csv"):
				from core.page.data_import_tool.data_import_tool import import_file_by_path
				import_file_by_path(f, ignore_links=True)
				webnotes.conn.commit()

	elif options.reset_perms:
		for d in webnotes.conn.sql_list("""select name from `tabDocType`
			where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
				try:
					webnotes.clear_cache(doctype=d)
					webnotes.reset_perms(d)
				except:
					pass
					
	elif options.make_conf:
		if os.path.exists("conf.py"):
			os.system("mv conf.py conf.py.bak")
		
		with open("lib/conf/conf.py", "r") as confsrc:
			confstr = confsrc.read()
	
		db_name = raw_input("Database Name: ")
		if not db_name:
			print "Database Name Required"
			return
			
def execute():
    webnotes.reset_perms("Custom Script")
Ejemplo n.º 9
0
def reset(doctype):
    webnotes.reset_perms(doctype)
    webnotes.clear_cache(doctype=doctype)
    webnotes.defaults.clear_cache()
Ejemplo n.º 10
0
def run():
	sys.path.append('.')
	sys.path.append('lib')
	sys.path.append('app')

	(options, args) = setup_options()
	
	# build
	if options.build:
		from webnotes import build
		if options.no_cms:
			cms_make = False
		else:
			cms_make = True
		build.bundle(False, cms_make)
		return
		
	elif options.watch:
		from webnotes import build
		build.watch(True)
		return

	# code replace
	elif options.replace:
		print options.replace
		replace_code('.', options.replace[0], options.replace[1], options.replace[2], force=options.force)
		return
	
	# git
	elif options.status:
		os.chdir('lib')
		os.system('git status')
		os.chdir('../app')
		os.system('git status')
		return

	elif options.git:
		os.chdir('lib')
		os.system('git %s' % options.git)
		os.chdir('../app')
		os.system('git %s' % options.git)
		return
		
	import webnotes
	import conf
	from webnotes.db import Database
	import webnotes.modules.patch_handler
	webnotes.print_messages = True
	
	# connect
	if options.db_name is not None:
		if options.password:
			webnotes.connect(options.db_name, options.password)
		else:
			webnotes.connect(options.db_name)
	elif not any([options.install, options.pull, options.install_fresh]):
		webnotes.connect(conf.db_name)

	if options.pull:
		pull(options.pull[0], options.pull[1], build=True)

	elif options.commit:
		os.chdir('lib')
		os.system('git commit -a -m "%s"' % (options.commit))
		os.chdir('../app')
		os.system('git commit -a -m "%s"' % (options.commit))

	elif options.push:
		if not args:
			args = ["origin", conf.branch]
		
		os.chdir('lib')
		os.system('git push %s %s' % (args[0], args[1]))
		os.chdir('../app')
		os.system('git push %s %s' % (args[0], args[1]))
				
	elif options.checkout:
		os.chdir('lib')
		os.system('git checkout %s' % options.checkout)
		os.chdir('../app')
		os.system('git checkout %s' % options.checkout)
			
	# patch
	elif options.patch_list:
		# clear log
		webnotes.modules.patch_handler.log_list = []
		
		# run individual patches
		for patch in options.patch_list:
			webnotes.modules.patch_handler.run_single(\
				patchmodule = patch, force = options.force)
		
		print '\n'.join(webnotes.modules.patch_handler.log_list)
	
		# reload
	elif options.reload_doc:
		webnotes.modules.patch_handler.reload_doc(\
			{"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]})		
		print '\n'.join(webnotes.modules.patch_handler.log_list)

	elif options.export_doc:
		from webnotes.modules import export_doc
		export_doc(options.export_doc[0], options.export_doc[1])

	# run all pending
	elif options.run_latest:
		apply_latest_patches()
	
	elif options.install:
		from webnotes.install_lib.install import Installer
		inst = Installer('root')
		inst.import_from_db(options.install[0], source_path=options.install[1],
			verbose = 1)

	elif options.install_fresh:
		from webnotes.install_lib.install import Installer
		inst = Installer('root')
		inst.import_from_db(options.install_fresh, verbose = 1)

	elif options.make_demo:
		import utilities.make_demo
		utilities.make_demo.make()

	elif options.make_demo_fresh:
		import utilities.make_demo
		utilities.make_demo.make(True)

	elif options.diff_ref_file is not None:
		import webnotes.modules.diff
		webnotes.modules.diff.diff_ref_file()

	elif options.diff_ref_db is not None:
		import webnotes.modules.diff
		webnotes.modules.diff.diff_ref_db()
	
	elif options.run_scheduler:
		import webnotes.utils.scheduler
		print webnotes.utils.scheduler.execute()
	
	elif options.run_scheduler_event is not None:
		import webnotes.utils.scheduler
		print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
		
	elif options.sync_all is not None:
		sync_all(options.force or 0)

	elif options.sync is not None:
		webnotes.reload_doc(options.sync[0], "doctype", options.sync[1])
	
	elif options.update:
		if not args:
			args = ["origin", conf.branch]
			
		update_erpnext(args[0], args[1])
		
	elif options.patch_sync_build:
		patch_sync_build()
	
	elif options.patch_sync:
		patch_sync()

	elif options.cleanup_data:
		from utilities import cleanup_data
		cleanup_data.run()
		
	elif options.domain:
		webnotes.conn.set_value('Website Settings', None, 'subdomain', options.domain)
		webnotes.conn.commit()
		print "Domain set to", options.domain
		
	elif options.clear_web:
		# build wn-web.js and wn-web.css
		from website.helpers.make_web_include_files import make
		make()
	
		import webnotes.webutils
		webnotes.webutils.clear_cache()
		
	elif options.clear_cache:
		clear_cache()
		
	elif options.clear_defaults:
		import webnotes.defaults
		webnotes.defaults.clear_cache()
		webnotes.clear_cache()
		
	elif options.append_future_import:
		append_future_import()

	elif options.backup:
		from webnotes.utils.backups import scheduled_backup
		scheduled_backup(ignore_files = True)
		
	# print messages
	if webnotes.message_log:
		print '\n'.join(webnotes.message_log)
		
	elif options.build_message_files:
		import webnotes.translate
		webnotes.translate.build_message_files()
		
	elif options.export_messages:
		import webnotes.translate
		webnotes.translate.export_messages(*options.export_messages)

	elif options.import_messages:
		import webnotes.translate
		webnotes.translate.import_messages(*options.import_messages)
	
	elif options.google_translate:
		from webnotes.translate import google_translate
		google_translate(*options.google_translate)
	
	elif options.translate:
		from webnotes.translate import translate
		translate(options.translate)
		
	elif options.docs:
		from core.doctype.documentation_tool.documentation_tool import write_static
		write_static()

	elif options.reset_perms:
		for d in webnotes.conn.sql_list("""select name from `tabDocType`
			where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
				try:
					webnotes.clear_cache(doctype=d)
					webnotes.reset_perms(d)
				except:
					pass
Ejemplo n.º 11
0
def reset(doctype):
    webnotes.only_for(("System Manager", "Administrator"))
    webnotes.reset_perms(doctype)
    clear_doctype_cache(doctype)
    webnotes.defaults.clear_cache()
Ejemplo n.º 12
0
def reset(doctype):
	webnotes.reset_perms(doctype)
	clear_doctype_cache(doctype)
	webnotes.defaults.clear_cache()
def execute():
	webnotes.reset_perms("Custom Script")
Ejemplo n.º 14
0
def execute():
	webnotes.reload_doc("core", "doctype", "docperm")
	webnotes.reset_perms("Custom Script")
Ejemplo n.º 15
0
def reset(doctype):
    webnotes.reset_perms(doctype)
    webnotes.clear_cache(doctype=doctype)
Ejemplo n.º 16
0
def reset(doctype):
	webnotes.only_for("System Manager")
	webnotes.reset_perms(doctype)
	clear_doctype_cache(doctype)
Ejemplo n.º 17
0
def reset(doctype):
	webnotes.only_for(("System Manager", "Administrator"))
	webnotes.reset_perms(doctype)
	clear_doctype_cache(doctype)
	webnotes.defaults.clear_cache()
def execute():
    webnotes.reset_perms("Appraisal")
Ejemplo n.º 19
0
def run():
    sys.path.append('.')
    sys.path.append('lib')
    sys.path.append('app')

    (options, args) = setup_options()

    # build
    if options.build:
        from webnotes import build
        if options.no_cms:
            cms_make = False
        else:
            cms_make = True
        build.bundle(False, cms_make)
        return

    elif options.watch:
        from webnotes import build
        build.watch(True)
        return

    # code replace
    elif options.replace:
        print options.replace
        replace_code('.',
                     options.replace[0],
                     options.replace[1],
                     options.replace[2],
                     force=options.force)
        return

    # git
    elif options.status:
        os.chdir('lib')
        os.system('git status')
        os.chdir('../app')
        os.system('git status')
        return

    elif options.git:
        os.chdir('lib')
        os.system('git %s' % options.git)
        os.chdir('../app')
        os.system('git %s' % options.git)
        return

    import webnotes
    import conf
    from webnotes.db import Database
    import webnotes.modules.patch_handler
    webnotes.print_messages = True

    # connect
    if options.db_name is not None:
        if options.password:
            webnotes.connect(options.db_name, options.password)
        else:
            webnotes.connect(options.db_name)
    elif not any([options.install, options.pull, options.install_fresh]):
        webnotes.connect(conf.db_name)

    if options.pull:
        pull(options.pull[0], options.pull[1], build=True)

    elif options.commit:
        os.chdir('lib')
        os.system('git commit -a -m "%s"' % (options.commit))
        os.chdir('../app')
        os.system('git commit -a -m "%s"' % (options.commit))

    elif options.push:
        if not args:
            args = ["origin", conf.branch]

        os.chdir('lib')
        os.system('git push %s %s' % (args[0], args[1]))
        os.chdir('../app')
        os.system('git push %s %s' % (args[0], args[1]))

    elif options.checkout:
        os.chdir('lib')
        os.system('git checkout %s' % options.checkout)
        os.chdir('../app')
        os.system('git checkout %s' % options.checkout)

    # patch
    elif options.patch_list:
        # clear log
        webnotes.modules.patch_handler.log_list = []

        # run individual patches
        for patch in options.patch_list:
            webnotes.modules.patch_handler.run_single(\
             patchmodule = patch, force = options.force)

        print '\n'.join(webnotes.modules.patch_handler.log_list)

        # reload
    elif options.reload_doc:
        webnotes.modules.patch_handler.reload_doc(\
         {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]})
        print '\n'.join(webnotes.modules.patch_handler.log_list)

    elif options.export_doc:
        from webnotes.modules import export_doc
        export_doc(options.export_doc[0], options.export_doc[1])

    # run all pending
    elif options.run_latest:
        apply_latest_patches()

    elif options.install:
        from webnotes.install_lib.install import Installer
        inst = Installer('root')
        inst.import_from_db(options.install[0],
                            source_path=options.install[1],
                            verbose=1)

    elif options.install_fresh:
        from webnotes.install_lib.install import Installer
        inst = Installer('root')
        inst.import_from_db(options.install_fresh, verbose=1)

    elif options.make_demo:
        import utilities.make_demo
        utilities.make_demo.make()

    elif options.make_demo_fresh:
        import utilities.make_demo
        utilities.make_demo.make(True)

    elif options.diff_ref_file is not None:
        import webnotes.modules.diff
        webnotes.modules.diff.diff_ref_file()

    elif options.diff_ref_db is not None:
        import webnotes.modules.diff
        webnotes.modules.diff.diff_ref_db()

    elif options.run_scheduler:
        import webnotes.utils.scheduler
        print webnotes.utils.scheduler.execute()

    elif options.run_scheduler_event is not None:
        import webnotes.utils.scheduler
        print webnotes.utils.scheduler.trigger('execute_' +
                                               options.run_scheduler_event)

    elif options.sync_all is not None:
        sync_all(options.force or 0)

    elif options.sync is not None:
        webnotes.reload_doc(options.sync[0], "doctype", options.sync[1])

    elif options.update:
        if not args:
            args = ["origin", conf.branch]

        update_erpnext(args[0], args[1])

    elif options.patch_sync_build:
        patch_sync_build()

    elif options.patch_sync:
        patch_sync()

    elif options.cleanup_data:
        from utilities import cleanup_data
        cleanup_data.run()

    elif options.domain:
        webnotes.conn.set_value('Website Settings', None, 'subdomain',
                                options.domain)
        webnotes.conn.commit()
        print "Domain set to", options.domain

    elif options.clear_web:
        # build wn-web.js and wn-web.css
        from website.helpers.make_web_include_files import make
        make()

        import webnotes.webutils
        webnotes.webutils.clear_cache()

    elif options.clear_cache:
        clear_cache()

    elif options.clear_defaults:
        import webnotes.defaults
        webnotes.defaults.clear_cache()
        webnotes.clear_cache()

    elif options.append_future_import:
        append_future_import()

    elif options.backup:
        from webnotes.utils.backups import scheduled_backup
        scheduled_backup(ignore_files=True)

    # print messages
    if webnotes.message_log:
        print '\n'.join(webnotes.message_log)

    elif options.build_message_files:
        import webnotes.translate
        webnotes.translate.build_message_files()

    elif options.export_messages:
        import webnotes.translate
        webnotes.translate.export_messages(*options.export_messages)

    elif options.import_messages:
        import webnotes.translate
        webnotes.translate.import_messages(*options.import_messages)

    elif options.google_translate:
        from webnotes.translate import google_translate
        google_translate(*options.google_translate)

    elif options.translate:
        from webnotes.translate import translate
        translate(options.translate)

    elif options.docs:
        from core.doctype.documentation_tool.documentation_tool import write_static
        write_static()

    elif options.reset_perms:
        for d in webnotes.conn.sql_list("""select name from `tabDocType`
			where ifnull(istable, 0)=0 and ifnull(custom, 0)=0"""):
            try:
                webnotes.clear_cache(doctype=d)
                webnotes.reset_perms(d)
            except:
                pass