There is no group type column in the DB. Instead, the group table has three separate columns joinable_by, readable_by and writeable_by. models.Group.type is a @property that returns "private", "restricted" or "open" depending on the values of joinable_by, readable_by and writeable_by.
Currently models.Group.type isn't writeable: there's no setter for the property.
Add a setter for models.Group.type that accepts a simple type string "private", "restricted" or "open" and sets the underlying joinable_by, readable_by and writeable_by attributes appropriately so that reading the type property will now return the given "private", "restricted" or "open" string.
So now you can change a group's type by just doing:
some_group.type = "open"
Group type changes would normally be done via GroupUpdateService.update(). That service method just sets arbitrary kwargs on the group object so I didn't need to make any service-method changes to add support for the new type setter. Previously if you did group_update_svc.update(group, type="open") it would raise TypeError because it would try to set group.type = "open" but the property has no setter. Now it will work. I added a service test to prove this.
There is no group type column in the DB. Instead, the
group
table has three separate columnsjoinable_by
,readable_by
andwriteable_by
.models.Group.type
is a@property
that returns"private"
,"restricted"
or"open"
depending on the values ofjoinable_by
,readable_by
andwriteable_by
.Currently
models.Group.type
isn't writeable: there's no setter for the property.Add a setter for
models.Group.type
that accepts a simple type string"private"
,"restricted"
or"open"
and sets the underlyingjoinable_by
,readable_by
andwriteable_by
attributes appropriately so that reading thetype
property will now return the given"private"
,"restricted"
or"open"
string.So now you can change a group's type by just doing:
Group type changes would normally be done via
GroupUpdateService.update()
. That service method just sets arbitrary kwargs on thegroup
object so I didn't need to make any service-method changes to add support for the newtype
setter. Previously if you didgroup_update_svc.update(group, type="open")
it would raiseTypeError
because it would try to setgroup.type = "open"
but the property has no setter. Now it will work. I added a service test to prove this.