Renamend model network.protocol to network.service. And network.protocol.type to network.protocol

This commit is contained in:
Jordi Esteve 2014-01-03 13:42:10 +01:00
parent 2bf357466a
commit ac9de1231b
9 changed files with 138 additions and 135 deletions

View file

@ -13,6 +13,6 @@ def register():
NetworkSoftwareType,
NetworkSoftware,
NetworkSoftwareLogin,
NetworkProtocolType,
NetworkProtocol,
NetworkSoftwareService,
module='network', type_='model')

View file

@ -11,8 +11,8 @@ __all__ = [
'NetworkSoftwareType',
'NetworkSoftware',
'NetworkSoftwareLogin',
'NetworkProtocolType',
'NetworkProtocol',
'NetworkSoftwareService',
]
@ -99,8 +99,8 @@ class NetworkSoftware(ModelSQL, ModelView):
)
logins = fields.One2Many('network.software.login', 'software',
'Login Users')
protocols = fields.One2Many('network.protocol', 'software',
'Connection Protocols')
services = fields.One2Many('network.software.service', 'software',
'Connection Services')
def get_network(self, name):
return self.hardware.network.id
@ -149,56 +149,57 @@ class NetworkSoftwareLogin(ModelSQL, ModelView):
@classmethod
@ModelView.button
def compute_url(cls, logins):
Protocol = Pool().get('network.protocol')
Service = Pool().get('network.software.service')
for login in logins:
protocols = Protocol.search([('software', '=', login.software)])
services = Service.search([('software', '=', login.software)])
url = login.software.network.domain
if not url:
url = login.software.network.ip_address
if url and protocols:
protocol = protocols[0]
login.url = (protocol.name.name.lower() + "://" + login.login +
"@" + url + ":" + str(protocol.port))
if url and services:
service = services[0]
login.url = (service.protocol.name.lower() + "://" +
login.login + "@" + url + ":" + str(service.port))
login.save()
class NetworkProtocolType(ModelSQL, ModelView):
'Network Protocol Type'
__name__ = 'network.protocol.type'
name = fields.Char('Protocol Name', required=True)
@classmethod
def __setup__(cls):
super(NetworkProtocolType, cls).__setup__()
cls._order.insert(0, ('name', 'ASC'))
class NetworkProtocol(ModelSQL, ModelView):
'Network Protocol'
__name__ = 'network.protocol'
name = fields.Many2One('network.protocol.type', 'Protocol', required=True)
note = fields.Text('Notes')
port = fields.Integer('Port', required=True)
software = fields.Many2One('network.software', 'Software', required=True)
url = fields.Char('URL')
name = fields.Char('Protocol Name', required=True)
@classmethod
def __setup__(cls):
super(NetworkProtocol, cls).__setup__()
cls._order.insert(0, ('name', 'ASC'))
class NetworkSoftwareService(ModelSQL, ModelView):
'Network Software Service'
__name__ = 'network.software.service'
_rec_name = 'url'
protocol = fields.Many2One('network.protocol', 'Protocol', required=True)
port = fields.Integer('Port', required=True)
software = fields.Many2One('network.software', 'Software', required=True)
note = fields.Text('Notes')
url = fields.Char('URL')
@classmethod
def __setup__(cls):
super(NetworkSoftwareService, cls).__setup__()
cls._buttons.update({
'compute_url': {},
})
@classmethod
@ModelView.button
def compute_url(cls, protocols):
for protocol in protocols:
url = protocol.software.network.domain
def compute_url(cls, services):
for service in services:
url = service.software.network.domain
if not url:
url = protocol.software.network.ip_address
url = service.software.network.ip_address
if url:
protocol.url = (protocol.name.name.lower() + "://" + url + ":" +
str(protocol.port))
protocol.save()
service.url = (service.protocol.name.lower() + "://" + url +
":" + str(service.port))
service.save()

View file

