def check_level(cls, data):
        fields = set(PROFILE_EDITABLE_FIELDS)
        profile = get_profile(data.user)
        level = cls.NONE

        # First level: user completed the site tour.
        if True:
            level = cls.PROFILE_LVL1
        else:
            return level

        # Second level: user uploaded a photo and filled drop-downs.
        if profile.profile_photo and filled_gender_and_race(profile, fields):
            level = cls.PROFILE_LVL2
        else:
            return level

        # Third level: all one-liner fields.
        if filled_fields(profile, basic_profile_fields(fields)):
            level = cls.PROFILE_LVL3
        else:
            return level

        # Last level: user filled *ALL* profile info.
        if filled_gender_and_race(profile, fields) and filled_fields(profile, fields):
            level = cls.PROFILE_LVL4
        return level
    def achieve_next_level_msg(self, data):
        p = get_profile(data.user)
        fields = set(PROFILE_EDITABLE_FIELDS)

        if self == self.PROFILE_LVL4:
            return _("Congratulations! Your profile is complete!")

        elif self == self.NONE:
            return _("Please take the site tour!")

        elif self == self.PROFILE_LVL1:
            missing = []
            if "race" in fields and p.race == Race.NOT_FILLED:
                missing.append("race")
            if "gender" in fields and p.gender == Gender.NOT_FILLED:
                missing.append("gender")
            if not p.profile_photo:
                missing.append("profile photo")
            if missing:
                return missing_fields_message(missing)

        elif self == self.PROFILE_LVL2:
            fields_ = basic_profile_fields(fields)
            return missing_fields_message(missing_fields(p, fields_))

        elif self == self.PROFILE_LVL3:
            return missing_fields_message(missing_fields(p, fields))
示例#3
0
    def check_level(cls, data):
        fields = set(PROFILE_EDITABLE_FIELDS)
        profile = get_profile(data.user)
        level = cls.NONE

        # First level: user completed the site tour.
        if True:
            level = cls.BASIC
        else:
            return level

        # Second level: user uploaded a photo.
        if profile.profile_photo and filled_gender_and_race(profile, fields):
            level = cls.RELEVANT
        else:
            return level

        # Third level: all one-liner fields.
        if filled_fields(profile, basic_profile_fields(fields)):
            level = cls.INFORMATIVE
        else:
            return level

        # Last level: user filled *ALL* profile info.
        if filled_gender_and_race(profile, fields) and filled_fields(profile, fields):
            level = cls.COMPLETE
        return level