data = pagination_dict(page)
        data.update({'results': UsernameChangeSerializer(page.object_list, many=True).data})

        request.frontend_context['PROFILE_NAME_HISTORY'] = data

        return {
            'history': page.object_list,
            'count': data['count'],
        }


class UserBanView(ProfileView):
    template_name = 'misago/profile/ban_details.html'

    def get_context_data(self, request, profile):
        ban = get_user_ban(profile)

        request.frontend_context['PROFILE_BAN'] = BanDetailsSerializer(ban).data

        return {
            'ban': ban,
        }


UserProfileSerializer = UserSerializer.subset_fields(
    'id', 'username', 'slug', 'email', 'joined_on', 'rank', 'title', 'avatars', 'is_avatar_locked',
    'signature', 'is_signature_locked', 'followers', 'following', 'threads', 'posts', 'acl',
    'is_followed', 'is_blocked', 'status', 'api', 'url'
)
Beispiel #2
0
        page = get_int_or_404(request.query_params.get('page', 0))
        if page == 1:
            page = 0  # api allows explicit first page

        feed = UserPosts(request, profile, page)

        return Response(feed.get_frontend_context())


UserProfileSerializer = UserSerializer.subset_fields(
    'id',
    'username',
    'slug',
    'email',
    'joined_on',
    'rank',
    'title',
    'avatars',
    'is_avatar_locked',
    'signature',
    'is_signature_locked',
    'followers',
    'following',
    'threads',
    'posts',
    'is_followed',
    'is_blocked',
    'status',
)
Beispiel #3
0
from django.urls import reverse

from misago.core.serializers import MutableFields
from misago.threads.models import Post
from misago.users.serializers import UserSerializer as BaseUserSerializer


__all__ = ['PostSerializer']

UserSerializer = BaseUserSerializer.subset_fields(
    'id',
    'username',
    'rank',
    'avatars',
    'signature',
    'title',
    'status',
    'posts',
    'url',
)


class PostSerializer(serializers.ModelSerializer, MutableFields):
    poster = UserSerializer(many=False, read_only=True)
    poster_ip = serializers.SerializerMethodField()
    content = serializers.SerializerMethodField()
    attachments = serializers.SerializerMethodField()
    last_editor = serializers.PrimaryKeyRelatedField(read_only=True)
    hidden_by = serializers.PrimaryKeyRelatedField(read_only=True)
from misago.categories.serializers import CategorySerializer
from misago.core.serializers import MutableFields
from misago.threads.models import Post
from misago.users.serializers import UserSerializer

from .post import PostSerializer


__all__ = [
    'FeedSerializer',
]

FeedUserSerializer = UserSerializer.subset_fields(
    'id',
    'username',
    'avatars',
    'url',
    'title',
    'rank',
)

FeedCategorySerializer = CategorySerializer.subset_fields('name', 'css_class', 'url')


class FeedSerializer(PostSerializer, MutableFields):
    poster = FeedUserSerializer(many=False, read_only=True)
    category = FeedCategorySerializer(many=False, read_only=True)

    thread = serializers.SerializerMethodField()

    class Meta:
        model = Post
Beispiel #5
0
from rest_framework import serializers

from misago.categories.serializers import CategorySerializer
from misago.core.serializers import MutableFields
from misago.threads.models import Post
from misago.users.serializers import UserSerializer

from .post import PostSerializer


__all__ = [
    'FeedSerializer',
]

FeedUserSerializer = UserSerializer.subset_fields('id', 'username', 'avatars', 'absolute_url')

FeedCategorySerializer = CategorySerializer.subset_fields('name', 'css_class', 'absolute_url')


class FeedSerializer(PostSerializer, MutableFields):
    poster = FeedUserSerializer(many=False, read_only=True)
    category = FeedCategorySerializer(many=False, read_only=True)

    thread = serializers.SerializerMethodField()
    top_category = serializers.SerializerMethodField()

    class Meta:
        model = Post
        fields = PostSerializer.Meta.fields + ['category', 'thread', 'top_category']

    def get_thread(self, obj):
Beispiel #6
0
from misago.api.serializers import MutableFields
from misago.categories.serializers import CategorySerializer
from misago.threads.models import Post
from misago.users.serializers import UserSerializer

from .post import PostSerializer

__all__ = [
    'FeedSerializer',
]

FeedUserSerializer = UserSerializer.subset_fields(
    'id',
    'username',
    'avatars',
    'url',
    'title',
    'rank',
)

FeedCategorySerializer = CategorySerializer.subset_fields(
    'name', 'css_class', 'url')


class FeedSerializer(PostSerializer, MutableFields):
    poster = FeedUserSerializer(many=False, read_only=True)
    category = FeedCategorySerializer(many=False, read_only=True)

    thread = serializers.SerializerMethodField()

    class Meta: