[website] [minor] fixes after moving website module
This commit is contained in:
parent
d9e075b2e4
commit
37f1c27d4b
4 changed files with 32 additions and 26 deletions
|
|
@ -69,32 +69,13 @@ class DocType:
|
|||
used_in = sql('select name from tabDocType where substring_index(autoname, ".", 1) = %s and name!=%s', (prefix, name))
|
||||
if used_in:
|
||||
msgprint('<b>Series already in use:</b> The series "%s" is already used in "%s"' % (prefix, used_in[0][0]), raise_exception=1)
|
||||
|
||||
def make_module_and_roles(self):
|
||||
try:
|
||||
if not webnotes.conn.exists("Module Def", self.doc.module):
|
||||
m = webnotes.bean({"doctype": "Module Def", "module_name": self.doc.module})
|
||||
m.insert()
|
||||
|
||||
for role in list(set(p.role for p in self.doclist.get({"doctype": "DocPerm"}))):
|
||||
if not webnotes.conn.exists("Role", role):
|
||||
r = webnotes.bean({"doctype": "Role", "role_name": role})
|
||||
r.doc.role_name = role
|
||||
r.insert()
|
||||
except webnotes.DoesNotExistError, e:
|
||||
pass
|
||||
except MySQLdb.ProgrammingError, e:
|
||||
if e.args[0]==1146:
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
def on_update(self):
|
||||
from webnotes.model.db_schema import updatedb
|
||||
updatedb(self.doc.name)
|
||||
|
||||
self.change_modified_of_parent()
|
||||
self.make_module_and_roles()
|
||||
make_module_and_roles(self.doclist)
|
||||
|
||||
import conf
|
||||
if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0):
|
||||
|
|
@ -315,3 +296,23 @@ def validate_permissions(permissions, for_remove=False):
|
|||
check_if_submittable(d)
|
||||
check_level_zero_is_set(d)
|
||||
remove_report_if_single(d)
|
||||
|
||||
def make_module_and_roles(doclist, perm_doctype="DocPerm"):
|
||||
try:
|
||||
if not webnotes.conn.exists("Module Def", doclist[0].module):
|
||||
m = webnotes.bean({"doctype": "Module Def", "module_name": doclist[0].module})
|
||||
m.insert()
|
||||
|
||||
roles = list(set(p.role for p in doclist.get({"doctype": perm_doctype})))
|
||||
for role in roles:
|
||||
if not webnotes.conn.exists("Role", role):
|
||||
r = webnotes.bean({"doctype": "Role", "role_name": role})
|
||||
r.doc.role_name = role
|
||||
r.insert()
|
||||
except webnotes.DoesNotExistError, e:
|
||||
pass
|
||||
except MySQLdb.ProgrammingError, e:
|
||||
if e.args[0]==1146:
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
|
@ -34,6 +34,9 @@ class DocType:
|
|||
it will write out a .html file
|
||||
"""
|
||||
import conf
|
||||
from core.doctype.doctype.doctype import make_module_and_roles
|
||||
make_module_and_roles(self.doclist, "Page Role")
|
||||
|
||||
if not webnotes.in_import and getattr(conf,'developer_mode', 0) and self.doc.standard=='Yes':
|
||||
from webnotes.modules.export_file import export_to_files
|
||||
from webnotes.modules import get_module_path, scrub
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ class Installer:
|
|||
except ImportError, e:
|
||||
install = None
|
||||
|
||||
install and install.pre_import()
|
||||
|
||||
if os.path.exists("app"):
|
||||
sync_for("app", force=True, sync_everything=True)
|
||||
|
||||
|
|
@ -135,7 +133,9 @@ class Installer:
|
|||
{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator',
|
||||
'parenttype':'Profile', 'parentfield':'user_roles'},
|
||||
{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest',
|
||||
'parenttype':'Profile', 'parentfield':'user_roles'}
|
||||
'parenttype':'Profile', 'parentfield':'user_roles'},
|
||||
|
||||
{'doctype': "Role", "role_name": "Report Manager"}
|
||||
]
|
||||
|
||||
webnotes.conn.begin()
|
||||
|
|
|
|||
|
|
@ -296,12 +296,14 @@ def is_signup_enabled():
|
|||
|
||||
def update_page_name(doc, title):
|
||||
"""set page_name and check if it is unique"""
|
||||
webnotes.conn.set(doc, "page_name", page_name(title))
|
||||
new_page_name = page_name(title)
|
||||
|
||||
if doc.page_name in get_all_pages():
|
||||
webnotes.throw("%s: %s. %s: %s" % (doc.page_name, _("Page already exists"),
|
||||
if new_page_name in get_all_pages():
|
||||
webnotes.throw("%s: %s. %s: %s" % (new_page_name, _("Page already exists"),
|
||||
_("Please change the value"), title))
|
||||
|
||||
if doc.page_name: delete_page_cache(doc.page_name)
|
||||
webnotes.conn.set(doc, "page_name", new_page_name)
|
||||
delete_page_cache(doc.page_name)
|
||||
|
||||
def page_name(title):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue