Commit 8afc273d by Jareer Ahsan

Added username and user_id in opt out email csv.

ECOM-2963
parent 28e3b1cb
...@@ -49,6 +49,8 @@ class Command(BaseCommand): ...@@ -49,6 +49,8 @@ class Command(BaseCommand):
# Fields output in the CSV # Fields output in the CSV
OUTPUT_FIELD_NAMES = [ OUTPUT_FIELD_NAMES = [
"user_id",
"username",
"email", "email",
"full_name", "full_name",
"course_id", "course_id",
...@@ -199,6 +201,8 @@ class Command(BaseCommand): ...@@ -199,6 +201,8 @@ class Command(BaseCommand):
query = ( query = (
u""" u"""
SELECT SELECT
user.`id` AS `user_id`,
user.`username` AS username,
user.`email` AS `email`, user.`email` AS `email`,
profile.`name` AS `full_name`, profile.`name` AS `full_name`,
enrollment.`course_id` AS `course_id`, enrollment.`course_id` AS `course_id`,
...@@ -234,8 +238,10 @@ class Command(BaseCommand): ...@@ -234,8 +238,10 @@ class Command(BaseCommand):
cursor.execute(query) cursor.execute(query)
row_count = 0 row_count = 0
for row in self._iterate_results(cursor): 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({ writer.writerow({
"user_id": user_id,
"username": username.encode('utf-8'),
"email": email.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 # There should not be a case where users are without full_names. We only need this safe check because
# of ECOM-1995. # of ECOM-1995.
......
...@@ -37,6 +37,8 @@ class EmailOptInListTest(ModuleStoreTestCase): ...@@ -37,6 +37,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
OUTPUT_FILE_NAME = "test_org_email_opt_in.csv" OUTPUT_FILE_NAME = "test_org_email_opt_in.csv"
OUTPUT_FIELD_NAMES = [ OUTPUT_FIELD_NAMES = [
"user_id",
"username",
"email", "email",
"full_name", "full_name",
"course_id", "course_id",
...@@ -401,6 +403,8 @@ class EmailOptInListTest(ModuleStoreTestCase): ...@@ -401,6 +403,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
# Check the header row # Check the header row
self.assertEqual({ self.assertEqual({
"user_id": "user_id",
"username": "username",
"email": "email", "email": "email",
"full_name": "full_name", "full_name": "full_name",
"course_id": "course_id", "course_id": "course_id",
...@@ -411,6 +415,8 @@ class EmailOptInListTest(ModuleStoreTestCase): ...@@ -411,6 +415,8 @@ class EmailOptInListTest(ModuleStoreTestCase):
# Check data rows # Check data rows
for user, course_id, opt_in_pref in args: for user, course_id, opt_in_pref in args:
self.assertIn({ self.assertIn({
"user_id": str(user.id),
"username": user.username.encode('utf-8'),
"email": user.email.encode('utf-8'), "email": user.email.encode('utf-8'),
"full_name": ( "full_name": (
user.profile.name.encode('utf-8') 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