New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] connector_dns #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============= | ||
Connector DNS | ||
============= | ||
|
||
This module aims to allows to manage your DNS domain through Odoo. | ||
|
||
Installation | ||
============ | ||
|
||
To install this module, you need to: | ||
|
||
* have basic modules installed (connector) | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
.. figure:: path/to/local/image.png | ||
:alt: alternative description | ||
:width: 600 px | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch} | ||
|
||
.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt | ||
.. branch is "8.0" for example | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* TBD | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Eric Caudal <eric.caudal@elico-corp.com> | ||
* Noah Wang <noah.wang@elico-corp.com> | ||
* Liu Lixia <contact@elico-corp.com> | ||
* Augustin Cisterne-Kaas <contact@elico-corp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import backend | ||
from . import connector | ||
from . import dns | ||
from . import tests | ||
from . import unit | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
'name': 'DNS connector', | ||
'version': '8.0.1.0.0', | ||
'category': 'Connector', | ||
'depends': ['connector'], | ||
'author': 'Elico Corp,Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'website': 'https://www.elico-corp.com', | ||
'images': [], | ||
'data': [ | ||
'dns_view.xml', | ||
'dns_menu.xml' | ||
], | ||
'installable': True, | ||
'application': False | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import openerp.addons.connector.backend as backend | ||
|
||
dns = backend.Backend('dns') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use simplified headers in all files py There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from openerp import models, fields | ||
from openerp.addons.connector.connector import (Environment) | ||
from openerp.addons.connector.checkpoint import checkpoint | ||
|
||
|
||
def get_environment(session, model_name, backend_id): | ||
""" Create an environment to work with. """ | ||
backend_record = session.browse('dns.backend', backend_id) | ||
env = Environment(backend_record, session, model_name) | ||
return env | ||
|
||
|
||
class DNSBinding(models.Model): | ||
""" Abstract Model for the Bindigs. | ||
All the models used as bindings between dnspod and OpenERP | ||
(``dnspod.res.partner``, ``dnspod.product.product``, ...) should | ||
``_inherit`` it. | ||
""" | ||
_name = 'dns.binding' | ||
_inherit = 'external.binding' | ||
_description = 'dns Binding (abstract)' | ||
|
||
backend_id = fields.Many2one( | ||
'dns.backend', | ||
String='DNS Backend', | ||
required=True, | ||
ondelete='restrict') | ||
# fields.char because 0 is a valid dnspod ID | ||
dns_id = fields.Char('ID on other software') | ||
# state of the record synchronization with dnspod | ||
state = fields.Selection( | ||
[('draft', 'Draft'), ('done', 'Done'), | ||
('exception', 'Exception')], 'State', | ||
default="draft", | ||
help='Done when succeed otherwise Exception') | ||
|
||
|
||
def add_checkpoint(session, model_name, record_id, backend_id): | ||
""" Add a row in the model ``connector.checkpoint`` for a record, | ||
meaning it has to be reviewed by a user. | ||
:param session: current session | ||
:type session: :class:`openerp.addons.connector.session.ConnectorSession` | ||
:param model_name: name of the model of the record to be reviewed | ||
:type model_name: str | ||
:param record_id: ID of the record to be reviewed | ||
:type record_id: int | ||
:param backend_id: ID of the dnspod Backend | ||
:type backend_id: int | ||
""" | ||
return checkpoint.add_checkpoint(session, model_name, record_id, | ||
'dns.backend', backend_id) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2015 Elico Corp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from openerp import models, fields, api | ||
|
||
|
||
class DNSBackend(models.Model): | ||
_name = 'dns.backend' | ||
_inherit = 'connector.backend' | ||
_backend_type = 'dns' | ||
|
||
def _select_version(self): | ||
return [] | ||
|
||
login = fields.Char( | ||
string='Login', | ||
help="Provider's login.", | ||
required=True | ||
) | ||
password = fields.Char( | ||
string='Password', | ||
help="Provider's password.", | ||
required=True | ||
) | ||
state = fields.Selection( | ||
[('draft', 'Draft'), ('done', 'Done'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can improve the format splitting the lines |
||
('exception', 'Exception')], | ||
string='State', | ||
default="draft", | ||
help='"Confirmed" when the domain has been succesfully created.' | ||
) | ||
version = fields.Selection( | ||
selection='_select_version', | ||
string='Service Provider', | ||
help='DNS service provider', | ||
required=True | ||
) | ||
|
||
@api.multi | ||
def name_get(self): | ||
res = [] | ||
for backend in self: | ||
res.append((backend.id, '%s (%s)' % (backend.name, backend.login))) | ||
return res | ||
|
||
|
||
class DNSDomain(models.Model): | ||
_name = 'dns.domain' | ||
_inherit = 'dns.binding' | ||
|
||
name = fields.Char( | ||
string='Name', | ||
required=True, | ||
help='Domain name without "www",such as"dnspod.cn"' | ||
) | ||
record_ids = fields.One2many( | ||
comodel_name='dns.record', | ||
inverse_name='domain_id', | ||
string='Subdomains' | ||
) | ||
|
||
|
||
class DNSRecord(models.Model): | ||
_name = 'dns.record' | ||
_inherit = 'dns.binding' | ||
|
||
def _line_select_version(self): | ||
return [] | ||
|
||
def _type_select_version(self): | ||
return [] | ||
|
||
name = fields.Char( | ||
string='Sub domain', | ||
help="host record,such as 'www'", | ||
required=True) | ||
domain_id = fields.Many2one( | ||
comodel_name='dns.domain', | ||
string="Domain", | ||
domain="[('state','=','done')]", | ||
ondelete='cascade', | ||
help="Domain which has already confirmed" | ||
) | ||
type = fields.Selection( | ||
selection='_type_select_version', | ||
string='Record Type' | ||
) | ||
line = fields.Selection( | ||
selection='_line_select_version', | ||
string='Record Line' | ||
) | ||
value = fields.Text( | ||
string='Value', | ||
help="such as IP:200.200.200.200", | ||
required=True | ||
) | ||
mx_priority = fields.Integer( | ||
string='MX priority', | ||
help="scope:1-20", | ||
default=1 | ||
) | ||
ttl = fields.Integer( | ||
string='TTL', | ||
default=600, | ||
help="scope:1-604800", | ||
required=True | ||
) | ||
backend_id = fields.Many2one( | ||
comodel_name='dns.backend', | ||
related='domain_id.backend_id', | ||
store=True | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<openerp> | ||
<data> | ||
<menuitem id="menu_dns" | ||
name="DNS" | ||
parent="connector.menu_connector_root"/> | ||
|
||
<menuitem name="Backends" | ||
id="menu_dns_backend" | ||
parent="menu_dns" | ||
sequence="10" | ||
action="dns_backend_action"/> | ||
|
||
<menuitem name="Domains" | ||
id="menu_dns_domain" | ||
parent="menu_dns" | ||
sequence="20" | ||
action="dns_domain_action"/> | ||
|
||
<menuitem name="Records" | ||
id="menu_dns_record" | ||
parent="menu_dns" | ||
sequence="30" | ||
action="dns_record_action"/> | ||
</data> | ||
</openerp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check newest template/badge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to adapt the template accordingly... (check the previous one for the content)