Merge lp:~veebers/ubuntu-community-testing/fixing-email-address-handling into lp:ubuntu-community-testing

Proposed by Christopher Lee
Status: Merged
Merged at revision: 26
Proposed branch: lp:~veebers/ubuntu-community-testing/fixing-email-address-handling
Merge into: lp:ubuntu-community-testing
Diff against target: 53 lines (+12/-13)
2 files modified
tools/upload_results.py (+2/-1)
ubuntu_pt_community/api/v1.py (+10/-12)
To merge this branch: bzr merge lp:~veebers/ubuntu-community-testing/fixing-email-address-handling
Reviewer Review Type Date Requested Status
Ubuntu Testcase Admins Pending
Review via email: mp+268281@code.launchpad.net

Commit message

Add email address handling

Description of the change

This got lost along the way somewhere, adding email address details.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tools/upload_results.py'
--- tools/upload_results.py 2015-08-14 04:45:18 +0000
+++ tools/upload_results.py 2015-08-18 00:48:36 +0000
@@ -150,10 +150,11 @@
150 print('ERROR: Invalid credentials')150 print('ERROR: Invalid credentials')
151151
152 headers = get_oauth_signed_request(url, oauth_creds)152 headers = get_oauth_signed_request(url, oauth_creds)
153 form_data = dict(uploader_email=email)
153154
154 print('Uploading file to service.')155 print('Uploading file to service.')
155 with open(file_path, 'rb') as f:156 with open(file_path, 'rb') as f:
156 upload_data = dict(data=f)157 upload_data = dict(data=f)
157 # Right, now we can post the details.158 # Right, now we can post the details.
158 requests.post(url, files=upload_data, headers=headers)159 requests.post(url, files=upload_data, data=form_data, headers=headers)
159 print('Upload succeeded')160 print('Upload succeeded')
160161
=== modified file 'ubuntu_pt_community/api/v1.py'
--- ubuntu_pt_community/api/v1.py 2015-08-17 10:00:50 +0000
+++ ubuntu_pt_community/api/v1.py 2015-08-18 00:48:36 +0000
@@ -70,15 +70,10 @@
7070
7171
72def store_upload_details(request, json_data):72def store_upload_details(request, json_data):
73 user_details = get_user_details_from_header(request)73 # If email address is None, should we continue to store the data?
7474 email_address = get_user_email_address(request)
75 try:75 if email_address is None:
76 email_address = user_details['email']76 logger.warning('Storing results against no email address.')
77 except KeyError:
78 logger.error(
79 'Attempted to store details for results with no user details'
80 )
81 return
8277
83 details = dict(78 details = dict(
84 user_email=email_address,79 user_email=email_address,
@@ -110,6 +105,9 @@
110 return db.get_collection(database_name, collection_name)105 return db.get_collection(database_name, collection_name)
111106
112107
113def get_user_details_from_header(request):108def get_user_email_address(request):
114 # STUB109 try:
115 return dict(email='another@email.com')110 return request.form['uploader_email']
111 except KeyError:
112 logger.error('Unable to extract email address from header.')
113 return None

Subscribers

People subscribed via source and target branches