def save(self, commit=True):
        group, project = self.team.group, self.team.project

        granted_perms = self.cleaned_data['permissions']
        team_perms = get_perms(group, project)
        # Grant permissions
        for perm in granted_perms:
            if perm not in team_perms:
                assign(perm, group, project)
                self._message('info', _("Permission added: %s" % perm))
        # Remove permissions
        for perm in team_perms:
            if perm not in granted_perms:
                remove_perm(perm, group, project)
                self._message('warning', _("Permission removed: %s" % perm))
Saves granted permissions and removes those switched off.
dataset/ETHPy150Open lukaszb/django-projector/projector/forms.py/ProjectTeamPermissionsForm.save