Browse Source

[minor] fixes for custom field and website route length

version-14
Rushabh Mehta 9 years ago
parent
commit
a9e3df6e82
3 changed files with 10 additions and 6 deletions
  1. +6
    -3
      frappe/custom/doctype/custom_field/custom_field.py
  2. +2
    -1
      frappe/utils/fixtures.py
  3. +2
    -2
      frappe/website/website_generator.py

+ 6
- 3
frappe/custom/doctype/custom_field/custom_field.py View File

@@ -33,6 +33,8 @@ class CustomField(Document):
if not self.idx: if not self.idx:
self.idx = len(fieldnames) + 1 self.idx = len(fieldnames) + 1


self._old_fieldtype = self.db_get('fieldtype')

if not self.fieldname: if not self.fieldname:
frappe.throw(_("Fieldname not set for Custom Field")) frappe.throw(_("Fieldname not set for Custom Field"))


@@ -44,9 +46,10 @@ class CustomField(Document):
validate_fields_for_doctype(self.dt) validate_fields_for_doctype(self.dt)


# update the schema # update the schema
# if not frappe.flags.in_test:
from frappe.model.db_schema import updatedb
updatedb(self.dt)
if (self.fieldname not in frappe.db.get_table_columns(self.dt)
or self._old_fieldtype != self.fieldtype):
from frappe.model.db_schema import updatedb
updatedb(self.dt)


def on_trash(self): def on_trash(self):
# delete property setter entries # delete property setter entries


+ 2
- 1
frappe/utils/fixtures.py View File

@@ -20,7 +20,8 @@ def sync_fixtures(app=None):
fixture_files = sorted(os.listdir(frappe.get_app_path(app, "fixtures"))) fixture_files = sorted(os.listdir(frappe.get_app_path(app, "fixtures")))
for fname in fixture_files: for fname in fixture_files:
if fname.endswith(".json") or fname.endswith(".csv"): if fname.endswith(".json") or fname.endswith(".csv"):
import_doc(frappe.get_app_path(app, "fixtures", fname), ignore_links=True, overwrite=True)
import_doc(frappe.get_app_path(app, "fixtures", fname),
ignore_links=True, overwrite=True)


import_custom_scripts(app) import_custom_scripts(app)




+ 2
- 2
frappe/website/website_generator.py View File

@@ -15,7 +15,7 @@ class WebsiteGenerator(Document):
website = frappe._dict( website = frappe._dict(
page_title_field = "name" page_title_field = "name"
) )
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.route = None self.route = None
super(WebsiteGenerator, self).__init__(*args, **kwargs) super(WebsiteGenerator, self).__init__(*args, **kwargs)
@@ -35,7 +35,7 @@ class WebsiteGenerator(Document):
self.route = self.make_route() self.route = self.make_route()


if self.route: if self.route:
self.route = self.route.strip('/.')
self.route = self.route.strip('/.')[:140]


def make_route(self): def make_route(self):
return self.scrub(self.get(self.website.page_title_field or "name")) return self.scrub(self.get(self.website.page_title_field or "name"))


Loading…
Cancel
Save