djangoflow / django-df-chat

Djangoflow in-app chat server using django-channels
MIT License
0 stars 16 forks source link

add categories (mptt) for rooms #10

Closed marbleyung closed 1 year ago

marbleyung commented 1 year ago

first of all, create some categories and rooms via admin _ http://localhost:8000/api/v1/chat/rooms/ to check existing rooms http://localhost:8000/api/v1/chat/categories/ to check existing categories http://localhost:8000/api/v1/chat/categories//rooms/ to check rooms belong to the category

eugapx commented 1 year ago

@marbleyung I updated project structure to python module, could you please update the commit?

Also, I think we don't need Tree-like categories, flat structure should be enough.

marbleyung commented 1 year ago

@eugapx Fine, it's done. Didn't mean to commit 5 times instead of one, sorry :)

marbleyung commented 1 year ago

@eugapx I've did all the changes you noticed. What's for user-specific categories, I've reconstructed Categories. Now, going to http://localhost:8000/api/v1/chat/rooms/ you can create room without category Also you can to go http://localhost:8000/api/v1/chat/categories/ and create a category first Then when creating a room you can pass Category ID in category_id field, so the room will belong to the category Categories are specific for each user. They also have unique constraint 'unique_together = ('owner', 'title'); Categories have CRUD functionality (put is not available - use patch instead). Filters work like http://localhost:8000/api/v1/chat/rooms/?category= Category gets 'owner' field filled auto after POST, and its value equals to user, send POST. I've tested it with postman and everything was fine. I hope migrations squashed well too.

marbleyung commented 1 year ago

@eugapx done

marbleyung commented 1 year ago

@eugapx not sure that Category.rooms will be better than Room.categories, but I did it. One serializer for both GET categories and POST categories on api/v1/chat/rooms/ seems like bad solution because it overloads the output data. I'm not sure about fields which is necessary to display. Plus there is some troubles with Postman auth so now it is very difficult to test all the methods, but I think they should work stable because nothing of their core has been changed.