Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: appengine/chromium_rietveld/codereview/views.py

Issue 806373005: Allow target_ref to be modified by subsequent patchsets with logging (Closed) Base URL: https://chromium.googlesource.com/infra/infra@master
Patch Set: Cleanup II Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2008 Google Inc. 1 # Copyright 2008 Google Inc.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 if request.POST.get('send_mail') == 'yes' or request.POST.get('message'): 1329 if request.POST.get('send_mail') == 'yes' or request.POST.get('message'):
1330 msg = make_message(request, request.issue, request.POST.get('message', ''), 1330 msg = make_message(request, request.issue, request.POST.get('message', ''),
1331 send_mail=(request.POST.get('send_mail', '') == 'yes')) 1331 send_mail=(request.POST.get('send_mail', '') == 'yes'))
1332 request.issue.put() 1332 request.issue.put()
1333 msg.put() 1333 msg.put()
1334 notify_xmpp.notify_issue(request, request.issue, 'Mailed') 1334 notify_xmpp.notify_issue(request, request.issue, 'Mailed')
1335 1335
1336 return HttpTextResponse('OK') 1336 return HttpTextResponse('OK')
1337 1337
1338 1338
1339 def _get_target_ref(form, issue_key, project):
1340 target_ref = form.cleaned_data.get('target_ref', None)
1341 # The following is a hack to ensure that all target_refs for chromium and v8
1342 # start with 'refs/pending/'. More context here:
1343 # https://code.google.com/p/chromium/issues/detail?id=435702#c10
1344 # TODO(rmistry): Remove the below hack when the logged warning stops showing
1345 # up.
1346 if (target_ref and not target_ref.startswith('refs/pending/') and
1347 project in ('chromium', 'v8')):
1348 target_ref = target_ref.replace('refs/', 'refs/pending/')
1349 logging.warn('Issue %d for %s did not start with refs/pending/',
agable 2014/12/19 17:52:56 nit: "Target ref %s for issue %d in project %s did
1350 issue_key.id(), project)
1351 return target_ref
1352
1353
1339 def _make_new(request, form): 1354 def _make_new(request, form):
1340 """Creates new issue and fill relevant fields from given form data. 1355 """Creates new issue and fill relevant fields from given form data.
1341 1356
1342 Sends notification about created issue (if requested with send_mail param). 1357 Sends notification about created issue (if requested with send_mail param).
1343 1358
1344 Returns (Issue, PatchSet) or (None, None). 1359 Returns (Issue, PatchSet) or (None, None).
1345 """ 1360 """
1346 if not form.is_valid(): 1361 if not form.is_valid():
1347 return (None, None) 1362 return (None, None)
1348 account = models.Account.get_account_for_user(request.user) 1363 account = models.Account.get_account_for_user(request.user)
(...skipping 15 matching lines...) Expand all
1364 return (None, None) 1379 return (None, None)
1365 1380
1366 base = form.get_base() 1381 base = form.get_base()
1367 if base is None: 1382 if base is None:
1368 return (None, None) 1383 return (None, None)
1369 1384
1370 first_issue_id, _ = models.Issue.allocate_ids(1) 1385 first_issue_id, _ = models.Issue.allocate_ids(1)
1371 issue_key = ndb.Key(models.Issue, first_issue_id) 1386 issue_key = ndb.Key(models.Issue, first_issue_id)
1372 1387
1373 project = form.cleaned_data['project'] 1388 project = form.cleaned_data['project']
1374 target_ref = form.cleaned_data.get('target_ref', None) 1389 target_ref = _get_target_ref(form, issue_key, project)
1375 # The following is a hack to ensure that all target_refs for chromium and v8
1376 # start with 'refs/pending/'. More context here:
1377 # https://code.google.com/p/chromium/issues/detail?id=435702#c10
1378 # TODO(rmistry): Remove the below hack when the logged warning stops showing
1379 # up.
1380 if (target_ref and not target_ref.startswith('refs/pending/') and
1381 project in ('chromium', 'v8')):
1382 target_ref = target_ref.replace('refs/', 'refs/pending/')
1383 logging.warn('Issue %d for %s did not start with refs/pending/',
1384 issue_key.id(), project)
1385 1390
1386 issue = models.Issue(subject=form.cleaned_data['subject'], 1391 issue = models.Issue(subject=form.cleaned_data['subject'],
1387 description=form.cleaned_data['description'], 1392 description=form.cleaned_data['description'],
1388 project=project, 1393 project=project,
1389 base=base, 1394 base=base,
1390 target_ref=target_ref, 1395 target_ref=target_ref,
1391 repo_guid=form.cleaned_data.get('repo_guid', None), 1396 repo_guid=form.cleaned_data.get('repo_guid', None),
1392 reviewers=reviewers, 1397 reviewers=reviewers,
1393 required_reviewers=required_reviewers, 1398 required_reviewers=required_reviewers,
1394 cc=cc, 1399 cc=cc,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 issue.required_reviewers += [reviewer for reviewer in required_reviewers 1525 issue.required_reviewers += [reviewer for reviewer in required_reviewers
1521 if reviewer not in issue.required_reviewers] 1526 if reviewer not in issue.required_reviewers]
1522 emails, _ = _get_emails(form, 'cc') 1527 emails, _ = _get_emails(form, 'cc')
1523 if not form.is_valid(): 1528 if not form.is_valid():
1524 return None 1529 return None
1525 issue.cc += [cc for cc in emails if cc not in issue.cc] 1530 issue.cc += [cc for cc in emails if cc not in issue.cc]
1526 else: 1531 else:
1527 issue.reviewers, issue.required_reviewers = _get_emails(form, 'reviewers') 1532 issue.reviewers, issue.required_reviewers = _get_emails(form, 'reviewers')
1528 issue.cc, _ = _get_emails(form, 'cc') 1533 issue.cc, _ = _get_emails(form, 'cc')
1529 issue.commit = False 1534 issue.commit = False
1535 issue.target_ref = _get_target_ref(form, issue.key, issue.project)
1530 issue.calculate_updates_for() 1536 issue.calculate_updates_for()
1531 issue.put() 1537 issue.put()
1538 # Log for auditing purposes.
1539 logging.info("Patchset id %s for issue %s has target_ref %s",
1540 patchset.key.id(), issue.key.id(), issue.target_ref)
1532 1541
1533 if form.cleaned_data.get('send_mail'): 1542 if form.cleaned_data.get('send_mail'):
1534 msg = make_message(request, issue, message, '', True) 1543 msg = make_message(request, issue, message, '', True)
1535 issue.put() 1544 issue.put()
1536 msg.put() 1545 msg.put()
1537 notify_xmpp.notify_issue(request, issue, 'Updated') 1546 notify_xmpp.notify_issue(request, issue, 'Updated')
1538 return patchset 1547 return patchset
1539 1548
1540 def _get_emails(form, label): 1549 def _get_emails(form, label):
1541 """Returns (reviewers, required_reviewers) or (None, None) for error.""" 1550 """Returns (reviewers, required_reviewers) or (None, None) for error."""
(...skipping 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after
5189 return HttpResponseNotFound() 5198 return HttpResponseNotFound()
5190 tops = [] 5199 tops = []
5191 shame = [] 5200 shame = []
5192 for i in data: 5201 for i in data:
5193 if i.score == models.AccountStatsBase.NULL_SCORE: 5202 if i.score == models.AccountStatsBase.NULL_SCORE:
5194 shame.append(i) 5203 shame.append(i)
5195 else: 5204 else:
5196 tops.append(i) 5205 tops.append(i)
5197 return respond( 5206 return respond(
5198 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when}) 5207 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when})
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698