-
Notifications
You must be signed in to change notification settings - Fork 19
Migrated all models to use the UI Component Framework. #332
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
Migrated all models to use the UI Component Framework. #332
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cdf0c22 to
8b36cf8
Compare
gsnider2195
left a comment
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 this looks good! Just found a couple of small issues.
pyproject.toml
Outdated
| python = ">=3.9.2,<3.13" | ||
| # Used for local development | ||
| nautobot = ">=2.4.2,<3.0.0" | ||
| nautobot = ">=2.4.19,<3.0.0" |
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.
I think we should bump the minor version of firewall models with this change and update the compatibility matrix.
nautobot_firewall_models/templates/nautobot_firewall_models/inc/policy_expanded_rules.html
Show resolved
Hide resolved
| {% include 'nautobot_firewall_models/inc/policy_rules_tablerow.html' with rule=rule parent_policy=True %} | ||
| {% endfor %} | ||
| {% include "nautobot_firewall_models/inc/policyrule_tablehead.html" %} | ||
| {% if object.policy_rules %} |
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.
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.
hmm, something is odd, I am seeing the inverse. With .exists it looks like your after.
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.
My "after" screenshot above was after changing it to use .exists.
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.
I'm confusing myself.. will re-look at it tonight.
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.
okay, looking at it, I presume the screenshot is where there is no rule in a set of policies, thus there should be no row. How it is, does currently meets my expectation.
- What this does: it a single template that normalizes policy_rules from policy
- What it does not do: Set a default of empty rule
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.
I don't think you can evaluate a model manager (Policy.policy_rules) as boolean.
>>> Policy.objects.all()
<RestrictedQuerySet [<Policy: Policy 1>, <Policy: Policy 2>, <Policy: Policy 3>]>
>>> type(Policy.objects.all()[0].policy_rules)
>>> django.db.models.fields.related_descriptors.create_forward_many_to_many_manager.<locals>.ManyRelatedManager
>>> Policy.objects.all()[0].policy_rules.all()
<RestrictedQuerySet [<PolicyRule: Policy Rule 1 - req1>]>
>>> Policy.objects.all()[1].policy_rules.all()
<RestrictedQuerySet [<PolicyRule: Policy Rule 1 - req1>, <PolicyRule: Policy Rule 2 - req2>]>
>>> Policy.objects.all()[2].policy_rules.all()
<RestrictedQuerySet []>
>>> bool(Policy.objects.all()[0].policy_rules)
True
>>> bool(Policy.objects.all()[1].policy_rules)
True
>>> bool(Policy.objects.all()[2].policy_rules)
True{% if object.policy_rules %} will never evaluate to False so you'll never hit the else in this if/else. The screenshot I'm showing above is what it looks like when the else gets rendered correctly with nautobot_firewall_models/inc/policy_rules_tablerow.html
nautobot_firewall_models/templates/nautobot_firewall_models/inc/nat_policy_expanded_rules.html
Show resolved
Hide resolved
|
Not going to worry about poetry.lock until 2.4.20 is published. |
0b67c78 to
778872a
Compare
Co-authored-by: Gary Snider <[email protected]>


firewall-screenshots.pdf