Skip to content

Commit a909635

Browse files
committed
Set parent of new areas to IESG. Fixes ietf-tools#2011. Commit ready for merge.
- Legacy-Id: 13328
1 parent 073a7fb commit a909635

3 files changed

Lines changed: 21 additions & 22 deletions

File tree

ietf/secr/areas/forms.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,12 @@ def clean_name(self):
134134

135135
def save(self, force_insert=False, force_update=False, commit=True):
136136
area = super(AddAreaModelForm, self).save(commit=False)
137-
area_type = GroupTypeName.objects.get(name='area')
138-
area.type = area_type
137+
area.type = GroupTypeName.objects.get(slug='area')
138+
area.parent = Group.objects.get(acronym='iesg')
139139
if commit:
140140
area.save()
141141
return area
142142

143-
# class AddAreaForm(forms.Form):
144-
# acronym = forms.CharField(max_length=16,required=True)
145-
# name = forms.CharField(max_length=80,required=True)
146-
# status = forms.IntegerField(widget=forms.Select(choices=STATE_CHOICES),required=True)
147-
# start_date = forms.DateField()
148-
# comments = forms.CharField(widget=forms.Textarea(attrs={'rows':'1'}),required=False, strip=False)
149-
#
150-
# def clean_acronym(self):
151-
# # get name, strip leading and trailing spaces
152-
# name = self.cleaned_data.get('acronym', '').strip()
153-
# # check for invalid characters
154-
# r1 = re.compile(r'[a-zA-Z\-\. ]+$')
155-
# if name and not r1.match(name):
156-
# raise forms.ValidationError("Enter a valid acronym (only letters,period,hyphen allowed)")
157-
# # ensure doesn't already exist
158-
# if Group.objects.filter(acronym=name).exists():
159-
# raise forms.ValidationError("This acronym already exists. Enter a unique one.")
160-
# return name
161-
162143
class AreaDirectorForm(forms.Form):
163144
ad_name = forms.CharField(max_length=100,label='Name',help_text="To see a list of people type the first name, or last name, or both.")
164145
#login = forms.EmailField(max_length=75,help_text="This should be the person's primary email address.")

ietf/secr/areas/tests.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,21 @@ def test_view(self):
3333
self.client.login(username="secretary", password="secretary+password")
3434
response = self.client.get(url)
3535
self.assertEqual(response.status_code, 200)
36+
37+
def test_add(self):
38+
"Add Test"
39+
make_test_data()
40+
url = reverse('ietf.secr.areas.views.add')
41+
self.client.login(username="secretary", password="secretary+password")
42+
data = {'acronym':'ta',
43+
'name':'Test Area',
44+
'state':'active',
45+
'start_date':'2017-01-01',
46+
'awp-TOTAL_FORMS':'2',
47+
'awp-INITIAL_FORMS':'0',
48+
'submit':'Save'}
49+
response = self.client.post(url,data)
50+
self.assertRedirects(response, reverse('ietf.secr.areas.views.list_areas'))
51+
area = Group.objects.get(acronym='ta')
52+
iesg = Group.objects.get(acronym='iesg')
53+
self.assertTrue(area.parent == iesg)

ietf/secr/areas/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def add(request):
8383
group_url.save()
8484

8585
messages.success(request, 'The Area was created successfully!')
86-
return redirect('areas')
86+
return redirect('ietf.secr.areas.views.list_areas')
8787
else:
8888
# display initial forms
8989
area_form = AddAreaModelForm()

0 commit comments

Comments
 (0)