Skip to content

Commit

Permalink
fix pgsql issue
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Oct 30, 2018
1 parent 788c5ae commit 8dbeb45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions eNMS/base/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ def get_one(model):

def factory(cls_name, **kwargs):
if 'id' in kwargs:
instance = fetch(cls_name, id=kwargs['id'])
if not kwargs['id']:
kwargs.pop('id')
if kwargs['id']:
instance = fetch(cls_name, id=kwargs['id'])
else:
instance = kwargs.pop('id')
else:
instance = fetch(cls_name, name=kwargs['name'])
if instance:
instance.update(**kwargs)
else:
print(kwargs)
instance = classes[cls_name](**kwargs)
db.session.add(instance)
db.session.commit()
Expand Down
3 changes: 2 additions & 1 deletion eNMS/objects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
BooleanField,
FloatField,
HiddenField,
IntegerField,
PasswordField,
SelectMultipleField,
SelectField,
Expand Down Expand Up @@ -51,7 +52,7 @@ class AddDevice(AddObjectForm):
device_types = [subtype for subtype in device_subtypes.items()]
subtype = SelectField(choices=device_types)
ip_address = TextField('IP address')
port = TextField()
port = IntegerField(default=22)
operating_system = TextField()
os_version = TextField()
longitude = FloatField(default=0.)
Expand Down

0 comments on commit 8dbeb45

Please sign in to comment.