adhocracy4
adhocracy4 copied to clipboard
Refactoring plan
What is this?
In the Scrum of scrums on (18th July 2017) it was decided that we collect a list of bigger refactorings that we want to todo to give them back into the scrum process.
project/module mixin
Most operations in a typical adhocracy4 platform happen inside in the context of a project or a module (which also implies a project). Currently we have some ways to find those contexts
- read
module_slugparameter from url (eg. creation of ideas and other items) - read
moduleproperty of a project mixin, which in turn reads theproject_slugof the url (eg. listing of ideas) - read
projectfromproject_slugslug of the url (eg. project detail view / all views extending project mixin) - read
moduleorprojectfromself.objectif the object is an item
The same issue exists to some extend also for forms, that want to create an item.
What would be a good solution:
- implement an view(-mixin/baseclass) that provides
self.projectandself.module- it should automatically try to get the values from their respective url slugs, or
self.objectif it has anprojectormoduleproperty - it should allow to override the
projectormoduleproperty if needed - it should provide those values to the template via
get_context - it should provide the most specific value to the form via
get_form_kwargs(possibly introspecting the form, if it needs that value)
- it should automatically try to get the values from their respective url slugs, or
- implement an model form(-mixin/baseclass) that receives the project or module parameter from the view
- it should set that value as a property of a for
- it should on save set the project or module property of the saved object (maybe that needs to be configurable)
- it should target create forms primarily (maybe something similar could be done for update forms, but that should read the value from the instance instead)
makeing item an abstract model
Currently we are using item as an concrete model (with it own table). This type of inheritance is discouraged in many Django guides. In addition we never ~~(or seldom)~~ use that model, so is there really a need for it.
pro
- don't use multi table inheritance
contra
- lose ability to give an unqiue number to each item
The project/module may also be derived from the Item itself: f.ex. in detail the detail view:
- read
moduleproperty of an 'item', which is a foreign key. the 'item' itself is determined via theslugparam. an 'item' may be f.ex. anIdea, aPollor anOfflineEvent
I edited the proposal to include reading of the module property.
Should we split each refactoring into its own issue, and just collect the list of issues here? That would allow to discuss each on it own.