parent
e5aa9c5f2f
commit
3a5dceae18
0
erpnext/erpnext_integrations/__init__.py
Normal file
0
erpnext/erpnext_integrations/__init__.py
Normal file
0
erpnext/erpnext_integrations/connectors/__init__.py
Normal file
0
erpnext/erpnext_integrations/connectors/__init__.py
Normal file
45
erpnext/erpnext_integrations/connectors/github_connection.py
Normal file
45
erpnext/erpnext_integrations/connectors/github_connection.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.data_migration.doctype.data_migration_connector.connectors.base import BaseConnection
|
||||||
|
from github import Github
|
||||||
|
|
||||||
|
class GithubConnection(BaseConnection):
|
||||||
|
def __init__(self, connector):
|
||||||
|
self.connector = connector
|
||||||
|
|
||||||
|
try:
|
||||||
|
password = self.get_password()
|
||||||
|
except frappe.AuthenticationError:
|
||||||
|
password = None
|
||||||
|
|
||||||
|
if self.connector.username and password:
|
||||||
|
self.connection = Github(self.connector.username, self.get_password())
|
||||||
|
else:
|
||||||
|
self.connection = Github()
|
||||||
|
|
||||||
|
self.name_field = 'id'
|
||||||
|
|
||||||
|
def insert(self, doctype, doc):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update(self, doctype, doc, migration_id):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def delete(self, doctype, migration_id):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get(self, remote_objectname, fields=None, filters=None, start=0, page_length=10):
|
||||||
|
repo = filters.get('repo')
|
||||||
|
|
||||||
|
if remote_objectname == 'Milestone':
|
||||||
|
return self.get_milestones(repo, start, page_length)
|
||||||
|
if remote_objectname == 'Issue':
|
||||||
|
return self.get_issues(repo, start, page_length)
|
||||||
|
|
||||||
|
def get_milestones(self, repo, start=0, page_length=10):
|
||||||
|
_repo = self.connection.get_repo(repo)
|
||||||
|
return list(_repo.get_milestones()[start:start+page_length])
|
||||||
|
|
||||||
|
def get_issues(self, repo, start=0, page_length=10):
|
||||||
|
_repo = self.connection.get_repo(repo)
|
||||||
|
return list(_repo.get_issues()[start:start+page_length])
|
@ -0,0 +1,11 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def pre_process(issue):
|
||||||
|
|
||||||
|
project = frappe.db.get_value('Project', filters={'project_name': issue.milestone})
|
||||||
|
return {
|
||||||
|
'title': issue.title,
|
||||||
|
'body': frappe.utils.to_html(issue.body or ''),
|
||||||
|
'state': issue.state.title(),
|
||||||
|
'project': project or ''
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"condition": "{\"repo\":\"frappe/erpnext\"}",
|
||||||
|
"creation": "2017-10-16 16:03:32.772191",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Data Migration Mapping",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "subject",
|
||||||
|
"remote_fieldname": "title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "description",
|
||||||
|
"remote_fieldname": "body"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "status",
|
||||||
|
"remote_fieldname": "state"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 0,
|
||||||
|
"local_doctype": "Task",
|
||||||
|
"local_primary_key": "name",
|
||||||
|
"mapping_name": "Issue to Task",
|
||||||
|
"mapping_type": "Pull",
|
||||||
|
"migration_id_field": "github_sync_id",
|
||||||
|
"modified": "2017-10-20 11:48:54.575993",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"name": "Issue to Task",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"page_length": 10,
|
||||||
|
"remote_objectname": "Issue",
|
||||||
|
"remote_primary_key": "id"
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
def pre_process(milestone):
|
||||||
|
return {
|
||||||
|
'title': milestone.title,
|
||||||
|
'description': milestone.description,
|
||||||
|
'state': milestone.state.title()
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"condition": "{\"repo\": \"frappe/erpnext\"}",
|
||||||
|
"creation": "2017-10-13 11:16:49.664925",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Data Migration Mapping",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "project_name",
|
||||||
|
"remote_fieldname": "title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "notes",
|
||||||
|
"remote_fieldname": "description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"is_child_table": 0,
|
||||||
|
"local_fieldname": "status",
|
||||||
|
"remote_fieldname": "state"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"idx": 0,
|
||||||
|
"local_doctype": "Project",
|
||||||
|
"local_primary_key": "project_name",
|
||||||
|
"mapping_name": "Milestone to Project",
|
||||||
|
"mapping_type": "Pull",
|
||||||
|
"migration_id_field": "github_sync_id",
|
||||||
|
"modified": "2017-10-20 11:48:54.552305",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"name": "Milestone to Project",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"page_length": 10,
|
||||||
|
"remote_objectname": "Milestone",
|
||||||
|
"remote_primary_key": "id"
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"creation": "2017-10-13 11:16:53.600026",
|
||||||
|
"docstatus": 0,
|
||||||
|
"doctype": "Data Migration Plan",
|
||||||
|
"idx": 0,
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"enabled": 1,
|
||||||
|
"mapping": "Milestone to Project"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enabled": 1,
|
||||||
|
"mapping": "Issue to Task"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"modified": "2017-10-20 11:48:54.496123",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "ERPNext Integrations",
|
||||||
|
"name": "GitHub Sync",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"plan_name": "GitHub Sync"
|
||||||
|
}
|
@ -17,3 +17,4 @@ Schools
|
|||||||
Regional
|
Regional
|
||||||
Healthcare
|
Healthcare
|
||||||
Restaurant
|
Restaurant
|
||||||
|
ERPNext Integrations
|
Loading…
x
Reference in New Issue
Block a user