Commit 7baecd3a by jareerahsan Committed by GitHub

Merge pull request #14317 from edx/jareer/ecom-2963-added-new-fields-in-email-opt-out

Added username and user_id in opt out email csv.
parents 09030734 8afc273d
......@@ -49,6 +49,8 @@ class Command(BaseCommand):
# Fields output in the CSV
OUTPUT_FIELD_NAMES = [
"user_id",
"username",
"email",
"full_name",
"course_id",
......@@ -199,6 +201,8 @@ class Command(BaseCommand):
query = (
u"""
SELECT
user.`id` AS `user_id`,
user.`username` AS username,
user.`email` AS `email`,
profile.`name` AS `full_name`,
enrollment.`course_id` AS `course_id`,
......@@ -234,8 +238,10 @@ class Command(BaseCommand):
cursor.execute(query)
row_count = 0
for row in self._iterate_results(cursor):
email, full_name, course_id, is_opted_in, pref_set_datetime = row
user_id, username, email, full_name, course_id, is_opted_in, pref_set_datetime = row
writer.writerow({
"user_id": user_id,
"username": username.encode('utf-8'),
"email": email.encode('utf-8'),
# There should not be a case where users are without full_names. We only need this safe check because
# of ECOM-1995.
......
......@@ -36,6 +36,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
OUTPUT_FILE_NAME = "test_org_email_opt_in.csv"
OUTPUT_FIELD_NAMES = [
"user_id",
"username",
"email",
"full_name",
"course_id",
......@@ -400,6 +402,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
# Check the header row
self.assertEqual({
"user_id": "user_id",
"username": "username",
"email": "email",
"full_name": "full_name",
"course_id": "course_id",
......@@ -410,6 +414,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
# Check data rows
for user, course_id, opt_in_pref in args:
self.assertIn({
"user_id": str(user.id),
"username": user.username.encode('utf-8'),
"email": user.email.encode('utf-8'),
"full_name": (
user.profile.name.encode('utf-8')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment