summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2013-07-19 14:40:20 +0000
committerMagnus Hagander2013-07-19 14:40:20 +0000
commit59701ea9ee7333a062e8684b4d25b00f31225643 (patch)
tree86a359c99b8b728b9de00243bbf16a72bb48288b
parent520992c4ab012ee26f4f302b7cc15331e61746ba (diff)
Make patch creation a separate workflow
-rw-r--r--pgcommitfest/commitfest/forms.py9
-rw-r--r--pgcommitfest/commitfest/templates/commitfest.html2
-rw-r--r--pgcommitfest/commitfest/templates/patch_commands.inc2
-rw-r--r--pgcommitfest/commitfest/views.py46
-rw-r--r--pgcommitfest/urls.py3
5 files changed, 38 insertions, 24 deletions
diff --git a/pgcommitfest/commitfest/forms.py b/pgcommitfest/commitfest/forms.py
index af3bd45..9838ce6 100644
--- a/pgcommitfest/commitfest/forms.py
+++ b/pgcommitfest/commitfest/forms.py
@@ -5,6 +5,7 @@ from selectable.forms.widgets import AutoCompleteSelectMultipleWidget
from models import Patch, MailThread
from lookups import UserLookup
+from widgets import ThreadPickWidget
from ajax import _archivesAPI
class PatchForm(forms.ModelForm):
@@ -23,6 +24,14 @@ class PatchForm(forms.ModelForm):
self.fields['committer'].label_from_instance = lambda x: '%s %s (%s)' % (x.user.first_name, x.user.last_name, x.user.username)
+class NewPatchForm(forms.ModelForm):
+ threadmsgid = forms.CharField(max_length=200, required=True, label='Specify thread msgid', widget=ThreadPickWidget)
+ patchfile = forms.FileField(allow_empty_file=False, max_length=50000, label='or upload patch file', required=False, help_text='This may be supported sometime in the future, and would then autogenerate a mail to the hackers list. At such a time, the threadmsgid would no longer be required.')
+
+ class Meta:
+ model = Patch
+ exclude = ('commitfests', 'mailthreads', 'modified', 'authors', 'reviewers', 'committer', 'wikilink', 'gitlink', )
+
def _fetch_thread_choices(patch):
for mt in patch.mailthread_set.order_by('-latestmessage'):
ti = sorted(_archivesAPI('/message-id.json/%s' % mt.messageid), key=lambda x: x['date'], reverse=True)
diff --git a/pgcommitfest/commitfest/templates/commitfest.html b/pgcommitfest/commitfest/templates/commitfest.html
index db76225..dc34653 100644
--- a/pgcommitfest/commitfest/templates/commitfest.html
+++ b/pgcommitfest/commitfest/templates/commitfest.html
@@ -40,6 +40,6 @@ This is commitfest {{cf}}.
</table>
<p>
-<a class="btn" href="new/edit/">New patch</a>
+<a class="btn" href="new/">New patch</a>
</p>
{%endblock%}
diff --git a/pgcommitfest/commitfest/templates/patch_commands.inc b/pgcommitfest/commitfest/templates/patch_commands.inc
index 4b458df..abcbffe 100644
--- a/pgcommitfest/commitfest/templates/patch_commands.inc
+++ b/pgcommitfest/commitfest/templates/patch_commands.inc
@@ -23,7 +23,7 @@
<ul class="dropdown-menu">
<li><a href="close/reject/" onclick="return verify_reject()">Rejected</a></li>
<li><a href="close/feedback/" onclick="return verify_returned()">Returned with feedback</a></li>
- <li><a href="close/committed/" onclick="return verify_committed()">Committed</a></li>
+ <li><a href="close/committed/" onclick="return verify_committed({{is_committer|yesno:"true,false"}}))">Committed</a></li>
</ul>
</div>
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py
index e7795b3..95ac285 100644
--- a/pgcommitfest/commitfest/views.py
+++ b/pgcommitfest/commitfest/views.py
@@ -12,7 +12,7 @@ from email.utils import formatdate, make_msgid
from mailqueue.util import send_mail
from models import CommitFest, Patch, PatchOnCommitFest, PatchHistory, Committer
-from forms import PatchForm, CommentForm
+from forms import PatchForm, NewPatchForm, CommentForm
def home(request):
commitfests = CommitFest.objects.all()
@@ -66,12 +66,7 @@ def patch(request, cfid, patchid):
@transaction.commit_on_success
def patchform(request, cfid, patchid):
cf = get_object_or_404(CommitFest, pk=cfid)
-
- if patchid == 'new':
- patch = Patch()
- else:
- #XXX: also filter that it exists on this cf!
- patch = get_object_or_404(Patch, pk=patchid)
+ patch = get_object_or_404(Patch, pk=patchid, commitfests=cf)
if request.method == 'POST':
form = PatchForm(data=request.POST, instance=patch)
@@ -82,30 +77,39 @@ def patchform(request, cfid, patchid):
r.set_modified()
r.save()
- if patchid == 'new':
- poc = PatchOnCommitFest(patch=r, commitfest=cf, enterdate=datetime.today())
- poc.save()
form.save_m2m()
return HttpResponseRedirect('../../%s/' % r.pk)
# Else fall through and render the page again
else:
form = PatchForm(instance=patch)
- if patchid=='new':
- title = 'New patch'
- breadcrumbs = [{'title': cf.name, 'href': '/%s/' % cf.pk},]
- else:
- title = 'Edit patch'
- breadcrumbs = [{'title': cf.name, 'href': '/%s/' % cf.pk},
- {'title': 'View patch', 'href': '/%s/%s/' % (cf.pk, patch.pk)}]
-
return render_to_response('base_form.html', {
'cf': cf,
'form': form,
'patch': patch,
- 'title': title,
- 'breadcrumbs': breadcrumbs,
- }, context_instance=RequestContext(request))
+ 'title': 'Edit patch',
+ 'breadcrumbs': [{'title': cf.name, 'href': '/%s/' % cf.pk},
+ {'title': 'View patch', 'href': '/%s/%s/' % (cf.pk, patch.pk)}],
+ }, context_instance=RequestContext(request))
+
+@login_required
+def newpatch(request, cfid):
+ cf = get_object_or_404(CommitFest, pk=cfid)
+ if request.method == 'POST':
+ form = NewPatchForm(data=request.POST)
+ if form.is_valid():
+ raise Exception("Do something")
+ else:
+ form = NewPatchForm()
+
+ return render_to_response('base_form.html', {
+ 'form': form,
+ 'title': 'New patch',
+ 'breadcrumbs': [{'title': cf.name, 'href': '/%s/' % cf.pk},],
+ 'savebutton': 'Create patch',
+ 'threadbrowse': True,
+ }, context_instance=RequestContext(request))
def _review_status_string(reviewstatus):
if '0' in reviewstatus:
diff --git a/pgcommitfest/urls.py b/pgcommitfest/urls.py
index 3be957a..106aeb1 100644
--- a/pgcommitfest/urls.py
+++ b/pgcommitfest/urls.py
@@ -9,7 +9,8 @@ urlpatterns = patterns('',
url(r'^$', 'commitfest.views.home'),
url(r'^(\d+)/$', 'commitfest.views.commitfest'),
url(r'^(\d+)/(\d+)/$', 'commitfest.views.patch'),
- url(r'^(\d+)/(\d+|new)/edit/$', 'commitfest.views.patchform'),
+ url(r'^(\d+)/(\d+)/edit/$', 'commitfest.views.patchform'),
+ url(r'^(\d+)/new/$', 'commitfest.views.newpatch'),
url(r'^(\d+)/(\d+)/status/(review|author|committer)/$', 'commitfest.views.status'),
url(r'^(\d+)/(\d+)/close/(reject|feedback|committed)/$', 'commitfest.views.close'),
url(r'^(\d+)/(\d+)/reviewer/(become|remove)/$', 'commitfest.views.reviewer'),