Removal of SMS Settings and SMS Parameters from ERPNext (#10033)
* Removal of SMS Settings and SMS Parameter from ERPNext.
* [DOCS]Documentation for Two Factor Authentication
* [Patch]Point SMS module to frappe core
* Rearrange doc help index.txt to fit
* [DOCS]Update Documentation for Two Factor Authentication
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-1.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-1.png
new file mode 100644
index 0000000..6dd17f0
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-1.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-2.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-2.png
new file mode 100644
index 0000000..c884213
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-2.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-3.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-3.png
new file mode 100644
index 0000000..56eee8c
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-3.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-4.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-4.png
new file mode 100644
index 0000000..6d8ecab
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-4.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-5.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-5.png
new file mode 100644
index 0000000..1c39e94
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-5.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-6.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-6.png
new file mode 100644
index 0000000..d62ba53
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-6.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor-8.png b/erpnext/docs/assets/img/articles/twofactor/twofactor-8.png
new file mode 100644
index 0000000..84cf5fa
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor-8.png
Binary files differ
diff --git a/erpnext/docs/assets/img/articles/twofactor/twofactor_app.jpeg b/erpnext/docs/assets/img/articles/twofactor/twofactor_app.jpeg
new file mode 100644
index 0000000..ae5e930
--- /dev/null
+++ b/erpnext/docs/assets/img/articles/twofactor/twofactor_app.jpeg
Binary files differ
diff --git a/erpnext/docs/assets/img/setup-wizard/twofactor.png b/erpnext/docs/assets/img/setup-wizard/twofactor.png
new file mode 100644
index 0000000..ada4f5b
--- /dev/null
+++ b/erpnext/docs/assets/img/setup-wizard/twofactor.png
Binary files differ
diff --git a/erpnext/docs/assets/img/setup/settings/twofactor-settings.png b/erpnext/docs/assets/img/setup/settings/twofactor-settings.png
new file mode 100644
index 0000000..c56f304
--- /dev/null
+++ b/erpnext/docs/assets/img/setup/settings/twofactor-settings.png
Binary files differ
diff --git a/erpnext/docs/user/manual/en/setting-up/articles/index.txt b/erpnext/docs/user/manual/en/setting-up/articles/index.txt
index e6a3b85..eb4d119 100644
--- a/erpnext/docs/user/manual/en/setting-up/articles/index.txt
+++ b/erpnext/docs/user/manual/en/setting-up/articles/index.txt
@@ -9,4 +9,5 @@
naming-series-current-value
overwriting-data-from-data-import-tool
rename-user
-using-custom-domain-on-erpnext
\ No newline at end of file
+using-custom-domain-on-erpnext
+setup-two-factor-authentication
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/setting-up/articles/setup-two-factor-authentication.md b/erpnext/docs/user/manual/en/setting-up/articles/setup-two-factor-authentication.md
new file mode 100644
index 0000000..cdb4e34
--- /dev/null
+++ b/erpnext/docs/user/manual/en/setting-up/articles/setup-two-factor-authentication.md
@@ -0,0 +1,41 @@
+#Setup Two Factor Authentication
+
+##Enable Two Factor Authentication (2FA)
+
+Activate two factor authentication by running the command.
+
+`bench --site [sitename] enable_two_factor_auth true`
+
+Specify the following in System Settings
+
+* The method of OTP validation (OTP App = TOTP using Soft or Hard Token while Email/SMS = HOTP using Email or SMS
+* The expiry time for the QR Code on the server if OTP App is specified
+* The OTP Issuer Name.
+
+<img alt="Enable Two Factor Auth" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-1.png">
+
+
+On activation of 2FA from setup, it is also activated for the Role "All". In this way, all users including the Administrator have to perform a 2nd level authentication with a token. By unchecking the "Two Factor Authentication" checkbox in the "All" role and enabling it in other roles, the need to login with a token can be limited to specific roles. 2FA does not apply to login by Web Users and API login
+
+<img alt="Role Enable Two Factor Auth" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-2.png">
+
+If using SMS authentication, please make sure that your SMS settings are updated
+
+<img alt="SMS Settings" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-3.png">
+
+If using Email, make sure that your outgoing Email account settings are updated
+
+<img alt="Email Settings" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-4.png">
+
+When the new user tries to log in for the first time in a system that has two-factor authentication enabled and which has the authentication option as OTP App, an email is sent containing a link to the QR Code.
+
+<img alt="Email Notify Two Factor" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-5.png">
+<img alt="QR Code Page" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-6.png">
+
+Scanning the QR Code with an authentication app like Google Authenticator registers the access for the user and automatically starts to generate tokens that can be used to login
+
+<img alt="Two Factor Scan App" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor_app.jpeg">
+
+If either of Email/SMS is used as the authentication method, you get notifications also
+
+<img alt="Email and SMS" class="screenshot" src="/docs/assets/img/articles/twofactor/twofactor-8.png">
\ No newline at end of file
diff --git a/erpnext/docs/user/manual/en/setting-up/settings/system-settings.md b/erpnext/docs/user/manual/en/setting-up/settings/system-settings.md
index 43f47f1..e3f7453 100644
--- a/erpnext/docs/user/manual/en/setting-up/settings/system-settings.md
+++ b/erpnext/docs/user/manual/en/setting-up/settings/system-settings.md
@@ -10,4 +10,14 @@
<img class="screenshot" alt="System Settings" src="/docs/assets/img/setup/settings/system-settings.png">
+####Two Factor Authentication.
+Settings for Two Factor Authentication can be configured here.
+
+* Select the authentication method to be used
+* Expiry time for QRCode image if "OTP App" is selected in method
+* Issuer name of the One Time Password
+
+<img class="screenshot" alt="Two Factor Auth" src="/docs/assets/img/setup/settings/twofactor-settings.png">
+
+
{next}
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/index.txt b/erpnext/docs/user/manual/en/setting-up/setup-wizard/index.txt
index 74f6a42..dad277a 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/index.txt
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/index.txt
@@ -1,10 +1,11 @@
step-1-language
step-2-currency-and-timezone
step-3-user-details
-step-4-company-details
-step-5-letterhead-and-logo
-step-6-add-users
-step-7-tax-details
-step-8-customer-names
-step-9-suppliers
-step-10-item
+step-4-two-factor-authentication
+step-5-company-details
+step-6-letterhead-and-logo
+step-7-add-users
+step-8-tax-details
+step-9-customer-names
+step-10-suppliers
+step-11-item
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-suppliers.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-suppliers.md
similarity index 91%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-suppliers.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-suppliers.md
index 46bcfba..364b4d6 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-suppliers.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-suppliers.md
@@ -1,4 +1,4 @@
-# Step 8: Suppliers
+# Step 10: Suppliers
Enter a few of your Suppliers' names.
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-item.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-11-item.md
similarity index 94%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-item.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-11-item.md
index 837c333..42d7e3d 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-10-item.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-11-item.md
@@ -1,4 +1,4 @@
-# Step 9: Item Names
+# Step 11: Item Names
In this final step, please enter the names of the Items you buy or sell.
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-3-user-details.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-3-user-details.md
index 5d6002a..228b972 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-3-user-details.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-3-user-details.md
@@ -2,8 +2,7 @@
Enter Users Profile Details like Name, User ID and preferred password.
-<img alt="User" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-3.png">
+<img alt="User" class="screenshot" src="/docs/assets/img/setup-wizard/step-3.png">
---
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-two-factor-authentication.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-two-factor-authentication.md
new file mode 100644
index 0000000..66bbd07
--- /dev/null
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-two-factor-authentication.md
@@ -0,0 +1,13 @@
+# Step 4: Two Factor Authentication
+
+Enable Two Factor Athentication
+
+<img alt="TwoFactor" class="screenshot" src="/docs/assets/img/setup-wizard/twofactor.png">
+
+---
+###Authentication Method
+Whenevever each user logs in, based on the role set for that user,
+they will be asked for a **One Time Password** after they input
+their login details.
+
+{next}
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-company-details.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-company-details.md
similarity index 85%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-company-details.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-company-details.md
index 2558f16..13a87e9 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-4-company-details.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-company-details.md
@@ -1,9 +1,8 @@
-# Step 4: Company Details
+# Step 5: Company Details
Enter Company Details like Name, Abbreviation and Financial Year Details.
-<img alt="Company Details" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-4.png">
+<img alt="Company Details" class="screenshot" src="/docs/assets/img/setup-wizard/step-4.png">
---
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-add-users.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-add-users.md
deleted file mode 100644
index 0a0cd00..0000000
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-add-users.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Step 6: Add Users
-
-Add other users and assign them roles based on their job responsibilities.
-
-<img alt="Users" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-6.png">
-
-{next}
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-letterhead-and-logo.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-letterhead-and-logo.md
similarity index 84%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-letterhead-and-logo.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-letterhead-and-logo.md
index 9f45642..0286a3e 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-5-letterhead-and-logo.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-6-letterhead-and-logo.md
@@ -1,9 +1,8 @@
-# Step 5: Letterhead and Logo
+# Step 6: Letterhead and Logo
Attach Company Letterhead and Company Logo.
-<img alt="Company Logo and Letterhead" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-5.png">
+<img alt="Company Logo and Letterhead" class="screenshot" src="/docs/assets/img/setup-wizard/step-5.png">
---
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-add-users.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-add-users.md
new file mode 100644
index 0000000..c92721c
--- /dev/null
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-add-users.md
@@ -0,0 +1,7 @@
+# Step 7: Add Users
+
+Add other users and assign them roles based on their job responsibilities.
+
+<img alt="Users" class="screenshot" src="/docs/assets/img/setup-wizard/step-6.png">
+
+{next}
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-tax-details.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-tax-details.md
similarity index 91%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-tax-details.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-tax-details.md
index 3b42ebe..dae88e4 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-7-tax-details.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-tax-details.md
@@ -1,9 +1,8 @@
-# Step 6: Tax Details
+# Step 8: Tax Details
Enter any three types of taxes which you regularly pay. This wizard will create a tax master which will calculate the taxes as per the tax-type.
-<img alt="Tax Details" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-7.png">
+<img alt="Tax Details" class="screenshot" src="/docs/assets/img/setup-wizard/step-7.png">
Just set the tax name and the standard percentage levied.
diff --git a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-customer-names.md b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-customer-names.md
similarity index 84%
rename from erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-customer-names.md
rename to erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-customer-names.md
index 2b6ae0c..e348943 100644
--- a/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-8-customer-names.md
+++ b/erpnext/docs/user/manual/en/setting-up/setup-wizard/step-9-customer-names.md
@@ -1,10 +1,9 @@
-# Step 7: Customers
+# Step 9: Customers
Enter your Customer names and the contact person from that organisation.
-<img alt="Customers" class="screenshot"
-src="/docs/assets/img/setup-wizard/step-8.png">
+<img alt="Customers" class="screenshot" src="/docs/assets/img/setup-wizard/step-8.png">
---
diff --git a/erpnext/patches/v8_6/point_sms_doctype_module_to_frappe_core.py b/erpnext/patches/v8_6/point_sms_doctype_module_to_frappe_core.py
new file mode 100644
index 0000000..014a74a
--- /dev/null
+++ b/erpnext/patches/v8_6/point_sms_doctype_module_to_frappe_core.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.db.sql('''UPDATE `tabDocType` SET module="Core"
+ WHERE name IN ("SMS Parameter", "SMS Settings");''')
\ No newline at end of file
diff --git a/erpnext/public/js/sms_manager.js b/erpnext/public/js/sms_manager.js
index 13e226f..6ce8bb1 100644
--- a/erpnext/public/js/sms_manager.js
+++ b/erpnext/public/js/sms_manager.js
@@ -35,7 +35,7 @@
this.get_contact_number = function(contact, ref_doctype, ref_name) {
frappe.call({
- method: "erpnext.setup.doctype.sms_settings.sms_settings.get_contact_number",
+ method: "frappe.core.doctype.sms_settings.sms_settings.get_contact_number",
args: {
contact_name: contact,
ref_doctype: ref_doctype,
@@ -85,7 +85,7 @@
if(v) {
$(btn).set_working();
frappe.call({
- method: "erpnext.setup.doctype.sms_settings.sms_settings.send_sms",
+ method: "frappe.core.doctype.sms_settings.sms_settings.send_sms",
args: {
receiver_list: [v.number],
msg: v.message
diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py
index ea6832b..f3674ae 100644
--- a/erpnext/selling/doctype/sms_center/sms_center.py
+++ b/erpnext/selling/doctype/sms_center/sms_center.py
@@ -9,7 +9,7 @@
from frappe.model.document import Document
-from erpnext.setup.doctype.sms_settings.sms_settings import send_sms
+from frappe.core.doctype.sms_settings.sms_settings import send_sms
class SMSCenter(Document):
def create_receiver_list(self):
diff --git a/erpnext/setup/doctype/sms_parameter/README.md b/erpnext/setup/doctype/sms_parameter/README.md
deleted file mode 100644
index 5935a39..0000000
--- a/erpnext/setup/doctype/sms_parameter/README.md
+++ /dev/null
@@ -1 +0,0 @@
-SMS query parameter for SMS Settings.
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_parameter/__init__.py b/erpnext/setup/doctype/sms_parameter/__init__.py
deleted file mode 100755
index baffc48..0000000
--- a/erpnext/setup/doctype/sms_parameter/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.json b/erpnext/setup/doctype/sms_parameter/sms_parameter.json
deleted file mode 100755
index afcabfa..0000000
--- a/erpnext/setup/doctype/sms_parameter/sms_parameter.json
+++ /dev/null
@@ -1,85 +0,0 @@
-{
- "allow_copy": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2013-02-22 01:27:58",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "editable_grid": 1,
- "fields": [
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "parameter",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Parameter",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "150px",
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0,
- "width": "150px"
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "value",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Value",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": "150px",
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0,
- "width": "150px"
- }
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 1,
- "image_view": 0,
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "max_attachments": 0,
- "modified": "2016-07-11 03:28:08.624783",
- "modified_by": "Administrator",
- "module": "Setup",
- "name": "SMS Parameter",
- "owner": "Administrator",
- "permissions": [],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "track_seen": 0
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.py b/erpnext/setup/doctype/sms_parameter/sms_parameter.py
deleted file mode 100644
index 08b220b..0000000
--- a/erpnext/setup/doctype/sms_parameter/sms_parameter.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-from frappe.model.document import Document
-
-class SMSParameter(Document):
- pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_settings/README.md b/erpnext/setup/doctype/sms_settings/README.md
deleted file mode 100644
index 4fb4980..0000000
--- a/erpnext/setup/doctype/sms_settings/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Settings for automatically sending SMS from the system.
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_settings/__init__.py b/erpnext/setup/doctype/sms_settings/__init__.py
deleted file mode 100755
index baffc48..0000000
--- a/erpnext/setup/doctype/sms_settings/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.js b/erpnext/setup/doctype/sms_settings/sms_settings.js
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/setup/doctype/sms_settings/sms_settings.js
+++ /dev/null
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.json b/erpnext/setup/doctype/sms_settings/sms_settings.json
deleted file mode 100755
index 23d6fa2..0000000
--- a/erpnext/setup/doctype/sms_settings/sms_settings.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "allow_copy": 1,
- "allow_import": 0,
- "allow_rename": 0,
- "creation": "2013-01-10 16:34:24",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "fields": [
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "column_break0",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0,
- "width": "50%"
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "description": "Eg. smsgateway.com/api/send_sms.cgi",
- "fieldname": "sms_gateway_url",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "SMS Gateway URL",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "description": "Enter url parameter for message",
- "fieldname": "message_parameter",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Message Parameter",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "description": "Enter url parameter for receiver nos",
- "fieldname": "receiver_parameter",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Receiver Parameter",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "sms_sender_name",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "SMS Sender Name",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "static_parameters_section",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0,
- "width": "50%"
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "description": "Enter static url parameters here (Eg. sender=ERPNext, username=ERPNext, password=1234 etc.)",
- "fieldname": "parameters",
- "fieldtype": "Table",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Static Parameters",
- "no_copy": 0,
- "options": "SMS Parameter",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- }
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "fa fa-cog",
- "idx": 1,
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 0,
- "issingle": 1,
- "istable": 0,
- "modified": "2015-03-02 02:24:19.692599",
- "modified_by": "Administrator",
- "module": "Setup",
- "name": "SMS Settings",
- "owner": "Administrator",
- "permissions": [
- {
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 0,
- "email": 0,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 0,
- "read": 1,
- "report": 0,
- "role": "System Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
- "write": 1
- }
- ],
- "read_only": 0,
- "read_only_onload": 0
-}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py
deleted file mode 100644
index a8b59be..0000000
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-from frappe import _, throw, msgprint
-from frappe.utils import nowdate
-
-from frappe.model.document import Document
-
-class SMSSettings(Document):
- pass
-
-def validate_receiver_nos(receiver_list):
- validated_receiver_list = []
- for d in receiver_list:
- # remove invalid character
- for x in [' ', '+', '-', '(', ')']:
- d = d.replace(x, '')
-
- validated_receiver_list.append(d)
-
- if not validated_receiver_list:
- throw(_("Please enter valid mobile nos"))
-
- return validated_receiver_list
-
-
-def get_sender_name():
- "returns name as SMS sender"
- sender_name = frappe.db.get_single_value('SMS Settings', 'sms_sender_name') or \
- 'ERPNXT'
- if len(sender_name) > 6 and \
- frappe.db.get_default("country") == "India":
- throw("""As per TRAI rule, sender name must be exactly 6 characters.
- Kindly change sender name in Setup --> Global Defaults.
- Note: Hyphen, space, numeric digit, special characters are not allowed.""")
- return sender_name
-
-@frappe.whitelist()
-def get_contact_number(contact_name, ref_doctype, ref_name):
- "returns mobile number of the contact"
- number = frappe.db.sql("""select mobile_no, phone from tabContact
- where name=%s
- and exists(
- select name from `tabDynamic Link` where link_doctype=%s and link_name=%s
- )
- """, (contact_name, ref_doctype, ref_name))
-
- return number and (number[0][0] or number[0][1]) or ''
-
-@frappe.whitelist()
-def send_sms(receiver_list, msg, sender_name = '', success_msg = True):
-
- import json
- if isinstance(receiver_list, basestring):
- receiver_list = json.loads(receiver_list)
- if not isinstance(receiver_list, list):
- receiver_list = [receiver_list]
-
- receiver_list = validate_receiver_nos(receiver_list)
-
- arg = {
- 'receiver_list' : receiver_list,
- 'message' : unicode(msg).encode('utf-8'),
- 'sender_name' : sender_name or get_sender_name(),
- 'success_msg' : success_msg
- }
-
- if frappe.db.get_value('SMS Settings', None, 'sms_gateway_url'):
- send_via_gateway(arg)
- else:
- msgprint(_("Please Update SMS Settings"))
-
-def send_via_gateway(arg):
- ss = frappe.get_doc('SMS Settings', 'SMS Settings')
- args = {ss.message_parameter: arg.get('message')}
- for d in ss.get("parameters"):
- args[d.parameter] = d.value
-
- success_list = []
- for d in arg.get('receiver_list'):
- args[ss.receiver_parameter] = d
- status = send_request(ss.sms_gateway_url, args)
-
- if 200 <= status < 300:
- success_list.append(d)
-
- if len(success_list) > 0:
- args.update(arg)
- create_sms_log(args, success_list)
- if arg.get('success_msg'):
- frappe.msgprint(_("SMS sent to following numbers: {0}").format("\n" + "\n".join(success_list)))
-
-
-def send_request(gateway_url, params):
- import requests
- response = requests.get(gateway_url, params = params, headers={'Accept': "text/plain, text/html, */*"})
- response.raise_for_status()
- return response.status_code
-
-
-# Create SMS Log
-# =========================================================
-def create_sms_log(args, sent_to):
- sl = frappe.new_doc('SMS Log')
- sl.sender_name = args['sender_name']
- sl.sent_on = nowdate()
- sl.message = args['message'].decode('utf-8')
- sl.no_of_requested_sms = len(args['receiver_list'])
- sl.requested_numbers = "\n".join(args['receiver_list'])
- sl.no_of_sent_sms = len(sent_to)
- sl.sent_to = "\n".join(sent_to)
- sl.flags.ignore_permissions = True
- sl.save()