Skip to content

Commit a2af7cf

Browse files
committed
Removed BaseNomcomForm and the notion of custom fieldsets
- Legacy-Id: 10608
1 parent ebb6884 commit a2af7cf

2 files changed

Lines changed: 12 additions & 94 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,10 @@ def clean(self, value):
8888
return result
8989

9090

91-
class BaseNomcomForm(object):
92-
def __unicode__(self):
93-
return self.as_div()
94-
95-
def as_div(self):
96-
return render_to_string('nomcom/nomcomform.html', {'form': self})
97-
98-
def get_fieldsets(self):
99-
if not self.fieldsets:
100-
yield dict(name=None, fields=self)
101-
else:
102-
for fieldset, fields in self.fieldsets:
103-
fieldset_dict = dict(name=fieldset, fields=[])
104-
for field_name in fields:
105-
if field_name in self.fields:
106-
fieldset_dict['fields'].append(self[field_name])
107-
if not fieldset_dict['fields']:
108-
# if there is no fields in this fieldset, we continue to next fieldset
109-
continue
110-
yield fieldset_dict
111-
112-
class EditMembersForm(BaseNomcomForm, forms.Form):
91+
class EditMembersForm(forms.Form):
11392

11493
members = MultiEmailField(label="Members email", required=False, widget=forms.Textarea)
11594

116-
fieldsets = [('Members', ('members',))]
117-
118-
11995
class EditMembersFormPreview(FormPreview):
12096
form_template = 'nomcom/edit_members.html'
12197
preview_template = 'nomcom/edit_members_preview.html'
@@ -212,10 +188,8 @@ def done(self, request, cleaned_data):
212188
return redirect('nomcom_edit_members', year=self.year)
213189

214190

215-
class EditNomcomForm(BaseNomcomForm, forms.ModelForm):
191+
class EditNomcomForm(forms.ModelForm):
216192

217-
fieldsets = [('Edit nomcom settings', ('public_key', 'initial_text',
218-
'send_questionnaire', 'reminder_interval'))]
219193

220194
def __init__(self, *args, **kwargs):
221195
super(EditNomcomForm, self).__init__(*args, **kwargs)
@@ -242,15 +216,13 @@ def clean_public_key(self):
242216
raise forms.ValidationError('Invalid public key. Error was: %s' % error)
243217

244218

245-
class MergeForm(BaseNomcomForm, forms.Form):
219+
class MergeForm(forms.Form):
246220

247221
secondary_emails = MultiEmailField(label="Secondary email addresses",
248222
help_text="Provide a comma separated list of email addresses. Nominations already received with any of these email address will be moved to show under the primary address.", widget=forms.Textarea)
249223
primary_email = forms.EmailField(label="Primary email address",
250224
widget=forms.TextInput(attrs={'size': '40'}))
251225

252-
fieldsets = [('Emails', ('primary_email', 'secondary_emails'))]
253-
254226
def __init__(self, *args, **kwargs):
255227
self.nomcom = kwargs.pop('nomcom', None)
256228
super(MergeForm, self).__init__(*args, **kwargs)
@@ -326,36 +298,26 @@ def save(self):
326298
secondary_nominees.update(duplicated=primary_nominee)
327299

328300

329-
class NominateForm(BaseNomcomForm, forms.ModelForm):
301+
class NominateForm(forms.ModelForm):
330302
comments = forms.CharField(label="Candidate's qualifications for the position",
331303
widget=forms.Textarea())
332304
confirmation = forms.BooleanField(label='Email comments back to me as confirmation.',
333305
help_text="If you want to get a confirmation mail containing your feedback in cleartext, please check the 'email comments back to me as confirmation'.",
334306
required=False)
335307

336-
fieldsets = [('Candidate Nomination', ('share_nominator','position', 'candidate_name',
337-
'candidate_email', 'candidate_phone', 'comments', 'confirmation'))]
338-
339308
def __init__(self, *args, **kwargs):
340309
self.nomcom = kwargs.pop('nomcom', None)
341310
self.user = kwargs.pop('user', None)
342311
self.public = kwargs.pop('public', None)
343312

344313
super(NominateForm, self).__init__(*args, **kwargs)
345314

