def to_representation(self, instance): ret = super(ConversationSerializer, self).to_representation(instance) blank_to_none(ret, ['icon', 'subject']) blank_to_none(ret['display'], ['title', 'sub_title', 'image']) if ret['type'] != str(CONVERSATION_TYPE_PUBLIC_CHAT): del ret['location'] return ret
def to_representation(self, instance): if instance.is_muted or instance.is_disabled: return InactiveShout().to_dict ret = super(ShoutSerializer, self).to_representation(instance) if 'filters' in ret: ret['filters'].sort(key=lambda c: c['name']) blank_to_none(ret, ['title', 'text']) return ret
def to_representation(self, instance): ret = super(MessageSerializer, self).to_representation(instance) blank_to_none(ret, ['text']) # Client id, Todo: check if it is still used by any client request = self.root.context.get('request') if request and request.method == 'POST': data = getattr(request, 'data', {}) client_id = data.get('client_id') if client_id: ret['client_id'] = request.data.get('client_id') return ret
def to_representation(self, instance): ret = super(DiscoverItemDetailSerializer, self).to_representation(instance) if not instance.show_shouts: ret.pop('shouts_url', None) blank_to_none(ret, ['image', 'cover', 'icon']) return ret
def to_representation(self, instance): ret = super(DiscoverItemSerializer, self).to_representation(instance) blank_to_none(ret, ['image', 'cover', 'icon']) return ret
def to_representation(self, instance): ret = super(MiniTagSerializer, self).to_representation(instance) blank_to_none(ret, ['image']) # Compatibility for older clients expecting `name` to be the unique identifier of Tag object self.compat_name(ret) return ret
def to_representation(self, instance): ret = super(CategorySerializer, self).to_representation(instance) blank_to_none(ret, ['image', 'icon']) return ret
def to_representation(self, instance): ret = super(PageDetailSerializer, self).to_representation(instance) blank_to_none(ret, ['about', 'description', 'phone', 'founded', 'impressum', 'overview', 'mission', 'general_info']) return ret
def to_representation(self, instance): ret = super(NotificationSerializer, self).to_representation(instance) blank_to_none(ret['display'], ['text', 'image']) return ret
def to_representation(self, instance): ret = super(ReportSerializer, self).to_representation(instance) blank_to_none(ret, ['text']) return ret