Esempio n. 1
0
    def register_default_user_profile_pages(self):
        def posts_badge(request, profile):
            return {
                'value': profile.posts,
                'attr': 'posts',
            }

        def threads_badge(request, profile):
            return {
                'value': profile.threads,
                'attr': 'threads',
            }

        def followers_badge(request, profile):
            return {
                'value': profile.followers,
                'attr': 'followers',
            }

        def following_badge(request, profile):
            return {
                'value': profile.following,
                'attr': 'following',
            }

        def can_see_names_history(request, profile):
            if request.user.is_authenticated():
                is_account_owner = profile.pk == request.user.pk
                has_permission = request.user.acl['can_see_users_name_history']
                return is_account_owner or has_permission
            else:
                return False

        def can_see_ban_details(request, profile):
            if request.user.is_authenticated():
                if request.user.acl['can_see_ban_details']:
                    from misago.users.bans import get_user_ban
                    return bool(get_user_ban(profile))
                else:
                    return False
            else:
                return False

        user_profile.add_section(
            link='misago:user-posts',
            name=_("Posts"),
            icon='message',
            component='posts',
            get_metadata=posts_badge,
        )
        user_profile.add_section(
            link='misago:user-threads',
            name=_("Threads"),
            icon='forum',
            component='threads',
            get_metadata=threads_badge,
        )
        user_profile.add_section(
            link='misago:user-followers',
            name=_("Followers"),
            icon='favorite',
            component='followers',
            get_metadata=followers_badge,
        )
        user_profile.add_section(
            link='misago:user-follows',
            name=_("Follows"),
            icon='favorite_border',
            component='follows',
            get_metadata=following_badge,
        )
        user_profile.add_section(
            link='misago:username-history',
            name=_("Username history"),
            icon='card_membership',
            component='username-history',
            visible_if=can_see_names_history,
        )
        user_profile.add_section(
            link='misago:user-ban',
            name=_("Ban details"),
            icon='remove_circle_outline',
            component='ban-details',
            visible_if=can_see_ban_details,
        )
Esempio n. 2
0
    def register_default_user_profile_pages(self):
        def posts_badge(request, profile):
            return profile.posts

        def threads_badge(request, profile):
            return profile.threads

        def followers_badge(request, profile):
            return profile.followers

        def following_badge(request, profile):
            return profile.following

        def can_see_names_history(request, profile):
            if request.user.is_authenticated():
                is_account_owner = profile.pk == request.user.pk
                has_permission = request.user.acl['can_see_users_name_history']
                return is_account_owner or has_permission
            else:
                return False

        def can_see_warnings(request, profile):
            if request.user.is_authenticated():
                is_account_owner = profile.pk == request.user.pk
                user_acl = request.user.acl
                has_permission = user_acl['can_see_other_users_warnings']
                return is_account_owner or has_permission
            else:
                return False

        def can_see_ban_details(request, profile):
            if request.user.is_authenticated():
                if request.user.acl['can_see_ban_details']:
                    from misago.users.bans import get_user_ban
                    return bool(get_user_ban(profile))
                else:
                    return False
            else:
                return False

        user_profile.add_section(
            link='misago:user_posts',
            name=_("Posts"),
            get_metadata=posts_badge)

        user_profile.add_section(
            link='misago:user_threads',
            name=_("Threads"),
            get_metadata=threads_badge)

        user_profile.add_section(
            link='misago:user_followers',
            name=_("Followers"),
            get_metadata=followers_badge)

        user_profile.add_section(
            link='misago:user_follows',
            name=_("Follows"),
            get_metadata=following_badge)

        user_profile.add_section(
            link='misago:user_name_history',
            name=_("Name history"),
            visible_if=can_see_names_history)

        user_profile.add_section(
            link='misago:user_warnings',
            name=_("Warnings"),
            visible_if=can_see_warnings)

        user_profile.add_section(
            link='misago:user_ban',
            name=_("Ban"),
            visible_if=can_see_ban_details)
Esempio n. 3
0
    def register_default_user_profile_pages(self):
        def posts_badge(request, profile):
            return profile.posts

        def threads_badge(request, profile):
            return profile.threads

        def followers_badge(request, profile):
            return profile.followers

        def following_badge(request, profile):
            return profile.following

        def can_see_names_history(request, profile):
            if request.user.is_authenticated():
                is_account_owner = profile.pk == request.user.pk
                has_permission = request.user.acl['can_see_users_name_history']
                return is_account_owner or has_permission
            else:
                return False

        def can_see_warnings(request, profile):
            if request.user.is_authenticated():
                is_account_owner = profile.pk == request.user.pk
                user_acl = request.user.acl
                has_permission = user_acl['can_see_other_users_warnings']
                return is_account_owner or has_permission
            else:
                return False

        def can_see_ban_details(request, profile):
            if request.user.is_authenticated():
                if request.user.acl['can_see_ban_details']:
                    from misago.users.bans import get_user_ban
                    return bool(get_user_ban(profile))
                else:
                    return False
            else:
                return False

        user_profile.add_section(link='misago:user_posts',
                                 name=_("Posts"),
                                 get_metadata=posts_badge)

        user_profile.add_section(link='misago:user_threads',
                                 name=_("Threads"),
                                 get_metadata=threads_badge)

        user_profile.add_section(link='misago:user_followers',
                                 name=_("Followers"),
                                 get_metadata=followers_badge)

        user_profile.add_section(link='misago:user_follows',
                                 name=_("Follows"),
                                 get_metadata=following_badge)

        user_profile.add_section(link='misago:user_name_history',
                                 name=_("Name history"),
                                 visible_if=can_see_names_history)

        user_profile.add_section(link='misago:user_warnings',
                                 name=_("Warnings"),
                                 visible_if=can_see_warnings)

        user_profile.add_section(link='misago:user_ban',
                                 name=_("Ban"),
                                 visible_if=can_see_ban_details)