Changeset 375 in main


Ignore:
Timestamp:
10/05/11 11:42:12 (8 years ago)
Author:
pcosquer
Message:

When a new object is created, sets the sponsor as the signer if
the sponsor is not the company

Location:
trunk/openPLM/plmapp/controllers
Files:
3 edited

Legend:

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

    r371 r375  
    183183        user = invitation.guest 
    184184        user.groups.add(self.object) 
     185        user.groupinfo_set.add(self.object) 
    185186        self._save_histo("User added", user.username, users=(user,)) 
    186187 
  • trunk/openPLM/plmapp/controllers/plmobject.py

    r367 r375  
    105105        # add links 
    106106        models.PLMObjectUserLink.objects.create(plmobject=obj, user=user, role="owner") 
     107        try: 
     108            l = models.DelegationLink.objects.get(delegatee=user, 
     109                    role=models.ROLE_SPONSOR) 
     110            sponsor = l.delegator 
     111            if sponsor.username == settings.COMPANY: 
     112                sponsor = user 
     113        except models.DelegationLink.DoesNotExist: 
     114            sponsor = user 
    107115        for i in range(len(obj.lifecycle.to_states_list()) - 1): 
    108             models.PLMObjectUserLink.objects.create(plmobject=obj, user=user, 
     116            models.PLMObjectUserLink.objects.create(plmobject=obj, user=sponsor, 
    109117                                                    role=level_to_sign_str(i)) 
    110118        return res 
  • trunk/openPLM/plmapp/controllers/user.py

    r357 r375  
    238238            pass 
    239239        password = generate_password() 
    240         new_user.is_contributor = is_contributor 
    241240        new_user.set_password(password) 
    242241        new_user.save() 
     242        new_user.get_profile().is_contributor = is_contributor 
     243        new_user.get_profile().save() 
    243244        link = models.DelegationLink(delegator=self._user, delegatee=new_user, 
    244245                role=models.ROLE_SPONSOR) 
Note: See TracChangeset for help on using the changeset viewer.