Set parent of new areas to IESG. Fixes #2011. Commit ready for merge.
- Legacy-Id: 13328
This commit is contained in:
parent
073a7fb04a
commit
a9096359ce
|
@ -134,31 +134,12 @@ class AddAreaModelForm(forms.ModelForm):
|
|||
|
||||
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.")
|
||||
|
|
|
@ -33,3 +33,21 @@ class SecrAreasTestCase(TestCase):
|
|||
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)
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue