Blocking projects when users cancelling accounts
parent
a263e79e39
commit
1f1b1b605a
|
@ -42,6 +42,7 @@ from taiga.auth.tokens import get_token_for_user
|
||||||
from taiga.base.utils.slug import slugify_uniquely
|
from taiga.base.utils.slug import slugify_uniquely
|
||||||
from taiga.base.utils.iterators import split_by_n
|
from taiga.base.utils.iterators import split_by_n
|
||||||
from taiga.permissions.permissions import MEMBERS_PERMISSIONS
|
from taiga.permissions.permissions import MEMBERS_PERMISSIONS
|
||||||
|
from taiga.projects.choices import BLOCKED_BY_OWNER_LEAVING
|
||||||
from taiga.projects.notifications.choices import NotifyLevel
|
from taiga.projects.notifications.choices import NotifyLevel
|
||||||
|
|
||||||
from easy_thumbnails.files import get_thumbnailer
|
from easy_thumbnails.files import get_thumbnailer
|
||||||
|
@ -245,6 +246,9 @@ class User(AbstractBaseUser, PermissionsMixin):
|
||||||
self.save()
|
self.save()
|
||||||
self.auth_data.all().delete()
|
self.auth_data.all().delete()
|
||||||
|
|
||||||
|
#Blocking all owned users
|
||||||
|
self.owned_projects.update(blocked_code=BLOCKED_BY_OWNER_LEAVING)
|
||||||
|
|
||||||
|
|
||||||
class Role(models.Model):
|
class Role(models.Model):
|
||||||
name = models.CharField(max_length=200, null=False, blank=False,
|
name = models.CharField(max_length=200, null=False, blank=False,
|
||||||
|
|
|
@ -15,6 +15,7 @@ from taiga.users import models
|
||||||
from taiga.users.serializers import LikedObjectSerializer, VotedObjectSerializer
|
from taiga.users.serializers import LikedObjectSerializer, VotedObjectSerializer
|
||||||
from taiga.auth.tokens import get_token_for_user
|
from taiga.auth.tokens import get_token_for_user
|
||||||
from taiga.permissions.permissions import MEMBERS_PERMISSIONS, ANON_PERMISSIONS, USER_PERMISSIONS
|
from taiga.permissions.permissions import MEMBERS_PERMISSIONS, ANON_PERMISSIONS, USER_PERMISSIONS
|
||||||
|
from taiga.projects import choices as project_choices
|
||||||
from taiga.users.services import get_watched_list, get_voted_list, get_liked_list
|
from taiga.users.services import get_watched_list, get_voted_list, get_liked_list
|
||||||
from taiga.projects.notifications.choices import NotifyLevel
|
from taiga.projects.notifications.choices import NotifyLevel
|
||||||
from taiga.projects.notifications.models import NotifyPolicy
|
from taiga.projects.notifications.models import NotifyPolicy
|
||||||
|
@ -152,6 +153,18 @@ def test_delete_self_user(client):
|
||||||
assert user.full_name == "Deleted user"
|
assert user.full_name == "Deleted user"
|
||||||
|
|
||||||
|
|
||||||
|
def test_delete_self_user_blocking_projects(client):
|
||||||
|
user = f.UserFactory.create()
|
||||||
|
project = f.ProjectFactory.create(owner=user)
|
||||||
|
url = reverse('users-detail', kwargs={"pk": user.pk})
|
||||||
|
|
||||||
|
assert project.blocked_code == None
|
||||||
|
client.login(user)
|
||||||
|
response = client.delete(url)
|
||||||
|
project = user.owned_projects.first()
|
||||||
|
assert project.blocked_code == project_choices.BLOCKED_BY_OWNER_LEAVING
|
||||||
|
|
||||||
|
|
||||||
def test_cancel_self_user_with_valid_token(client):
|
def test_cancel_self_user_with_valid_token(client):
|
||||||
user = f.UserFactory.create()
|
user = f.UserFactory.create()
|
||||||
url = reverse('users-cancel')
|
url = reverse('users-cancel')
|
||||||
|
|
Loading…
Reference in New Issue