| 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 129 matching lines...) Show 10 above Show 10 below | |
| 140 data = forms.FileField(required=False) | 140 data = forms.FileField(required=False) |
| 141 url = forms.URLField(required=False, | 141 url = forms.URLField(required=False, |
| 142 max_length=2083, | 142 max_length=2083, |
| 143 widget=forms.TextInput(attrs={'size': 60})) | 143 widget=forms.TextInput(attrs={'size': 60})) |
| 144 | 144 |
| 145 | 145 |
| 146 class UploadForm(forms.Form): | 146 class UploadForm(forms.Form): |
| 147 | 147 |
| 148 subject = forms.CharField(max_length=100) | 148 subject = forms.CharField(max_length=100) |
| 149 description = forms.CharField(max_length=10000, required=False) | 149 description = forms.CharField(max_length=10000, required=False) |
| 150 base = forms.CharField(max_length=2000) | 150 base = forms.CharField(max_length=2000, required=False) |
| 151 data = forms.FileField() | 151 data = forms.FileField() |
| 152 issue = forms.IntegerField(required=False) | 152 issue = forms.IntegerField(required=False) |
| 153 | 153 |
| 154 def get_base(self): | 154 def get_base(self): |
| 155 return self.cleaned_data.get('base') | 155 return self.cleaned_data.get('base') |
| 156 | 156 |
| 157 | |
|
GvR
2008/05/19 02:10:58
Please don't delete double blank lines. They're t
| |
| 158 class EditForm(IssueBaseForm): | 157 class EditForm(IssueBaseForm): |
| 159 | 158 |
| 160 closed = forms.BooleanField() | 159 closed = forms.BooleanField() |
| 161 | 160 |
| 162 | 161 |
| 163 class RepoForm(djangoforms.ModelForm): | 162 class RepoForm(djangoforms.ModelForm): |
| 164 | 163 |
| 165 class Meta: | 164 class Meta: |
| 166 model = models.Repository | 165 model = models.Repository |
| 167 exclude = ['owner'] | 166 exclude = ['owner'] |
| (...skipping 578 matching lines...) Show 10 above Show 10 below | |
| 746 _add_next_prev(patchset, patch) | 745 _add_next_prev(patchset, patch) |
| 747 return respond(request, 'patch.html', | 746 return respond(request, 'patch.html', |
| 748 {'patch': patch, | 747 {'patch': patch, |
| 749 'patchset': patchset, | 748 'patchset': patchset, |
| 750 'issue': request.issue}) | 749 'issue': request.issue}) |
| 751 | 750 |
| 752 | 751 |
| 753 @issue_required | 752 @issue_required |
| 754 def diff(request, patchset_id, patch_id): | 753 def diff(request, patchset_id, patch_id): |
| 755 """/<issue>/diff/<patchset>/<patch> - View a patch as a side-by-side diff.""" | 754 """/<issue>/diff/<patchset>/<patch> - View a patch as a side-by-side diff.""" |
| 755 | |
| 756 if not request.issue.base: | |
| 757 return HttpResponse('<html><body>side-by-side diff is not supported for ' | |
| 758 'this patch (yet).</body></html>') | |
| 759 | |
| 756 patchset = models.PatchSet.get_by_id(int(patchset_id), parent=request.issue) | 760 patchset = models.PatchSet.get_by_id(int(patchset_id), parent=request.issue) |
| 757 if patchset is None: | 761 if patchset is None: |
| 758 return HttpResponseNotFound('No patch set exists with that id (%s)' % | 762 return HttpResponseNotFound('No patch set exists with that id (%s)' % |
| 759 patchset_id) | 763 patchset_id) |
| 760 patchset.issue = request.issue | 764 patchset.issue = request.issue |
| 761 patch = models.Patch.get_by_id(int(patch_id), parent=patchset) | 765 patch = models.Patch.get_by_id(int(patch_id), parent=patchset) |
| 762 if patch is None: | 766 if patch is None: |
| 763 return HttpResponseNotFound('No patch exists with that id (%s/%s)' % | 767 return HttpResponseNotFound('No patch exists with that id (%s/%s)' % |
| 764 (patchset_id, patch_id)) | 768 (patchset_id, patch_id)) |
| 765 patch.patchset = patchset | 769 patch.patchset = patchset |
| (...skipping 500 matching lines...) Show 10 above Show 10 below | |
| 1266 else: | 1270 else: |
| 1267 accounts = models.Account.get_accounts_for_nickname(nickname) | 1271 accounts = models.Account.get_accounts_for_nickname(nickname) |
| 1268 if nickname != account.nickname and accounts: | 1272 if nickname != account.nickname and accounts: |
| 1269 form.errors['nickname'] = ['This nickname is already in use.'] | 1273 form.errors['nickname'] = ['This nickname is already in use.'] |
| 1270 else: | 1274 else: |
| 1271 account.nickname = nickname | 1275 account.nickname = nickname |
| 1272 account.put() | 1276 account.put() |
| 1273 if not form.is_valid(): | 1277 if not form.is_valid(): |
| 1274 return respond(request, 'settings.html', {'form': form}) | 1278 return respond(request, 'settings.html', {'form': form}) |
| 1275 return HttpResponseRedirect('/settings') | 1279 return HttpResponseRedirect('/settings') |
| OLD | NEW |