Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/notifications/web/notification.py

Issue 29327106: Issue 3048 - Mark inactive notifications instead of removing them (Closed)
Left Patch Set: Created Sept. 10, 2015, 11:16 a.m.
Right Patch Set: Simplify range selection and inactive check Created Sept. 11, 2015, 7:03 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/notifications/test/parser.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "version": _generate_version(groups), 95 "version": _generate_version(groups),
96 "notifications": _get_notifications_to_send(notifications, groups) 96 "notifications": _get_notifications_to_send(notifications, groups)
97 } 97 }
98 98
99 @url_handler("/notification.json") 99 @url_handler("/notification.json")
100 def notification(environ, start_response): 100 def notification(environ, start_response):
101 params = urlparse.parse_qs(environ.get("QUERY_STRING", "")) 101 params = urlparse.parse_qs(environ.get("QUERY_STRING", ""))
102 version = params.get("lastVersion", [""])[0] 102 version = params.get("lastVersion", [""])[0]
103 notifications = load_notifications() 103 notifications = load_notifications()
104 groups = _determine_groups(version, notifications) 104 groups = _determine_groups(version, notifications)
105 notifications = [x for x in notifications 105 notifications = [x for x in notifications if not x.get("inactive", False)]
106 if not ("inactive" in x and x["inactive"])]
107 if not groups: 106 if not groups:
108 groups = _assign_groups(notifications) 107 groups = _assign_groups(notifications)
109 response = _create_response(notifications, groups) 108 response = _create_response(notifications, groups)
110 response_headers = [("Content-Type", "application/json; charset=utf-8"), 109 response_headers = [("Content-Type", "application/json; charset=utf-8"),
111 ("ABP-Notification-Version", response["version"])] 110 ("ABP-Notification-Version", response["version"])]
112 response_body = json.dumps(response, ensure_ascii=False, indent=2, 111 response_body = json.dumps(response, ensure_ascii=False, indent=2,
113 separators=(",", ": "), 112 separators=(",", ": "),
114 sort_keys=True).encode("utf-8") 113 sort_keys=True).encode("utf-8")
115 start_response("200 OK", response_headers) 114 start_response("200 OK", response_headers)
116 return response_body 115 return response_body
LEFTRIGHT

Powered by Google App Engine
This is Rietveld