Sfoglia il codice sorgente

[website] [minor] fixes after moving website module

version-14
Anand Doshi 12 anni fa
parent
commit
37f1c27d4b
4 ha cambiato i file con 32 aggiunte e 26 eliminazioni
  1. +21
    -20
      core/doctype/doctype/doctype.py
  2. +3
    -0
      core/doctype/page/page.py
  3. +3
    -3
      webnotes/install_lib/install.py
  4. +5
    -3
      webnotes/webutils.py

+ 21
- 20
core/doctype/doctype/doctype.py Vedi File

@@ -69,32 +69,13 @@ class DocType:
used_in = sql('select name from tabDocType where substring_index(autoname, ".", 1) = %s and name!=%s', (prefix, name)) used_in = sql('select name from tabDocType where substring_index(autoname, ".", 1) = %s and name!=%s', (prefix, name))
if used_in: 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) 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): def on_update(self):
from webnotes.model.db_schema import updatedb from webnotes.model.db_schema import updatedb
updatedb(self.doc.name) updatedb(self.doc.name)


self.change_modified_of_parent() self.change_modified_of_parent()
self.make_module_and_roles()
make_module_and_roles(self.doclist)
import conf import conf
if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0): 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_if_submittable(d)
check_level_zero_is_set(d) check_level_zero_is_set(d)
remove_report_if_single(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

+ 3
- 0
core/doctype/page/page.py Vedi File

@@ -34,6 +34,9 @@ class DocType:
it will write out a .html file it will write out a .html file
""" """
import conf 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': 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.export_file import export_to_files
from webnotes.modules import get_module_path, scrub from webnotes.modules import get_module_path, scrub


+ 3
- 3
webnotes/install_lib/install.py Vedi File

@@ -85,8 +85,6 @@ class Installer:
except ImportError, e: except ImportError, e:
install = None install = None


install and install.pre_import()
if os.path.exists("app"): if os.path.exists("app"):
sync_for("app", force=True, sync_everything=True) sync_for("app", force=True, sync_everything=True)
@@ -135,7 +133,9 @@ class Installer:
{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator', {'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator',
'parenttype':'Profile', 'parentfield':'user_roles'}, 'parenttype':'Profile', 'parentfield':'user_roles'},
{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest', {'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() webnotes.conn.begin()


+ 5
- 3
webnotes/webutils.py Vedi File

@@ -296,12 +296,14 @@ def is_signup_enabled():


def update_page_name(doc, title): def update_page_name(doc, title):
"""set page_name and check if it is unique""" """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)) _("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) delete_page_cache(doc.page_name)


def page_name(title): def page_name(title):


Caricamento…
Annulla
Salva