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

Added option to define step values for grid labeling #115

Merged
merged 10 commits into from
Sep 12, 2024

Conversation

djhoward12
Copy link
Collaborator

Added option to define step values for use in the labeling of FloorPlan Grids. Updated documentation and tests.

…an Grids. Updated documentation and tests.
@djhoward12 djhoward12 linked an issue Aug 13, 2024 that may be closed by this pull request
@joewesch joewesch requested a review from glennmatthews August 19, 2024 14:54
Copy link
Contributor

@smk4664 smk4664 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments on implementing Custom Validator instead of having it in the save method.

@djhoward12 djhoward12 requested a review from smk4664 September 4, 2024 22:34
@djhoward12 djhoward12 marked this pull request as draft September 5, 2024 00:01
@djhoward12 djhoward12 marked this pull request as ready for review September 5, 2024 13:52
@djhoward12 djhoward12 closed this Sep 6, 2024
@djhoward12 djhoward12 reopened this Sep 6, 2024
@joewesch
Copy link
Contributor

@smk4664 are we good to merge this one yet?

Copy link
Contributor

@smk4664 smk4664 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes! I offered a suggestion on how to implement the validator as a class, but this is optional.

@@ -20,3 +23,13 @@ def grid_letter_to_number(letter):
if letter[:-1]:
return 26 * (grid_letter_to_number(letter[:-1])) + number
return number


def validate_not_zero(value):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, but to get around the validate_not_zero.message and follow established Django Pattern, you can change this to a class. In case you need this in the future.

Suggested change
def validate_not_zero(value):
from django.core.validators import BaseValidator
class NonZeroValidator(BaseValidator):
"""
Ensure that the field's value is not zero.
"""
message = "Must be a positive or negative Integer not equal to zero."
code = "zero_not_allowed"
def __call__(self, value):
if value == 0:
raise ValidationError(
self.message,
code=self.code,
)

@smk4664 smk4664 merged commit 314406d into nautobot:develop Sep 12, 2024
14 checks passed
@djhoward12 djhoward12 deleted the djhoward12-naaps-08-grid-step branch September 12, 2024 12:04
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

Successfully merging this pull request may close these issues.

Custom grid numbering in SVG render
3 participants