ImperialCollegeLondon / dune_processes

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Use unmanaged model for Drunc processes #63

Open AdrianDAlessandro opened 1 week ago

AdrianDAlessandro commented 1 week ago

This kind of thing is information that would normally be contained within a Model. I think we should probably refactor what we have to use and unmanaged model so that we can centralise the data structures within models.py and take advantage of the extra functionality that's built into Django surrounding models.

_Originally posted by @AdrianDAlessandro in https://github.com/ImperialCollegeLondon/dune_processes/pull/59#discussion_r1753701809_

This also can apply to the tables and forms that we are currently using.

AdrianDAlessandro commented 4 days ago

From offline conversation:

@cc-a : I've not really looked at unmanaged models before but it looks to me like they're still meant for working with stuff in the database. So it won't try to manage the database table but will still try and save data if the save method is called on an instance. TBH I can't really see it as a replacement for an enum that is just being used to represent options in a function call. Maybe more so for the forms and tables but we'd probably want to override some of the class methods to stop people trying to save objects which kind of makes me think we'd be abusing the intended purpose.

@AdrianDAlessandro: Yea, I agree. We don't want to use a model because we don't have a DB to interact with. But I think the lack of models means we're losing a bit of the natural separation of concerns that they help keep. We're defining data structure logic in the views, tables and forms which should really live somewhere else. So yes, agreed that an unmanaged model isn't the way to do it, but we need some kind of single-source-of-truth for data structures.