def _get_enrollment_data(self, data, course_settings):
        """Returns a file in memory with a new or updated enroll."""
        user, _ = get_user(email=data.get('user_email'))
        dropbox_file = self._get_course_list(course_settings).text
        enrollment_data = u'{date}, {fullname}, {first_name}, {last_name}, {email}, {course_id}, {enrolled}\n'.format(
            date=datetime.now().strftime(settings.DROPBOX_DATE_FORMAT),
            fullname=user.profile.name,
            first_name=user.first_name,
            last_name=user.last_name,
            email=user.email,
            course_id=course_settings.get('external_course_run_id'),
            enrolled=str(data.get('is_active')).lower(),
        )
        dropbox_file += enrollment_data
        temp_file = io.StringIO()
        temp_file.write(dropbox_file)
        temp_file.seek(0)

        return temp_file.getvalue()
    def _get_openedx_user(data):
        """

        :param data:
        :return:
        """
        user = {}
        order_lines = data.get("supported_lines")
        if order_lines:
            try:
                email = order_lines[0].get("user_email")
                _, openedx_profile = get_user(email=email)
                # TODO do not force logic assuming names with 2 words
                first_name, last_name = openedx_profile.name.split(" ", 1)
                user["FirstName"] = first_name.strip(" ")
                user["LastName"] = last_name.strip(" ")
                user["Email"] = email
            except Exception:  # pylint: disable=broad-except
                pass

        return user
    def _get_openedx_user(data):
        """
        :param data:
        :return:
        """
        user = {}
        order_lines = data.get("supported_lines")
        if order_lines:
            try:
                email = order_lines[0].get("user_email")
                _, openedx_profile = get_user(email=email)

                user["Email"] = email
                if openedx_profile.user.first_name:
                    user["FirstName"] = openedx_profile.user.first_name
                    user["LastName"] = openedx_profile.user.last_name
                else:
                    first_name, last_name = openedx_profile.name.split(" ", 1)
                    user["FirstName"] = first_name.strip(" ")
                    user["LastName"] = last_name.strip(" ")
            except Exception:  # pylint: disable=broad-except
                pass

        return user