Skip to content

Conversation

@Spacerat
Copy link
Contributor

@Spacerat Spacerat commented Jun 25, 2016

This PR improves validation in a few ways:

  • pre_save_full_clean_handler in meta.py triggers model validation any time a model is saved (including Model.object.create)
  • Adds validators for some model fields: ResourceIdentifier.resource_id, BuildResult.uuid and Project.uuid.
  • Some regexes are shared between python/models, HTML templates and the clientside JS. These are moved into a new module ide/utils/regexes.py and are made available to the templates with {% regexes.regex_name %} and the clientside JS with the global object REGEXES.regex_name.

(depends on #297)

@pebble-heroku pebble-heroku temporarily deployed to cloudpebble-sp-pr-321 June 25, 2016 18:55 Inactive
@Spacerat Spacerat force-pushed the bugfix/validation branch from e2dbd69 to aece9f7 Compare June 25, 2016 19:12
@Spacerat Spacerat temporarily deployed to cloudpebble-sp-pr-321 June 25, 2016 19:12 Inactive
@Spacerat Spacerat mentioned this pull request Jun 27, 2016
@Katharine Katharine force-pushed the bugfix/validation branch from aece9f7 to b8c09a6 Compare July 5, 2016 23:15
@Katharine Katharine temporarily deployed to cloudpebble-sp-pr-321 July 5, 2016 23:15 Inactive
class ResourceIdentifier(IdeModel):
resource_file = models.ForeignKey(ResourceFile, related_name='identifiers')
resource_id = models.CharField(max_length=100)
resource_id = models.CharField(max_length=100, validators=regexes.validator('c_identifier', _("Invalid resource ID.")))
Copy link
Member

Choose a reason for hiding this comment

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

This isn't quite right; resource IDs are prefixed and so don't have the usual start-of-identifier rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants