def CreatePageContent(self):
        ''' Save model instance data, and show form. '''
        if self.request.method == 'POST':
            
            detailsform = GroupForm(self.request.POST, instance = self.group)
            if detailsform.is_valid():
                detailsform.save()
                self.flags['saved'] = True
        else:
            detailsform = GroupForm(instance = self.group)

        return render_to_response("groups-manage-change-details", {'breadcrumb': self.breadcrumb, 'activetab': 'Groups', 'detailsform': detailsform, 'flags': self.flags})
Example #2
0
 def test_register_duplicate(self):
     ''' Group with same official name as existing > AlreadyExists '''
     group = {
         'official_name': "The Pete Peart Show",
         'category': self.category.id
         }
     
     mygroupform = GroupForm(group)
     self.assert_(mygroupform.is_valid())
     mygroupform.save()
     
     mygroupform = GroupForm(group)
     self.assert_(mygroupform.errors['official_name'] == ["Group with this Official name already exists."])
Example #3
0
 def test_register(self):
     ''' Minimal details > returns group '''
     group = {
         'official_name': "The Pete Peart Show",
         'category': self.category.id
         }
     
     mygroupform = GroupForm(group)
     self.assert_(mygroupform.is_valid())
     mynewgroup = mygroupform.save()
     
     self.assertEquals(mynewgroup.official_name, group['official_name'])
Example #4
0
 def test_register_all(self):
     ''' All possible details > returns group '''
     from MyPidge.Events.models import EventTag
     
     tags = [self.tagone, self.tagtwo]
     group = {
         'official_name': "The Pete Peart Show",
         'category': self.category.id,
         'friendly_name': "PP Show",
         'description': "Terribly exciting",
         'tags': [tag.id for tag in tags]
         }
     
     mygroupform = GroupForm(group)
     self.assert_(mygroupform.is_valid())
     mynewgroup = mygroupform.save()
     
     self.assertEquals(mynewgroup.official_name, group['official_name'])
     self.assertEquals(mynewgroup.category.id, group['category'])
     self.assertEquals(mynewgroup.friendly_name, group['friendly_name'])
     self.assertEquals(mynewgroup.description, group['description'])
     for tag in tags:
         self.assert_(tag in mynewgroup.tags.all())