(self, logged_in_username: str)
return user_dto
Create DTO object from user in scope
Create DTO object from user in scope
Create DTO object from user in scope
def as_dto(self, logged_in_username: str) -> UserDTO:
        """ Create DTO object from user in scope """
        user_dto = UserDTO()
        user_dto.id = self.id
        user_dto.username = self.username
        user_dto.role = UserRole(self.role).name
        user_dto.mapping_level = MappingLevel(self.mapping_level).name
        user_dto.projects_mapped = (
            len(self.projects_mapped) if self.projects_mapped else None
        )
        user_dto.is_expert = self.is_expert or False
        user_dto.date_registered = self.date_registered
        user_dto.twitter_id = self.twitter_id
        user_dto.linkedin_id = self.linkedin_id
        user_dto.facebook_id = self.facebook_id
        user_dto.skype_id = self.skype_id
        user_dto.slack_id = self.slack_id
        user_dto.irc_id = self.irc_id
        user_dto.city = self.city
        user_dto.country = self.country
        user_dto.name = self.name
        user_dto.picture_url = self.picture_url
        user_dto.default_editor = self.default_editor
        user_dto.mentions_notifications = self.mentions_notifications
        user_dto.projects_notifications = self.projects_notifications
        user_dto.comments_notifications = self.comments_notifications
        user_dto.tasks_notifications = self.tasks_notifications
        user_dto.teams_notifications = self.teams_notifications

        if self.username == logged_in_username:
            # Only return email address and gender information when logged in user is looking at their own profile
            user_dto.email_address = self.email_address
            user_dto.is_email_verified = self.is_email_verified
            gender = None
            if self.gender is not None:
                gender = UserGender(self.gender).name
                user_dto.gender = gender
                user_dto.self_description_gender = self.self_description_gender
        return user_dto
def as_dto ( self , logged_in_username : str ) -> UserDTO : user_dto = UserDTO ( ) user_dto . id = self . id user_dto . username = self . username user_dto . role = UserRole ( self . role ) . name user_dto . mapping_level = MappingLevel ( self . mapping_level ) . name user_dto . projects_mapped = ( len ( self . projects_mapped ) if self . projects_mapped else None ) user_dto . is_expert = self . is_expert or False user_dto . date_registered = self . date_registered user_dto . twitter_id = self . twitter_id user_dto . linkedin_id = self . linkedin_id user_dto . facebook_id = self . facebook_id user_dto . skype_id = self . skype_id user_dto . slack_id = self . slack_id user_dto . irc_id = self . irc_id user_dto . city = self . city user_dto . country = self . country user_dto . name = self . name user_dto . picture_url = self . picture_url user_dto . default_editor = self . default_editor user_dto . mentions_notifications = self . mentions_notifications user_dto . projects_notifications = self . projects_notifications user_dto . comments_notifications = self . comments_notifications user_dto . tasks_notifications = self . tasks_notifications user_dto . teams_notifications = self . teams_notifications if self . username == logged_in_username : # Only return email address and gender information when logged in user is looking at their own profile user_dto . email_address = self . email_address user_dto . is_email_verified = self . is_email_verified gender = None if self . gender is not None : gender = UserGender ( self . gender ) . name user_dto . gender = gender user_dto . self_description_gender = self . self_description_gender return user_dto