Revision 5c34b421 snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
1891 1891
    def approved_members(self):
1892 1892
        return [m.person for m in self.approved_memberships]
1893 1893

  
1894
    def add_member(self, user):
1895
        """
1896
        Raises:
1897
            astakos.im.models.AstakosUser.DoesNotExist
1898
        """
1899
        if isinstance(user, (int, long)):
1900
            user = AstakosUser.objects.get(user=user)
1901

  
1902
        m, created = ProjectMembership.objects.get_or_create(
1903
            person=user, project=self
1904
        )
1905
        m.accept()
1906

  
1907
    def remove_member(self, user):
1908
        """
1909
        Raises:
1910
            astakos.im.models.AstakosUser.DoesNotExist
1911
            astakos.im.models.ProjectMembership.DoesNotExist
1912
        """
1913
        if isinstance(user, (int, long)):
1914
            user = AstakosUser.objects.get(user=user)
1915

  
1916
        m = ProjectMembership.objects.get(person=user, project=self)
1917
        m.remove()
1918

  
1919 1894

  
1920 1895
CHAIN_STATE = {
1921 1896
    (Project.APPROVED,   ProjectApplication.PENDING)  : Chain.APPROVED_PENDING,

Also available in: Unified diff