| OLD | NEW |
| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 class UploadForm(forms.Form): | 169 class UploadForm(forms.Form): |
| 170 | 170 |
| 171 subject = forms.CharField(max_length=MAX_SUBJECT) | 171 subject = forms.CharField(max_length=MAX_SUBJECT) |
| 172 description = forms.CharField(max_length=MAX_DESCRIPTION, required=False) | 172 description = forms.CharField(max_length=MAX_DESCRIPTION, required=False) |
| 173 project = forms.CharField(required=False) | 173 project = forms.CharField(required=False) |
| 174 content_upload = forms.BooleanField(required=False) | 174 content_upload = forms.BooleanField(required=False) |
| 175 separate_patches = forms.BooleanField(required=False) | 175 separate_patches = forms.BooleanField(required=False) |
| 176 base = forms.CharField(max_length=MAX_URL, required=False) | 176 base = forms.CharField(max_length=MAX_URL, required=False) |
| 177 target_ref = forms.CharField(max_length=MAX_URL, required=False) | 177 target_ref = forms.CharField(max_length=MAX_URL, required=False) |
| 178 cq_dry_run = forms.BooleanField(required=False) |
| 178 data = forms.FileField(required=False) | 179 data = forms.FileField(required=False) |
| 179 issue = forms.IntegerField(required=False) | 180 issue = forms.IntegerField(required=False) |
| 180 reviewers = forms.CharField(max_length=MAX_REVIEWERS, required=False) | 181 reviewers = forms.CharField(max_length=MAX_REVIEWERS, required=False) |
| 181 cc = forms.CharField(max_length=MAX_CC, required=False) | 182 cc = forms.CharField(max_length=MAX_CC, required=False) |
| 182 private = forms.BooleanField(required=False, initial=False) | 183 private = forms.BooleanField(required=False, initial=False) |
| 183 send_mail = forms.BooleanField(required=False) | 184 send_mail = forms.BooleanField(required=False) |
| 184 base_hashes = forms.CharField(required=False) | 185 base_hashes = forms.CharField(required=False) |
| 185 commit = forms.BooleanField(required=False) | 186 commit = forms.BooleanField(required=False) |
| 186 repo_guid = forms.CharField(required=False, max_length=MAX_URL) | 187 repo_guid = forms.CharField(required=False, max_length=MAX_URL) |
| 187 | 188 |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 | 1421 |
| 1421 base = form.get_base() | 1422 base = form.get_base() |
| 1422 if base is None: | 1423 if base is None: |
| 1423 return (None, None) | 1424 return (None, None) |
| 1424 | 1425 |
| 1425 first_issue_id, _ = models.Issue.allocate_ids(1) | 1426 first_issue_id, _ = models.Issue.allocate_ids(1) |
| 1426 issue_key = ndb.Key(models.Issue, first_issue_id) | 1427 issue_key = ndb.Key(models.Issue, first_issue_id) |
| 1427 | 1428 |
| 1428 project = form.cleaned_data['project'] | 1429 project = form.cleaned_data['project'] |
| 1429 target_ref = _get_target_ref(form, issue_key, project) | 1430 target_ref = _get_target_ref(form, issue_key, project) |
| 1431 cq_dry_run = form.cleaned_data.get('cq_dry_run', False) |
| 1432 cq_dry_run_triggered_by = account.email if cq_dry_run else '' |
| 1430 | 1433 |
| 1431 issue = models.Issue(subject=form.cleaned_data['subject'], | 1434 issue = models.Issue(subject=form.cleaned_data['subject'], |
| 1432 description=form.cleaned_data['description'], | 1435 description=form.cleaned_data['description'], |
| 1433 project=project, | 1436 project=project, |
| 1434 base=base, | 1437 base=base, |
| 1435 target_ref=target_ref, | 1438 target_ref=target_ref, |
| 1436 repo_guid=form.cleaned_data.get('repo_guid', None), | 1439 repo_guid=form.cleaned_data.get('repo_guid', None), |
| 1437 reviewers=reviewers, | 1440 reviewers=reviewers, |
| 1438 required_reviewers=required_reviewers, | 1441 required_reviewers=required_reviewers, |
| 1439 cc=cc, | 1442 cc=cc, |
| 1440 private=form.cleaned_data.get('private', False), | 1443 private=form.cleaned_data.get('private', False), |
| 1441 n_comments=0, | 1444 n_comments=0, |
| 1445 cq_dry_run=cq_dry_run, |
| 1446 cq_dry_run_last_triggered_by=cq_dry_run_triggered_by, |
| 1442 key=issue_key) | 1447 key=issue_key) |
| 1443 issue.put() | 1448 issue.put() |
| 1444 | 1449 |
| 1445 first_ps_id, _ = models.PatchSet.allocate_ids(1, parent=issue.key) | 1450 first_ps_id, _ = models.PatchSet.allocate_ids(1, parent=issue.key) |
| 1446 ps_key = ndb.Key(models.PatchSet, first_ps_id, parent=issue.key) | 1451 ps_key = ndb.Key(models.PatchSet, first_ps_id, parent=issue.key) |
| 1447 patchset = models.PatchSet( | 1452 patchset = models.PatchSet( |
| 1448 issue_key=issue.key, data=data, url=url, key=ps_key) | 1453 issue_key=issue.key, data=data, url=url, key=ps_key) |
| 1449 patchset.put() | 1454 patchset.put() |
| 1450 | 1455 |
| 1451 if not separate_patches: | 1456 if not separate_patches: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 if reviewer not in issue.required_reviewers] | 1571 if reviewer not in issue.required_reviewers] |
| 1567 emails, _ = _get_emails(form, 'cc') | 1572 emails, _ = _get_emails(form, 'cc') |
| 1568 if not form.is_valid(): | 1573 if not form.is_valid(): |
| 1569 return None | 1574 return None |
| 1570 issue.cc += [cc for cc in emails if cc not in issue.cc] | 1575 issue.cc += [cc for cc in emails if cc not in issue.cc] |
| 1571 else: | 1576 else: |
| 1572 issue.reviewers, issue.required_reviewers = _get_emails(form, 'reviewers') | 1577 issue.reviewers, issue.required_reviewers = _get_emails(form, 'reviewers') |
| 1573 issue.cc, _ = _get_emails(form, 'cc') | 1578 issue.cc, _ = _get_emails(form, 'cc') |
| 1574 issue.commit = False | 1579 issue.commit = False |
| 1575 issue.target_ref = _get_target_ref(form, issue.key, issue.project) | 1580 issue.target_ref = _get_target_ref(form, issue.key, issue.project) |
| 1581 issue.cq_dry_run = form.cleaned_data.get('cq_dry_run', False) |
| 1582 issue.cq_dry_run_last_triggered_by = account.email if issue.cq_dry_run else '' |
| 1576 issue.calculate_updates_for() | 1583 issue.calculate_updates_for() |
| 1577 # New patchset has been uploaded, add to the approvers_to_notify list. | 1584 # New patchset has been uploaded, add to the approvers_to_notify list. |
| 1578 approval_dict = json.loads(issue.reviewer_approval) | 1585 approval_dict = json.loads(issue.reviewer_approval) |
| 1579 if approval_dict: | 1586 if approval_dict: |
| 1580 for approver in approval_dict: | 1587 for approver in approval_dict: |
| 1581 if approval_dict[approver] and approver not in issue.approvers_to_notify: | 1588 if approval_dict[approver] and approver not in issue.approvers_to_notify: |
| 1582 issue.approvers_to_notify.append(approver) | 1589 issue.approvers_to_notify.append(approver) |
| 1583 issue.put() | 1590 issue.put() |
| 1584 # Log for auditing purposes. | 1591 # Log for auditing purposes. |
| 1585 logging.info("Patchset id %s for issue %s has target_ref %s", | 1592 logging.info("Patchset id %s for issue %s has target_ref %s", |
| (...skipping 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5390 return HttpResponseNotFound() | 5397 return HttpResponseNotFound() |
| 5391 tops = [] | 5398 tops = [] |
| 5392 shame = [] | 5399 shame = [] |
| 5393 for i in data: | 5400 for i in data: |
| 5394 if i.score == models.AccountStatsBase.NULL_SCORE: | 5401 if i.score == models.AccountStatsBase.NULL_SCORE: |
| 5395 shame.append(i) | 5402 shame.append(i) |
| 5396 else: | 5403 else: |
| 5397 tops.append(i) | 5404 tops.append(i) |
| 5398 return respond( | 5405 return respond( |
| 5399 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when}) | 5406 request, 'leaderboard.html', {'tops': tops, 'shame': shame, 'when': when}) |
| OLD | NEW |