From 7b6be6c6b4caf602d476b87d3c4901ab12aee052 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 22 Mar 2017 16:38:53 +0530 Subject: [PATCH] [fix] rename jobs page to erpnext-job to avoid conflict with erpnext's job application --- .../doctype/portal_job/portal_job.json | 4 ++-- .../doctype/portal_job/portal_job.py | 6 +++--- foundation/erpnext_foundation/web_form/jobs/jobs.json | 2 +- foundation/hooks.py | 3 +-- foundation/migrate.py | 11 ++++++----- foundation/patches.txt | 1 + foundation/patches/__init__.py | 0 foundation/patches/v0_0/__init__.py | 0 foundation/patches/v0_0/update_erpnext_job_route.py | 7 +++++++ 9 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 foundation/patches/__init__.py create mode 100644 foundation/patches/v0_0/__init__.py create mode 100644 foundation/patches/v0_0/update_erpnext_job_route.py diff --git a/foundation/erpnext_foundation/doctype/portal_job/portal_job.json b/foundation/erpnext_foundation/doctype/portal_job/portal_job.json index 8d045c28..893f6212 100644 --- a/foundation/erpnext_foundation/doctype/portal_job/portal_job.json +++ b/foundation/erpnext_foundation/doctype/portal_job/portal_job.json @@ -290,7 +290,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2017-03-06 16:04:54.620681", + "modified": "2017-03-22 15:30:54.620681", "modified_by": "Administrator", "module": "ERPNext Foundation", "name": "Portal Job", @@ -321,7 +321,7 @@ "quick_entry": 1, "read_only": 0, "read_only_onload": 0, - "route": "/jobs", + "route": "/erpnext-jobs", "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", diff --git a/foundation/erpnext_foundation/doctype/portal_job/portal_job.py b/foundation/erpnext_foundation/doctype/portal_job/portal_job.py index d9d9cf94..8f98fef6 100644 --- a/foundation/erpnext_foundation/doctype/portal_job/portal_job.py +++ b/foundation/erpnext_foundation/doctype/portal_job/portal_job.py @@ -10,16 +10,16 @@ import foundation class PortalJob(WebsiteGenerator): def get_context(self, context): context.parents = [dict(label='View All Jobs', - route='jobs')] + route='erpnext-jobs')] context.is_member = foundation.is_member() def validate(self): if not self.route: - self.route = 'jobs/' + self.scrub(self.title) + self.route = 'erpnext-jobs/' + self.scrub(self.title) def get_list_context(context): context.allow_guest = True context.title = 'ERPNext Jobs' context.no_breadcrumbs = True context.order_by = 'creation desc' - context.introduction = '
Jobs for ERPNext Service Providers

' + context.introduction = '
Jobs for ERPNext Service Providers

Post A Job' diff --git a/foundation/erpnext_foundation/web_form/jobs/jobs.json b/foundation/erpnext_foundation/web_form/jobs/jobs.json index d8d46493..22aeb2ef 100644 --- a/foundation/erpnext_foundation/web_form/jobs/jobs.json +++ b/foundation/erpnext_foundation/web_form/jobs/jobs.json @@ -27,7 +27,7 @@ "route": "my-jobs", "show_sidebar": 1, "sidebar_items": [], - "success_url": "/jobs", + "success_url": "/erpnext-jobs", "title": "Jobs", "web_form_fields": [ { diff --git a/foundation/hooks.py b/foundation/hooks.py index 9c7d0a5e..18e0bef9 100644 --- a/foundation/hooks.py +++ b/foundation/hooks.py @@ -53,7 +53,7 @@ website_context = { ]}, {"label": "Community", "child_items": [ {"label": "Service Providers", "url": "/service-providers"}, - {"label": "Jobs", "url": "/jobs"}, + {"label": "Jobs", "url": "/erpnext-jobs"}, {"label": "Apps", "url": "/apps"}, {"label": "Events", "url": "/events"} ]}, @@ -69,7 +69,6 @@ website_context = { "hide_login": 1, "favicon": "/assets/frappe_theme/img/favicon.ico" } - # website user home page (by Role) # role_home_page = { # "Role": "home_page" diff --git a/foundation/migrate.py b/foundation/migrate.py index 7a75e74c..b6cb9ba3 100644 --- a/foundation/migrate.py +++ b/foundation/migrate.py @@ -10,7 +10,7 @@ def migrate(): users = source.sql('select * from tabUser', as_dict=1) for u in users: - if validate_email_add(u.email.strip()): + if validate_email_add(u.email.strip()) and not frappe.db.exists("User", u.email): frappe.get_doc(dict( doctype='User', name=u.name, @@ -23,10 +23,11 @@ def migrate(): print "sync auth" auth = source.sql('select * from __Auth where name != "Administrator"', as_dict=1) for user in auth: - frappe.db.sql("""insert into __Auth - (doctype, name, fieldname, password, salt, encrypted) - values (%s, %s, %s, %s, %s, %s)""", - (user.doctype, user.name, user.fieldname, user.password, user.salt, user.encrypted), debug=1) + if not frappe.db.sql("select doctype from __Auth where name = %s", user.name): + frappe.db.sql("""insert into __Auth + (doctype, name, fieldname, password, salt, encrypted) + values (%s, %s, %s, %s, %s, %s)""", + (user.doctype, user.name, user.fieldname, user.password, user.salt, user.encrypted)) print user.name frappe.db.sql('delete from `tabService Provider`') diff --git a/foundation/patches.txt b/foundation/patches.txt index e69de29b..0694358b 100644 --- a/foundation/patches.txt +++ b/foundation/patches.txt @@ -0,0 +1 @@ +foundation.patches.v0_0.update_erpnext_job_route \ No newline at end of file diff --git a/foundation/patches/__init__.py b/foundation/patches/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/patches/v0_0/__init__.py b/foundation/patches/v0_0/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/foundation/patches/v0_0/update_erpnext_job_route.py b/foundation/patches/v0_0/update_erpnext_job_route.py new file mode 100644 index 00000000..9e9be002 --- /dev/null +++ b/foundation/patches/v0_0/update_erpnext_job_route.py @@ -0,0 +1,7 @@ +import frappe + +def execute(): + for job in frappe.get_all("Portal Job"): + print job.name + frappe.db.set_value("Portal Job", job.name, "route", "erpnext-job/{0}".format(job.name.encode('utf-8')), + update_modified=False) \ No newline at end of file