-
Notifications
You must be signed in to change notification settings - Fork 65
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
[change] Add user defined properties field in Node and Link #85 #91
Conversation
2290eba
to
9cdbc70
Compare
This comment has been minimized.
This comment has been minimized.
openwisp_network_topology/integrations/device/migrations/0002_create_relations.py
Show resolved
Hide resolved
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.
openwisp_network_topology/integrations/device/migrations/0002_create_relations.py
Show resolved
Hide resolved
9cdbc70
to
69edec3
Compare
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.
Great progress!
Can you please do something to display the properties (on node and link admin change page) in a nicer way?
An admin method that simply adds
<br/>
elements would do or anything that makes it look better.
Thanks for trying something with the properties but that's not what I meant.
Please try something like the following:
from django.utils.safestring import mark_safe
@admin.register(Node)
class NodeAdmin(NodeLinkMixin, BaseAdmin):
# ...
fields = [
# ... omitted other fields
'readonly_properties',
]
readonly_fields = ['readonly_properties']
def readonly_properties(self, obj):
output = ''
for key, value in obj.properties.items():
key = key.replace('_', ' ').capitalize()
output += f'<p><strong>{key}</strong>: {value}</p>'
return mark_safe(output)
readonly_properties.short_description = _('properties')
This is working code but please ensure it's shared by NodeAdmin and LinkAdmin (do not duplicate it in both classes).
It looks like this:
Please also update the tests accordingly.
69edec3
to
9e9d294
Compare
6552d5a
to
9daec18
Compare
from django.utils.translation import ugettext_lazy as _ | ||
from flat_json_widget.widgets import FlatJsonWidget |
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.
this module needs to be added here: https://github.com/openwisp/openwisp-network-topology/blob/master/requirements.txt
openwisp-controller is not a direct dependency. The build is not failing because openwisp-controller is being installed with an additional command to test the integration module.
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.
@nemesisdesign Thank you for this catch. I forgot to add it 😄 . But the build isn't failing because of this. the Build is failing because modify_settings is called. I tried some many fix but they didn't work. I don't think the fix should be done in this module. if we fix it here, we might be hiding a potential bug which will certainly surface again one day. My master branch is equally failing with the same error.
9daec18
to
282da50
Compare
@nemesisdesign I will rebase this once #93 is merged |
282da50
to
e418f4d
Compare
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.
Thanks! 👍
Closed issue by adding a user defined properties field to Node and Link model
which users could use to defined their own properties as imported properties
are now readonly.
Closes #85