guardian / typerighter

Even if you’re the right typer, couldn’t hurt to use Typerighter!
Apache License 2.0
276 stars 12 forks source link

Batch edit rules (server-side) #346

Closed aracho1 closed 1 year ago

aracho1 commented 1 year ago

What does this change?

This PR introduces a new endpoint /rules/batch for batch editing, and adds batchUpdate method to authenticate and validate (via BatchUpdateRuleForm) the request. Lastly DbRuleDraft.batchUpdateFromFormRule() updates the corresponding rules in the database. I have also added a test.

How to test

Run this locally (or on CODE but #342 would need to be merged to fix CODE permissions). Create multiple new rules and and send a POST request to /rules/batch with their IDs and new categories and/or tags to update e.g.

{
 "ids":[800,801,802], 
 "fields": {
    "category": "Check this",
    "tags": "General,SG"
  }
}

Check that the relevant fields have been updated for these rules.

aracho1 commented 1 year ago

Thank you for your review and suggestions @jonathonherbert! I've tried to address them in my latest commit, appreciate if you could take another look. If anything looks wrong, please let me know.