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
1=== modified file 'tools/upload_results.py'
2--- tools/upload_results.py 2015-08-14 04:45:18 +0000
3+++ tools/upload_results.py 2015-08-18 00:48:36 +0000
4@@ -150,10 +150,11 @@
5 print('ERROR: Invalid credentials')
6
7 headers = get_oauth_signed_request(url, oauth_creds)
8+ form_data = dict(uploader_email=email)
9
10 print('Uploading file to service.')
11 with open(file_path, 'rb') as f:
12 upload_data = dict(data=f)
13 # Right, now we can post the details.
14- requests.post(url, files=upload_data, headers=headers)
15+ requests.post(url, files=upload_data, data=form_data, headers=headers)
16 print('Upload succeeded')
17
18=== modified file 'ubuntu_pt_community/api/v1.py'
19--- ubuntu_pt_community/api/v1.py 2015-08-17 10:00:50 +0000
20+++ ubuntu_pt_community/api/v1.py 2015-08-18 00:48:36 +0000
21@@ -70,15 +70,10 @@
22
23
24 def store_upload_details(request, json_data):
25- user_details = get_user_details_from_header(request)
26-
27- try:
28- email_address = user_details['email']
29- except KeyError:
30- logger.error(
31- 'Attempted to store details for results with no user details'
32- )
33- return
34+ # If email address is None, should we continue to store the data?
35+ email_address = get_user_email_address(request)
36+ if email_address is None:
37+ logger.warning('Storing results against no email address.')
38
39 details = dict(
40 user_email=email_address,
41@@ -110,6 +105,9 @@
42 return db.get_collection(database_name, collection_name)
43
44
45-def get_user_details_from_header(request):
46- # STUB
47- return dict(email='another@email.com')
48+def get_user_email_address(request):
49+ try:
50+ return request.form['uploader_email']
51+ except KeyError:
52+ logger.error('Unable to extract email address from header.')
53+ return None

Subscribers

People subscribed via source and target branches