USStateDept / State-TalentMAP-API

Source Code - https://github.com/USStateDept/State-TalentMAP
Other
12 stars 11 forks source link

Consider inverting the specifying of read-only model fields #107

Closed jseppi closed 6 years ago

jseppi commented 6 years ago

Ref https://github.com/18F/State-TalentMAP-API/commit/ab8a7b47b4fcebec08ea4fb9cf8d10c090f1e5d5#commitcomment-24093849

Rather than specifying the read-only fields of each model, consider specifying the fields that are modifiable instead.

afrasier commented 6 years ago

That'd probably be best, I'll have to poke around with DRF serializer meta objects since I know it has read_only_fields but I'm not sure if the inverse exists

afrasier commented 6 years ago

Maybe something like

class Meta:
    read_only_fields = "__all__"
    fields = ("writable_field_1",)

might work, but I'll leave this for next sprint

afrasier commented 6 years ago

Ok, I have a PR ready for this once #127 is merged in I can rebase my local branch and push and PR. Surprisingly simple solution to this one.