Commit bd30ed01 authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Vendor.code

--HG--
branch : feature/inventory
parent e2a9ca88
......@@ -15,7 +15,8 @@ Ext.define("NOC.inv.vendor.Application", {
columns: [
{
text: "Name",
dataIndex: "name"
dataIndex: "name",
width: 200
},
{
text: "Builtin",
......@@ -23,10 +24,15 @@ Ext.define("NOC.inv.vendor.Application", {
renderer: NOC.render.Bool,
width: 50
},
{
text: "Code",
dataIndex: "code",
width: 100
},
{
text: "Site",
dataIndex: "site",
flex: true,
flex: 1,
renderer: NOC.render.URL
}
],
......@@ -42,6 +48,12 @@ Ext.define("NOC.inv.vendor.Application", {
xtype: "checkboxfield",
boxLabel: "Is Builtin"
},
{
name: "code",
xtype: "textfield",
fieldLabel: "Code",
allowBlank: false
},
{
name: "site",
xtype: "textfield",
......
......@@ -19,6 +19,10 @@ Ext.define("NOC.inv.vendor.Model", {
name: "name",
type: "string"
},
{
name: "code",
type: "string"
},
{
name: "is_builtin",
type: "boolean",
......
......@@ -10,7 +10,7 @@
from mongoengine.document import Document
from mongoengine.fields import StringField, BooleanField, URLField
## NOC modules
from noc.lib.escape import json_escape as q
from noc.lib.prettyjson import to_json
class Vendor(Document):
......@@ -24,18 +24,15 @@ class Vendor(Document):
name = StringField(unique=True)
is_builtin = BooleanField(default=False)
code = StringField()
site = URLField(required=False)
def __unicode__(self):
return self.name
def to_json(self):
r = [
"[",
" {",
" \"name\": \"%s\"," % q(self.name),
" \"site\": \"%s\"" % q(self.site),
" }",
"]"
]
return "\n".join(r)
\ No newline at end of file
return to_json([{
"name": self.name,
"code": self.code,
"site": self.site
}])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment