Exemplo n.º 1
0
def check_can_join_community_with_name(user, community_name):
    if user.is_banned_from_community_with_name(community_name):
        raise ValidationError('Вы не можете присоединиться к сообществу, в котором вы были заблокированы.')

    if user.is_member_of_community_with_name(community_name):
        raise ValidationError(
            'Вы уже являетесь подписчиков сообщества',
        )

    if Community.is_community_with_name_private(community_name=community_name):
        if not user.is_invited_to_community_with_name(community_name=community_name):
            raise ValidationError(
                'Вы не приглашены в это сообщество',
            )
Exemplo n.º 2
0
def check_can_get_posts_for_community_with_name(user, community_name):
    check_is_not_banned_from_community_with_name(user=user, community_name=community_name)
    if Community.is_community_with_name_private(
            community_name=community_name) and not user.is_member_of_community_with_name(
        community_name=community_name):
        raise ValidationError(
            'Сообщество является приватным. Вы должны стать участником, чтобы видеть его записи.',
        )
    if Community.is_community_with_name_closed(
            community_name=community_name) and not user.is_member_of_community_with_name(
        community_name=community_name):
        raise ValidationError(
            'Сообщество является закрытым. Вы должны стать участником, чтобы видеть его записи.',
        )