Make patch creation a separate workflow
authorMagnus Hagander <magnus@hagander.net>
Fri, 19 Jul 2013 14:40:20 +0000 (16:40 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 19 Jul 2013 14:40:20 +0000 (16:40 +0200)
pgcommitfest/commitfest/forms.py
pgcommitfest/commitfest/templates/commitfest.html
pgcommitfest/commitfest/templates/patch_commands.inc
pgcommitfest/commitfest/views.py
pgcommitfest/urls.py

index af3bd459c212405392cde64f2756bc667b40bb09..9838ce610a39e7992fbbeb4becf71b6fb3ea78c2 100644 (file)
@@ -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)
index db76225df2f659698ee89b88b10912ccac91ffb9..dc34653771ed255205dc7871e3cf587192717c14 100644 (file)
@@ -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%}
index 4b458df7d783c1f9e17c0fad293023dc2aeea6c4..abcbffedd705db8add2a3eb8a957ab3c91da3280 100644 (file)
@@ -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>
 
index e7795b39f5e07f8c3d052a19e263232c5539e65b..95ac285db67295545fba949883a8f439d94adc81 100644 (file)
@@ -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
+@transaction.commit_on_success
+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:
index 3be957a38d2d6ee7d076319b68767fd6b1db6655..106aeb13bbc90ce07b38a762cb2e250b43160084 100644 (file)
@@ -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'),