Skip to content

Default author to self when adding a new patch #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pgcommitfest/commitfest/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ def __init__(self, *args, **kwargs):
self.fields[field].label_from_instance = lambda u: '{} ({})'.format(u.username, u.get_full_name())


class NewPatchForm(forms.ModelForm):
class NewPatchForm(PatchForm):
# Put threadmsgid first
field_order = ['threadmsgid']

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
fields = ('name', 'topic', )
def __init__(self, *args, **kwargs):
request = kwargs.pop('request', None)
super(NewPatchForm, self).__init__(*args, **kwargs)

if request:
self.fields['authors'].queryset = User.objects.filter(pk=request.user.id)
self.fields['authors'].initial = [request.user.id]

def clean_threadmsgid(self):
try:
Expand Down
5 changes: 3 additions & 2 deletions pgcommitfest/commitfest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def newpatch(request, cfid):
# Now add the thread
try:
doAttachThread(cf, patch, form.cleaned_data['threadmsgid'], request.user)
return HttpResponseRedirect("/patch/%s/edit/" % (patch.id,))
return HttpResponseRedirect("/patch/%s/" % (patch.id,))
except Http404:
# Thread not found!
# This is a horrible breakage of API layers
Expand All @@ -451,13 +451,14 @@ def newpatch(request, cfid):
# not happen very often. If we successfully attached to it, we will have already returned.
patch.delete()
else:
form = NewPatchForm()
form = NewPatchForm(request=request)

return render(request, 'base_form.html', {
'form': form,
'title': 'New patch',
'breadcrumbs': [{'title': cf.title, 'href': '/%s/' % cf.pk}, ],
'savebutton': 'Create patch',
'selectize_multiple_fields': form.selectize_multiple_fields.items(),
'threadbrowse': True,
})

Expand Down