Skip to content
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

Mismatch in singular/plural for many to many relationships #72

Closed
Kircheneer opened this issue Jul 19, 2022 · 1 comment
Closed

Mismatch in singular/plural for many to many relationships #72

Kircheneer opened this issue Jul 19, 2022 · 1 comment
Assignees

Comments

@Kircheneer
Copy link
Contributor

Environment

  • Nautobot version: *
  • nautobot-plugin-firewall-model version: 0.1.0-beta.2

Proposed Functionality

Single in on one plurality (my preference would be plural) for all many to many fields. Example:

PolicyRule has its many to many fields in singular, while Policy has them in plural.

class PolicyRule(PrimaryModel):
    (...)
    source_user = models.ManyToManyField(to=UserObject, through="SrcUserM2M", related_name="policy_rules")
    source_user_group = models.ManyToManyField(
        to=UserObjectGroup, through="SrcUserGroupM2M", related_name="policy_rules"
    )
    source_address = models.ManyToManyField(to=AddressObject, through="SrcAddrM2M", related_name="source_policy_rules")
    source_address_group = models.ManyToManyField(
        to=AddressObjectGroup, through="SrcAddrGroupM2M", related_name="source_policy_rules"
    )
    source_zone = models.ForeignKey(
        to=Zone, null=True, blank=True, on_delete=models.SET_NULL, related_name="source_policy_rules"
    )
    destination_address = models.ManyToManyField(
        to=AddressObject, through="DestAddrM2M", related_name="destination_policy_rules"
    )
    destination_address_group = models.ManyToManyField(
        to=AddressObjectGroup, through="DestAddrGroupM2M", related_name="destination_policy_rules"
    )
    destination_zone = models.ForeignKey(
        to=Zone, on_delete=models.SET_NULL, null=True, blank=True, related_name="destination_policy_rules"
    )
    service = models.ManyToManyField(to=ServiceObject, through="SvcM2M", related_name="policy_rules")
    service_group = models.ManyToManyField(to=ServiceObjectGroup, through="SvcGroupM2M", related_name="policy_rules")
class Policy(PrimaryModel):
    (...)
    policy_rules = models.ManyToManyField(to=PolicyRule, through="PolicyRuleM2M", related_name="policies")
    assigned_devices = models.ManyToManyField(
        to="dcim.Device", through="PolicyDeviceM2M", related_name="firewall_policies"
    )
    assigned_dynamic_groups = models.ManyToManyField(
        to="extras.DynamicGroup", through="PolicyDynamicGroupM2M", related_name="firewall_policies"
    )

Use Case

Greater level of intuition for field naming.

@whitej6 whitej6 self-assigned this Aug 26, 2022
@whitej6
Copy link
Contributor

whitej6 commented Aug 26, 2022

Resolved by #80

@whitej6 whitej6 closed this as completed Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants