Changeset 377 in main


Ignore:
Timestamp:
10/06/11 08:07:21 (8 years ago)
Author:
pcosquer
Message:

sponsor: fix empty user.groupinfo_set

Location:
trunk/openPLM/plmapp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/controllers/user.py

    r375 r377  
    239239        password = generate_password() 
    240240        new_user.set_password(password) 
     241        new_user.groupinfo_set.add(*[g.groupinfo for g in new_user.groups.all()]) 
    241242        new_user.save() 
    242243        new_user.get_profile().is_contributor = is_contributor 
  • trunk/openPLM/plmapp/tests/views.py

    r376 r377  
    244244         
    245245    def test_navigate(self): 
    246         response = self.client.get(self.base_url + "navigate/") 
    247         self.assertEqual(response.status_code,  200) 
     246        response = self.client.get(self.user_url + "navigate/") 
     247        self.assertEqual(response.status_code,  200) 
     248 
     249    def test_sponsor_get(self): 
     250        response = self.client.get(self.user_url + "delegation/sponsor/") 
     251        self.assertEqual(response.status_code,  200) 
     252        form = response.context["sponsor_form"] 
     253        self.assertEquals(set(g.id for g in self.user.groupinfo_owner.all()), 
     254                set(g.id for g in form.fields["groups"].queryset.all())) 
     255 
     256    def test_sponsor_post(self): 
     257        data = dict(sponsor=self.user.id,  
     258                    username="loser", first_name="You", last_name="Lost", 
     259                    email="you.lost@example.com", groups=[self.group.pk]) 
     260        response = self.client.post(self.user_url + "delegation/sponsor/", data, 
     261                follow=True) 
     262        self.assertEqual(response.status_code,  200) 
     263        user = User.objects.get(username=data["username"]) 
     264        for attr in ("first_name", "last_name", "email"): 
     265            self.assertEquals(data[attr], getattr(user, attr)) 
     266        self.assertTrue(user.get_profile().is_contributor) 
     267        self.assertFalse(user.get_profile().is_administrator) 
     268        self.assertTrue(self.group in user.groupinfo_set.all()) 
     269 
    248270 
    249271class SearchViewTest(CommonViewTest): 
Note: See TracChangeset for help on using the changeset viewer.