Selaa lähdekoodia

[hot] revert domain_settings patch

version-14
Rushabh Mehta 7 vuotta sitten
vanhempi
commit
effe13925e
3 muutettua tiedostoa jossa 34 lisäystä ja 1 poistoa
  1. +22
    -0
      frappe/core/doctype/domain/domain.py
  2. +2
    -1
      frappe/patches.txt
  3. +10
    -0
      frappe/patches/v9_1/revert_domain_settings.py

+ 22
- 0
frappe/core/doctype/domain/domain.py Näytä tiedosto

@@ -31,6 +31,28 @@ class Domain(Document):
# custom on_setup method # custom on_setup method
frappe.get_attr(self.data.on_setup)() frappe.get_attr(self.data.on_setup)()


def remove_domain(self):
'''Unset domain settings'''
self.setup_data()
for role_name in self.data.restricted_roles:
if frappe.db.exists('Role', role_name):
role = frappe.get_doc('Role', role_name)
role.disabled = 1
role.save()

if self.data.custom_fields:
for doctype in self.data.custom_fields:
custom_fields = self.data.custom_fields[doctype]

# custom_fields can be a list or dict
if isinstance(custom_fields, dict):
custom_fields = [custom_fields]

for custom_field_detail in custom_fields:
custom_field = frappe.get_doc('Custom Field',
dict(dt=doctype, fieldname=custom_field_detail.get('fieldname')))
custom_field.delete()



def setup_roles(self): def setup_roles(self):
'''Enable roles that are restricted to this domain''' '''Enable roles that are restricted to this domain'''


+ 2
- 1
frappe/patches.txt Näytä tiedosto

@@ -196,4 +196,5 @@ frappe.patches.v8_5.patch_event_colors
frappe.patches.v8_10.delete_static_web_page_from_global_search frappe.patches.v8_10.delete_static_web_page_from_global_search
frappe.patches.v8_x.add_bgn_xaf_xof_currencies frappe.patches.v8_x.add_bgn_xaf_xof_currencies
frappe.patches.v9_1.add_sms_sender_name_as_parameters frappe.patches.v9_1.add_sms_sender_name_as_parameters
frappe.patches.v9_1.resave_domain_settings
frappe.patches.v9_1.resave_domain_settings
frappe.patches.v9_1.revert_domain_settings

+ 10
- 0
frappe/patches/v9_1/revert_domain_settings.py Näytä tiedosto

@@ -0,0 +1,10 @@
import frappe

def execute():
domain_settings = frappe.get_doc('Domain Settings')
active_domains = [d.domain for d in domain_settings.active_domains]

for domain_name in ('Education', 'Healthcare', 'Hospitality'):
if domain_name not in active_domains:
domain = frappe.get_doc('Domain', domain_name)
domain.remove_domain()

Ladataan…
Peruuta
Tallenna