mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-18 00:21:14 +10:00
The first steps or whatever
balls
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
class CommunitySerializer():
|
||||
"""
|
||||
Serializes communities for use with JSON
|
||||
"""
|
||||
@staticmethod
|
||||
def single(community):
|
||||
"""
|
||||
Return one dict for a community, meant to be used in community pages, etc
|
||||
"""
|
||||
return {
|
||||
'id': community.id,
|
||||
'unique_id': str(community.unique_id),
|
||||
'name': community.name,
|
||||
'icon': (community.icon() or None),
|
||||
'banner': (community.banner or None),
|
||||
'description': community.description,
|
||||
'type': community.type,
|
||||
'platform': community.platform,
|
||||
'allowed_users': json.loads(community.allowed_users) if community.allowed_users else None,
|
||||
'creator': community.creator_id
|
||||
}
|
||||
@staticmethod
|
||||
def many(queryset):
|
||||
"""
|
||||
Return a community meant to be used in a bigger list, etc
|
||||
"""
|
||||
return [
|
||||
{
|
||||
'id': community.id,
|
||||
'name': community.name,
|
||||
'icon': (community.icon() or None),
|
||||
'banner': (community.banner or None),
|
||||
'type': community.type,
|
||||
'platform': community.platform
|
||||
} for community in queryset
|
||||
]
|
||||
Reference in New Issue
Block a user