|
6 | 6 | from friend.controllers import friend_invitation_by_email_send_for_api, friend_invitation_by_email_verify_for_api, \ |
7 | 7 | friend_invitation_by_we_vote_id_send_for_api, friend_invite_response_for_api, friend_list_for_api, \ |
8 | 8 | friend_lists_all_for_api, friend_invitation_by_facebook_send_for_api, \ |
9 | | - friend_invitation_by_facebook_verify_for_api, friend_invitation_information_for_api |
| 9 | + friend_invitation_by_facebook_verify_for_api, friend_invitation_information_for_api, message_to_friend_send_for_api |
10 | 10 | from friend.models import ACCEPT_INVITATION, CURRENT_FRIENDS, DELETE_INVITATION_EMAIL_SENT_BY_ME, \ |
11 | 11 | DELETE_INVITATION_VOTER_SENT_BY_ME, \ |
12 | 12 | FRIENDS_IN_COMMON, FRIEND_INVITATIONS_PROCESSED, FRIEND_INVITATIONS_SENT_TO_ME, FRIEND_INVITATIONS_SENT_BY_ME, \ |
13 | 13 | FRIEND_INVITATIONS_WAITING_FOR_VERIFICATION, \ |
14 | 14 | IGNORED_FRIEND_INVITATIONS, IGNORE_INVITATION, IGNORE_SUGGESTION, \ |
15 | 15 | SUGGESTED_FRIEND_LIST, UNFRIEND_CURRENT_FRIEND |
16 | 16 | import json |
17 | | -import wevote_functions.admin |
18 | | -from wevote_functions.functions import get_voter_device_id |
| 17 | +from wevote_functions.functions import get_voter_device_id, positive_value_exists, wevote_functions |
19 | 18 |
|
20 | 19 |
|
21 | 20 | logger = wevote_functions.admin.get_logger(__name__) |
@@ -249,3 +248,30 @@ def friend_lists_all_view(request): # friendList |
249 | 248 | 'suggested_friends': results['suggested_friends'], |
250 | 249 | } |
251 | 250 | return HttpResponse(json.dumps(json_data), content_type='application/json') |
| 251 | + |
| 252 | + |
| 253 | +def message_to_friend_send_view(request): # messageToFriendSend |
| 254 | + """ |
| 255 | +
|
| 256 | + :param request: |
| 257 | + :return: |
| 258 | + """ |
| 259 | + voter_device_id = get_voter_device_id(request) # We standardize how we take in the voter_device_id |
| 260 | + election_date_in_future_formatted = request.GET.get('election_date_in_future_formatted', "") |
| 261 | + election_date_is_today = positive_value_exists(request.GET.get('election_date_is_today', False)) |
| 262 | + message_to_friend = request.GET.get('message_to_friend', "") |
| 263 | + other_voter_we_vote_id = request.GET.get('other_voter_we_vote_id', "") |
| 264 | + hostname = request.GET.get('hostname', "") |
| 265 | + results = message_to_friend_send_for_api( |
| 266 | + election_date_in_future_formatted=election_date_in_future_formatted, |
| 267 | + election_date_is_today=election_date_is_today, |
| 268 | + other_voter_we_vote_id=other_voter_we_vote_id, |
| 269 | + message_to_friend=message_to_friend, |
| 270 | + voter_device_id=voter_device_id, |
| 271 | + web_app_root_url=hostname) |
| 272 | + json_data = { |
| 273 | + 'status': results['status'], |
| 274 | + 'success': results['success'], |
| 275 | + 'voter_device_id': voter_device_id, |
| 276 | + } |
| 277 | + return HttpResponse(json.dumps(json_data), content_type='application/json') |
0 commit comments