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

Add validation to Notes admin to require a period or exclamation mark as the final character #641

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

stevejalim
Copy link
Contributor

@stevejalim stevejalim commented Aug 24, 2022

This was requested in #639 as part of making it easier to standardise Release Notes content.

If an entry lacks an accepted terminating punctuation mark, we'll show a validation error in the admin and the author can try again:

Screenshot 2022-08-24 at 14 29 57

By default the behaviour is on, but can be easily overridden via env vars (via nucleus-config)

The list of allowed characters can also be amended via environment vars.

Fixes #639

### To test

  • pull this branch
  • make shell then./manage.py createsuperuser then exit the shell
  • make run
  • log in to the admin at http://localhost:8000/admin/
  • Browse to RNA > Notes and add a new note, leaving off punctuation, attempting to save, etc.

… as the

final character.

By default the behaviour is on, but can be easily overridden via nucleus-config

The list of allowed characters can also be amended via environment vars.

Fixes #639
@stevejalim stevejalim force-pushed the 639-validation-for-notes-field branch from ae3dc4a to 7d04adb Compare August 24, 2022 15:52
@stevejalim stevejalim requested a review from robhudson August 24, 2022 15:55
@stevejalim stevejalim assigned pmac and unassigned pmac Aug 24, 2022
@stevejalim stevejalim requested a review from pmac August 24, 2022 15:57
@stevejalim
Copy link
Contributor Author

@dsmithpadilla if you'd like to test-drive this, feel free. It's Docker-based, so cloning the repo and using the steps in the description should be all you need to do

Copy link
Member

@pmac pmac left a comment

Choose a reason for hiding this comment

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

📓

@@ -19,6 +23,22 @@ class Meta:
model = models.Note
fields = "__all__"

def clean_note(self):
"""Ensure Note entries end with appropriate punctuation
Copy link
Member

Choose a reason for hiding this comment

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

Error: docstring summary lines must end with appropriate puncutation. 😆

Copy link
Member

@robhudson robhudson left a comment

Choose a reason for hiding this comment

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

Looks great to me. Nice work with good tests too!

@stevejalim stevejalim merged commit 9d6fcce into master Aug 24, 2022
@stevejalim stevejalim deleted the 639-validation-for-notes-field branch August 24, 2022 18:48
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.

Feature request: Require punctuation at the end of each note
3 participants