Browse Source

Webhook Data DocType added

version-14
Revant Nandgaonkar 7 years ago
parent
commit
beb6318d88
6 changed files with 250 additions and 2 deletions
  1. +39
    -1
      frappe/integrations/doctype/webhook/webhook.js
  2. +62
    -1
      frappe/integrations/doctype/webhook/webhook.json
  3. +9
    -0
      frappe/integrations/doctype/webhook/webhook.py
  4. +0
    -0
      frappe/integrations/doctype/webhook_data/__init__.py
  5. +130
    -0
      frappe/integrations/doctype/webhook_data/webhook_data.json
  6. +10
    -0
      frappe/integrations/doctype/webhook_data/webhook_data.py

+ 39
- 1
frappe/integrations/doctype/webhook/webhook.js View File

@@ -1,8 +1,46 @@
// Copyright (c) 2017, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.webhook = {
set_fieldname_select: function(frm) {
var me = this,
doc = frm.doc;
if (doc.webhook_doctype) {
frappe.model.with_doctype(doc.webhook_doctype, function() {
var fields = $.map(frappe.get_doc("DocType", frm.doc.webhook_doctype).fields, function(d) {
if (frappe.model.no_value_type.indexOf(d.fieldtype) === -1 ||
d.fieldtype === 'Table') {
return { label: d.label + ' (' + d.fieldtype + ')', value: d.fieldname }
}
else if (d.fieldtype === 'Currency' || d.fieldtype === 'Float') {
return { label: d.label, value: d.fieldname }
}
else {
return null;
}
})
frappe.meta.get_docfield("Webhook Data", "fieldname", frm.doc.name).options = [""].concat(fields);
});
}
}
}

frappe.ui.form.on('Webhook', {
refresh: function(/*frm*/) {
refresh: function(frm) {
frappe.webhook.set_fieldname_select(frm);
},
webhook_doctype: function(frm) {
frappe.webhook.set_fieldname_select(frm);
}
});

frappe.ui.form.on("Webhook Data", {
fieldname: function(frm, doctype, name) {
var doc = frappe.get_doc(doctype, name);
var df = $.map(frappe.get_doc("DocType", frm.doc.webhook_doctype).fields, function(d) {
return doc.fieldname == d.fieldname ? d : null;
})[0];
doc.key = df.fieldname
frm.refresh_field("webhook_data");
}
});

+ 62
- 1
frappe/integrations/doctype/webhook/webhook.json View File

@@ -255,6 +255,67 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "sb_webhook_data",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Webhook Data",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "webhook_data",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Data",
"length": 0,
"no_copy": 0,
"options": "Webhook Data",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
@@ -267,7 +328,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-09-09 20:05:43.406391",
"modified": "2017-09-14 13:16:53.974340",
"modified_by": "Administrator",
"module": "Integrations",
"name": "Webhook",


+ 9
- 0
frappe/integrations/doctype/webhook/webhook.py View File

@@ -14,6 +14,7 @@ class Webhook(Document):
def validate(self):
self.validate_docevent()
self.validate_request_url()
self.validate_repeating_companies()
def validate_docevent(self):
if self.webhook_doctype:
is_submittable = frappe.get_value("DocType", self.webhook_doctype, "is_submittable")
@@ -26,3 +27,11 @@ class Webhook(Document):
raise frappe.ValidationError
except Exception as e:
frappe.throw(_("Check Request URL"), exc=e)
def validate_repeating_companies(self):
"""Error when Same Field is entered multiple times in webhook_data"""
webhook_data = []
for entry in self.webhook_data:
webhook_data.append(entry.fieldname)

if len(webhook_data)!= len(set(webhook_data)):
frappe.throw(_("Same Field is entered more than once"))

+ 0
- 0
frappe/integrations/doctype/webhook_data/__init__.py View File


+ 130
- 0
frappe/integrations/doctype/webhook_data/webhook_data.json View File

@@ -0,0 +1,130 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2017-09-14 12:08:50.302810",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fieldname",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Fieldname",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "cb_doc_data",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "key",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Key",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-09-14 13:16:58.252176",
"modified_by": "Administrator",
"module": "Integrations",
"name": "Webhook Data",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

+ 10
- 0
frappe/integrations/doctype/webhook_data/webhook_data.py View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document

class WebhookData(Document):
pass

Loading…
Cancel
Save