Пример #1
0
    def get_openness_level_for_user(self, user):
        """returns descriptive value, because it is to be used in the
        templates. The value must match the verbose versions of the
        openness choices!!!
        """
        if user.is_anonymous():
            return 'closed'

        #a special case - automatic global group cannot be joined or left
        if self.name == askbot_settings.GLOBAL_GROUP_NAME:
            return 'closed'

        #todo - return 'closed' for internal per user groups too

        if self.openness == Group.OPEN:
            return 'open'

        if user.is_administrator_or_moderator():
            return 'open'

        #relying on a specific method of storage
        from askbot.utils.forms import email_is_allowed
        if email_is_allowed(
            user.email,
            allowed_emails=self.preapproved_emails,
            allowed_email_domains=self.preapproved_email_domains
        ):
            return 'open'

        if self.openness == Group.MODERATED:
            return 'moderated'

        return 'closed'
Пример #2
0
    def get_openness_level_for_user(self, user):
        """returns descriptive value, because it is to be used in the
        templates. The value must match the verbose versions of the
        openness choices!!!
        """
        if user.is_anonymous():
            return 'closed'

        #a special case - automatic global group cannot be joined or left
        if self.name == askbot_settings.GLOBAL_GROUP_NAME:
            return 'closed'

        #todo - return 'closed' for internal per user groups too

        if self.openness == Group.OPEN:
            return 'open'

        if user.is_administrator_or_moderator():
            return 'open'

        #relying on a specific method of storage
        from askbot.utils.forms import email_is_allowed
        if email_is_allowed(
                user.email,
                allowed_emails=self.preapproved_emails,
                allowed_email_domains=self.preapproved_email_domains):
            return 'open'

        if self.openness == Group.MODERATED:
            return 'moderated'

        return 'closed'
Пример #3
0
    def can_accept_user(self, user):
        """True if user is preapproved to join the group"""
        if user.is_anonymous():
            return False

        if self.is_open:
            return True

        if user.is_administrator_or_moderator():
            return True

        #relying on a specific method of storage
        return email_is_allowed(
            user.email,
            allowed_emails=self.preapproved_emails,
            allowed_email_domains=self.preapproved_email_domains)

        return False
Пример #4
0
    def can_accept_user(self, user):
        """True if user is preapproved to join the group"""
        if user.is_anonymous():
            return False

        if self.is_open:
            return True

        if user.is_administrator_or_moderator():
            return True

        #relying on a specific method of storage
        return email_is_allowed(
            user.email,
            allowed_emails=self.preapproved_emails,
            allowed_email_domains=self.preapproved_email_domains
        )

        return False