@ -260,89 +260,6 @@ copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
<!-- network.protocol.type -->
<record model="ir.ui.view" id="network_protocol_type_view_tree">
<field name="model">network.protocol.type</field>
<field name="type">tree</field>
<field name="name">protocol_type_tree</field>
</record>
<record model="ir.ui.view" id="network_protocol_type_view_form">
<field name="model">network.protocol.type</field>
<field name="type">form</field>
<field name="name">protocol_type_form</field>
</record>
<record model="ir.model.access" id="access_network_protocol_type">
<field name="model" search="[('model', '=', 'network.protocol.type')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_network_protocol_admin_type">
<field name="model" search="[('model', '=', 'network.protocol.type')]"/>
<field name="group" ref="group_network"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="network.protocol.type" id="ftp_protocol_type">
<field name="name">FTP</field>
</record>
<record model="network.protocol.type" id="http_protocol_type">
<field name="name">HTTP</field>
</record>
<record model="network.protocol.type" id="https_protocol_type">
<field name="name">HTTPS</field>
</record>
<record model="network.protocol.type" id="net_rpc_protocol_type">
<field name="name">NET-RPC</field>
</record>
<record model="network.protocol.type" id="pop_protocol_type">
<field name="name">POP</field>
</record>
<record model="network.protocol.type" id="rtps_protocol_type">
<field name="name">RTPS</field>
</record>
<record model="network.protocol.type" id="smtp_protocol_type">
<field name="name">SMTP</field>
</record>
<record model="network.protocol.type" id="ssh_protocol_type">
<field name="name">SSH</field>
</record>
<record model="network.protocol.type" id="ssl_protocol_type">
<field name="name">SSL</field>
</record>
<record model="network.protocol.type" id="tls_protocol_type">
<field name="name">TLS</field>
</record>
<record model="network.protocol.type" id="xml_rpc_protocol_type">
<field name="name">XML-RPC</field>
</record>
<record model="network.protocol.type" id="xml_rpcs_protocol_type">
<field name="name">XML-RPCS</field>
</record>
<record model="network.protocol.type" id="json_protocol_type">
<field name="name">JSON</field>
</record>
<!-- network.protocol -->
<record model="ir.ui.view" id="network_protocol_view_tree">
<field name="model">network.protocol</field>
@ -373,5 +290,88 @@ copyright notices and license terms. -->
<field name="perm_delete" eval="True"/>
</record>
<record model="network.protocol" id="ftp_protocol">
<field name="name">FTP</field>
</record>
<record model="network.protocol" id="http_protocol">
<field name="name">HTTP</field>
</record>
<record model="network.protocol" id="https_protocol">
<field name="name">HTTPS</field>
</record>
<record model="network.protocol" id="net_rpc_protocol">
<field name="name">NET-RPC</field>
</record>
<record model="network.protocol" id="pop_protocol">
<field name="name">POP</field>
</record>
<record model="network.protocol" id="rtps_protocol">
<field name="name">RTPS</field>
</record>
<record model="network.protocol" id="smtp_protocol">
<field name="name">SMTP</field>
</record>
<record model="network.protocol" id="ssh_protocol">
<field name="name">SSH</field>
</record>
<record model="network.protocol" id="ssl_protocol">
<field name="name">SSL</field>
</record>
<record model="network.protocol" id="tls_protocol">
<field name="name">TLS</field>
</record>
<record model="network.protocol" id="xml_rpc_protocol">
<field name="name">XML-RPC</field>
</record>
<record model="network.protocol" id="xml_rpcs_protocol">
<field name="name">XML-RPCS</field>
</record>
<record model="network.protocol" id="json_protocol">
<field name="name">JSON</field>
</record>
<!-- network.software.service -->
<record model="ir.ui.view" id="network_software_service_view_tree">
<field name="model">network.software.service</field>
<field name="type">tree</field>
<field name="name">service_tree</field>
</record>
<record model="ir.ui.view" id="network_software_service_view_form">
<field name="model">network.software.service</field>
<field name="type">form</field>
<field name="name">service_form</field>
</record>
<record model="ir.model.access" id="access_network_software_service">
<field name="model" search="[('model', '=', 'network.software.service')]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.model.access" id="access_network_software_service_admin">
<field name="model" search="[('model', '=', 'network.software.service')]"/>
<field name="group" ref="group_network"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
</data>
</tryton>

View file

@ -5,8 +5,4 @@ copyright notices and license terms. -->
<form string="Protocol">
<label name='name'/>
<field name='name'/>
<label name='port'/>
<field name='port'/>
<button name="compute_url" string="Compute _URL" icon="tryton-go-next"/>
<field name='url'/>
</form>

View file

@ -4,6 +4,4 @@ The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree string="Protocols">
<field name='name'/>
<field name='port'/>
<field name='url'/>
</tree>

View file

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<!-- This file is part of network module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Protocol">
<label name='name'/>
<field name='name'/>
</form>

14
view/service_form.xml Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!-- This file is part of network module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<form string="Service">
<label name='protocol'/>
<field name='protocol'/>
<label name='port'/>
<field name='port'/>
<button name="compute_url" string="Compute _URL" icon="tryton-go-next"/>
<field name='url'/>
<separator name="note" colspan="6"/>
<field name="note" colspan="6"/>
</form>

View file

@ -2,6 +2,8 @@
<!-- This file is part of network module for Tryton.
The COPYRIGHT file at the top level of this repository contains the full
copyright notices and license terms. -->
<tree string="Protocols">
<field name='name'/>
<tree string="Services">
<field name='protocol'/>
<field name='port'/>
<field name='url'/>
</tree>

View file

@ -14,8 +14,8 @@ copyright notices and license terms. -->
<label name='hardware'/>
<field name='hardware'/>
<notebook colspan="6">
<page string="Login Protocols and Users" id="logins">
<field name="protocols" colspan="6"/>
<page string="Login Services and Users" id="logins">
<field name="services" colspan="6"/>
<field name='logins' colspan="6"/>
</page>
<page string="Notes" id="note">