As a service provider I can manage my Hobbies
Opened this issue · 1 comments
indigane commented
Users representing a service provider must be able to create and manage hobbies provided by that service provider.
Municipality moderators must be able to moderate the hobbies that are being provided within their municipality, so the municipality information must be included in the hobbies created by the service provider users.
Note that in the Hobby
model there is also an organizer
field, but for the purpose of this issue it should not be mixed with the concept of a service provider.
indigane commented
Suggestion for the implementation
- A new model
ServiceProvider
will be added. ServiceProvider
will have adefault_municipality
field. This will be used to determine themunicipality
of theHobby
objects created by theServiceProvider
. This way changes to the admin UI are not needed in this issue. Later ifServiceProviders
operate in multiple municipalities, a municipality field can be added to the admin UI, where the default value is picked fromdefault_municipality
.ServiceProvider
will have a many-to-many field pointing to theUser
model. These are the users who represent the service provider, and have access to create and manage the service provider's hobbies.- In
tasks.py
permission update tasks, a check through theServiceProvider
users many-to-many will be added, similar tomunicipality.moderators
. perform_create
forHobby
,Location
andPromotion
will be changed to get the municipality throughServiceProvider.default_municipality
. Additional logic can be added to see if the old municipality moderator relation should be used, or the new service provider relation.
Because Municipality
objects have been used to emulate ServiceProvider
in the absence of the concept of a service provider this data needs to be migrated.
- A data migration will be created, in the form of a script or management command, not through the Django migration files.
- The data migration will
- Copy data from
Municipality
objects intoServiceProvider
objects - Point all
Hobby
objects to theServiceProvider
object corresponding the oldMunicipality
object. - Add all
Users
fromMunicipality.moderators
into theServiceProvider
User
many-to-many. - Set the
ServiceProvider.default_municipality
to the correct municipality, such as Helsinki.
- Copy data from