Skip to content

Commit

Permalink
Set parent of new areas to IESG. Fixes #2011. Commit ready for merge.
Browse files Browse the repository at this point in the history
 - Legacy-Id: 13328
  • Loading branch information
rpcross committed May 11, 2017
1 parent 073a7fb commit a909635
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
23 changes: 2 additions & 21 deletions ietf/secr/areas/forms.py
Expand Up @@ -134,31 +134,12 @@ def clean_name(self):

def save(self, force_insert=False, force_update=False, commit=True):
area = super(AddAreaModelForm, self).save(commit=False)
area_type = GroupTypeName.objects.get(name='area')
area.type = area_type
area.type = GroupTypeName.objects.get(slug='area')
area.parent = Group.objects.get(acronym='iesg')
if commit:
area.save()
return area

# class AddAreaForm(forms.Form):
# acronym = forms.CharField(max_length=16,required=True)
# name = forms.CharField(max_length=80,required=True)
# status = forms.IntegerField(widget=forms.Select(choices=STATE_CHOICES),required=True)
# start_date = forms.DateField()
# comments = forms.CharField(widget=forms.Textarea(attrs={'rows':'1'}),required=False, strip=False)
#
# def clean_acronym(self):
# # get name, strip leading and trailing spaces
# name = self.cleaned_data.get('acronym', '').strip()
# # check for invalid characters
# r1 = re.compile(r'[a-zA-Z\-\. ]+$')
# if name and not r1.match(name):
# raise forms.ValidationError("Enter a valid acronym (only letters,period,hyphen allowed)")
# # ensure doesn't already exist
# if Group.objects.filter(acronym=name).exists():
# raise forms.ValidationError("This acronym already exists. Enter a unique one.")
# return name

class AreaDirectorForm(forms.Form):
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.")
#login = forms.EmailField(max_length=75,help_text="This should be the person's primary email address.")
Expand Down
18 changes: 18 additions & 0 deletions ietf/secr/areas/tests.py
Expand Up @@ -33,3 +33,21 @@ def test_view(self):
self.client.login(username="secretary", password="secretary+password")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

def test_add(self):
"Add Test"
make_test_data()
url = reverse('ietf.secr.areas.views.add')
self.client.login(username="secretary", password="secretary+password")
data = {'acronym':'ta',
'name':'Test Area',
'state':'active',
'start_date':'2017-01-01',
'awp-TOTAL_FORMS':'2',
'awp-INITIAL_FORMS':'0',
'submit':'Save'}
response = self.client.post(url,data)
self.assertRedirects(response, reverse('ietf.secr.areas.views.list_areas'))
area = Group.objects.get(acronym='ta')
iesg = Group.objects.get(acronym='iesg')
self.assertTrue(area.parent == iesg)
2 changes: 1 addition & 1 deletion ietf/secr/areas/views.py
Expand Up @@ -83,7 +83,7 @@ def add(request):
group_url.save()

messages.success(request, 'The Area was created successfully!')
return redirect('areas')
return redirect('ietf.secr.areas.views.list_areas')
else:
# display initial forms
area_form = AddAreaModelForm()
Expand Down

0 comments on commit a909635

Please sign in to comment.