346-
fieldset = ['share_nominator',
347-
'position',
348-
'candidate_name',
349-
'candidate_email', 'candidate_phone',
350-
'comments']
351-
352315
self.fields['nominator_email'].label = 'Nominator email'
353316
if self.nomcom:
354317
self.fields['position'].queryset = Position.objects.get_by_nomcom(self.nomcom).opened()
355318
self.fields['comments'].help_text = self.nomcom.initial_text
356319

357320
if not self.public:
358-
fieldset = ['nominator_email'] + fieldset
359321
author = get_user_email(self.user)
360322
if author:
361323
self.fields['nominator_email'].initial = author.address
@@ -367,9 +329,8 @@ def __init__(self, *args, **kwargs):
367329
has indicated they will allow NomCom to share their name as one of the people
368330
nominating this candidate."""
369331
else:
370-
fieldset.append('confirmation')
332+
pass
371333

372-
self.fieldsets = [('Candidate Nomination', fieldset)]
373334

374335
def save(self, commit=True):
375336
# Create nomination
@@ -433,7 +394,7 @@ class Meta:
433394
'candidate_email', 'candidate_phone')
434395

435396

436-
class FeedbackForm(BaseNomcomForm, forms.ModelForm):
397+
class FeedbackForm(forms.ModelForm):
437398
nominator_email = forms.CharField(label='Commenter email',required=False)
438399

439400
comments = forms.CharField(label='Comments',
@@ -516,25 +477,21 @@ class Meta:
516477
'confirmation',
517478
)
518479

519-
class FeedbackEmailForm(BaseNomcomForm, forms.Form):
480+
class FeedbackEmailForm(forms.Form):
520481

521482
email_text = forms.CharField(label='Email text', widget=forms.Textarea())
522483

523-
fieldsets = [('Feedback email', ('email_text',))]
524-
525484
def __init__(self, *args, **kwargs):
526485
self.nomcom = kwargs.pop('nomcom', None)
527486
super(FeedbackEmailForm, self).__init__(*args, **kwargs)
528487

529488
def save(self, commit=True):
530489
create_feedback_email(self.nomcom, self.cleaned_data['email_text'])
531490

532-
class QuestionnaireForm(BaseNomcomForm, forms.ModelForm):
491+
class QuestionnaireForm(forms.ModelForm):
533492

534493
comments = forms.CharField(label='Questionnaire response from this candidate',
535494
widget=forms.Textarea())
536-
fieldsets = [('New questionnaire response', ('nominee', 'comments'))]
537-
538495
def __init__(self, *args, **kwargs):
539496
self.nomcom = kwargs.pop('nomcom', None)
540497
self.user = kwargs.pop('user', None)
@@ -563,14 +520,10 @@ class Meta:
563520
model = Feedback
564521
fields = ( 'comments', )
565522

566-
class NomComTemplateForm(BaseNomcomForm, DBTemplateForm):
523+
class NomComTemplateForm(DBTemplateForm):
567524
content = forms.CharField(label="Text", widget=forms.Textarea(attrs={'cols': '120', 'rows':'40', }))
568-
fieldsets = [('Template content', ('content', )), ]
569525

570-
571-
class PositionForm(BaseNomcomForm, forms.ModelForm):
572-
573-
fieldsets = [('Position', ('name', 'is_open' ))]
526+
class PositionForm(forms.ModelForm):
574527

575528
class Meta:
576529
model = Position
@@ -585,12 +538,10 @@ def save(self, *args, **kwargs):
585538
super(PositionForm, self).save(*args, **kwargs)
586539

587540

588-
class PrivateKeyForm(BaseNomcomForm, forms.Form):
541+
class PrivateKeyForm(forms.Form):
589542

590543
key = forms.CharField(label='Private key', widget=forms.Textarea(), required=False)
591544

592-
fieldsets = [('Private key', ('key',))]
593-
594545
def clean_key(self):
595546
key = self.cleaned_data.get('key', None)
596547
if not key:
@@ -601,7 +552,7 @@ def clean_key(self):
601552
raise forms.ValidationError('Invalid private key. Error was: %s' % error)
602553

603554

604-
class PendingFeedbackForm(BaseNomcomForm, forms.ModelForm):
555+
class PendingFeedbackForm(forms.ModelForm):
605556

606557
type = forms.ModelChoiceField(queryset=FeedbackTypeName.objects.all().order_by('pk'), widget=forms.RadioSelect, empty_label='Unclassified', required=False)
607558

ietf/templates/nomcom/nomcomform.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)