Update black
This commit is contained in:
parent
7315626e18
commit
f9d19db9e2
@ -6,7 +6,7 @@ from django.db import migrations, transaction
|
|||||||
|
|
||||||
|
|
||||||
def change_pollmethods(apps, schema_editor):
|
def change_pollmethods(apps, schema_editor):
|
||||||
""" yn->YN, yna->YNA """
|
"""yn->YN, yna->YNA"""
|
||||||
AssignmentPoll = apps.get_model("assignments", "AssignmentPoll")
|
AssignmentPoll = apps.get_model("assignments", "AssignmentPoll")
|
||||||
pollmethod_map = {
|
pollmethod_map = {
|
||||||
"yn": "YN",
|
"yn": "YN",
|
||||||
@ -113,7 +113,7 @@ def convert_votesno(apps, schema_editor):
|
|||||||
|
|
||||||
|
|
||||||
def set_correct_state(apps, schema_editor):
|
def set_correct_state(apps, schema_editor):
|
||||||
""" if poll.published, set state to published """
|
"""if poll.published, set state to published"""
|
||||||
AssignmentPoll = apps.get_model("assignments", "AssignmentPoll")
|
AssignmentPoll = apps.get_model("assignments", "AssignmentPoll")
|
||||||
AssignmentVote = apps.get_model("assignments", "AssignmentVote")
|
AssignmentVote = apps.get_model("assignments", "AssignmentVote")
|
||||||
for poll in AssignmentPoll.objects.all():
|
for poll in AssignmentPoll.objects.all():
|
||||||
|
@ -106,7 +106,7 @@ class AssignmentPollSerializer(BasePollSerializer):
|
|||||||
read_only_fields = ("state",)
|
read_only_fields = ("state",)
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
""" Prevent updating the assignment """
|
"""Prevent updating the assignment"""
|
||||||
validated_data.pop("assignment", None)
|
validated_data.pop("assignment", None)
|
||||||
return super().update(instance, validated_data)
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def watch_and_update_configs():
|
|||||||
|
|
||||||
|
|
||||||
def build_mapping(base_config_key, mediafiles):
|
def build_mapping(base_config_key, mediafiles):
|
||||||
""" Returns a map of config keys to medaifile ids """
|
"""Returns a map of config keys to medaifile ids"""
|
||||||
logos = {}
|
logos = {}
|
||||||
for key in config[base_config_key]:
|
for key in config[base_config_key]:
|
||||||
url = config[key]["path"]
|
url = config[key]["path"]
|
||||||
|
@ -169,11 +169,11 @@ class Mediafile(RESTModelMixin, ListOfSpeakersMixin, models.Model):
|
|||||||
return deleted_ids
|
return deleted_ids
|
||||||
|
|
||||||
def _db_delete(self, *args, **kwargs):
|
def _db_delete(self, *args, **kwargs):
|
||||||
""" Captures the original .delete() method. """
|
"""Captures the original .delete() method."""
|
||||||
return super().delete(*args, **kwargs)
|
return super().delete(*args, **kwargs)
|
||||||
|
|
||||||
def get_children_deep(self):
|
def get_children_deep(self):
|
||||||
""" Returns all children and all children of childrens and so forth. """
|
"""Returns all children and all children of childrens and so forth."""
|
||||||
children = []
|
children = []
|
||||||
for child in self.children.all():
|
for child in self.children.all():
|
||||||
children.append(child)
|
children.append(child)
|
||||||
@ -257,7 +257,7 @@ class Mediafile(RESTModelMixin, ListOfSpeakersMixin, models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_file(self):
|
def is_file(self):
|
||||||
""" Do not check the self.mediafile, becuase this is not a valid indicator. """
|
"""Do not check the self.mediafile, becuase this is not a valid indicator."""
|
||||||
return not self.is_directory
|
return not self.is_directory
|
||||||
|
|
||||||
def get_list_of_speakers_title_information(self):
|
def get_list_of_speakers_title_information(self):
|
||||||
|
@ -4,7 +4,7 @@ from django.db import migrations
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
""" Cleanup 1 """
|
"""Cleanup 1"""
|
||||||
|
|
||||||
dependencies = [("motions", "0011_motion_version_2")]
|
dependencies = [("motions", "0011_motion_version_2")]
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
""" Cleanup 2 """
|
"""Cleanup 2"""
|
||||||
|
|
||||||
dependencies = [("motions", "0011_motion_version_3")]
|
dependencies = [("motions", "0011_motion_version_3")]
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.db import migrations, models
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
""" Note: this is a combined migration to execute code in a seperate transaction """
|
"""Note: this is a combined migration to execute code in a seperate transaction"""
|
||||||
|
|
||||||
dependencies = [("motions", "0020_auto_20190119_1425")]
|
dependencies = [("motions", "0020_auto_20190119_1425")]
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from django.db import migrations
|
|||||||
|
|
||||||
|
|
||||||
def change_pollmethods(apps, schema_editor):
|
def change_pollmethods(apps, schema_editor):
|
||||||
""" yn->YN, yna->YNA """
|
"""yn->YN, yna->YNA"""
|
||||||
MotionPoll = apps.get_model("motions", "MotionPoll")
|
MotionPoll = apps.get_model("motions", "MotionPoll")
|
||||||
pollmethod_map = {
|
pollmethod_map = {
|
||||||
"yn": "YN",
|
"yn": "YN",
|
||||||
@ -83,7 +83,7 @@ def convert_votes(apps, schema_editor):
|
|||||||
|
|
||||||
|
|
||||||
def set_correct_state(apps, schema_editor):
|
def set_correct_state(apps, schema_editor):
|
||||||
""" If there are votes, set the state to finished """
|
"""If there are votes, set the state to finished"""
|
||||||
MotionPoll = apps.get_model("motions", "MotionPoll")
|
MotionPoll = apps.get_model("motions", "MotionPoll")
|
||||||
MotionVote = apps.get_model("motions", "MotionVote")
|
MotionVote = apps.get_model("motions", "MotionVote")
|
||||||
for poll in MotionPoll.objects.all():
|
for poll in MotionPoll.objects.all():
|
||||||
|
@ -1057,7 +1057,7 @@ class State(RESTModelMixin, models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def is_next_or_previous_state_id(self, state_id):
|
def is_next_or_previous_state_id(self, state_id):
|
||||||
""" Returns true, if the given state id is a valid next or previous state """
|
"""Returns true, if the given state id is a valid next or previous state"""
|
||||||
next_state_ids = [item.id for item in self.next_states.all()]
|
next_state_ids = [item.id for item in self.next_states.all()]
|
||||||
previous_state_ids = [
|
previous_state_ids = [
|
||||||
item.id for item in State.objects.filter(next_states__in=[self.id])
|
item.id for item in State.objects.filter(next_states__in=[self.id])
|
||||||
|
@ -256,7 +256,7 @@ class MotionPollSerializer(BasePollSerializer):
|
|||||||
read_only_fields = ("state",)
|
read_only_fields = ("state",)
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
""" Prevent updating the motion """
|
"""Prevent updating the motion"""
|
||||||
validated_data.pop("motion", None)
|
validated_data.pop("motion", None)
|
||||||
return super().update(instance, validated_data)
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ class MotionCommentSectionSerializer(ModelSerializer):
|
|||||||
read_only_fields = ("weight",)
|
read_only_fields = ("weight",)
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
""" Call inform_changed_data on creation, so the cache includes the groups. """
|
"""Call inform_changed_data on creation, so the cache includes the groups."""
|
||||||
section = super().create(validated_data)
|
section = super().create(validated_data)
|
||||||
inform_changed_data(section)
|
inform_changed_data(section)
|
||||||
return section
|
return section
|
||||||
|
@ -15,7 +15,7 @@ from ..utils.models import SET_NULL_AND_AUTOUPDATE
|
|||||||
|
|
||||||
|
|
||||||
def generate_user_token():
|
def generate_user_token():
|
||||||
""" Generates a 16 character alphanumeric token. """
|
"""Generates a 16 character alphanumeric token."""
|
||||||
return get_random_string(16)
|
return get_random_string(16)
|
||||||
|
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class BasePoll(models.Model):
|
|||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def create_options(self):
|
def create_options(self):
|
||||||
""" Should be called after creation of this model. """
|
"""Should be called after creation of this model."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -316,7 +316,7 @@ class BasePollViewSet(ModelViewSet):
|
|||||||
raise ValidationError({"detail": "You have already voted."})
|
raise ValidationError({"detail": "You have already voted."})
|
||||||
|
|
||||||
def parse_vote_value(self, obj, key):
|
def parse_vote_value(self, obj, key):
|
||||||
""" Raises a ValidationError on incorrect values, including None """
|
"""Raises a ValidationError on incorrect values, including None"""
|
||||||
if key not in obj:
|
if key not in obj:
|
||||||
raise ValidationError({"detail": f"The field {key} is required"})
|
raise ValidationError({"detail": f"The field {key} is required"})
|
||||||
field = DecimalField(min_value=-2, max_digits=15, decimal_places=6)
|
field = DecimalField(min_value=-2, max_digits=15, decimal_places=6)
|
||||||
|
@ -32,7 +32,7 @@ class SamlView(View):
|
|||||||
return super().__init__(*args, **kwargs)
|
return super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
""" POST requests should do the same as GET requests. """
|
"""POST requests should do the same as GET requests."""
|
||||||
return self.get(request, *args, **kwargs)
|
return self.get(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
@ -183,7 +183,7 @@ class SamlView(View):
|
|||||||
return queryargs
|
return queryargs
|
||||||
|
|
||||||
def update_user(self, user, attributes):
|
def update_user(self, user, attributes):
|
||||||
""" Updates a user with the new attributes """
|
"""Updates a user with the new attributes"""
|
||||||
if "auth_type" in attributes:
|
if "auth_type" in attributes:
|
||||||
del attributes["auth_type"]
|
del attributes["auth_type"]
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class BaseUserBackend:
|
|||||||
|
|
||||||
|
|
||||||
class DefaultUserBackend(BaseUserBackend):
|
class DefaultUserBackend(BaseUserBackend):
|
||||||
""" The default user backend for OpenSlides """
|
"""The default user backend for OpenSlides"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -51,14 +51,14 @@ class UserBackendManager:
|
|||||||
self.backends: Dict[str, BaseUserBackend] = {}
|
self.backends: Dict[str, BaseUserBackend] = {}
|
||||||
|
|
||||||
def collect_backends_from_apps(self):
|
def collect_backends_from_apps(self):
|
||||||
""" Iterate through app configs and get an optional "user_backend_class" for a backend """
|
"""Iterate through app configs and get an optional "user_backend_class" for a backend"""
|
||||||
for app in apps.get_app_configs():
|
for app in apps.get_app_configs():
|
||||||
user_backend_class = getattr(app, "user_backend_class", None)
|
user_backend_class = getattr(app, "user_backend_class", None)
|
||||||
if user_backend_class:
|
if user_backend_class:
|
||||||
self.register_user_backend(user_backend_class())
|
self.register_user_backend(user_backend_class())
|
||||||
|
|
||||||
def register_user_backend(self, backend: BaseUserBackend):
|
def register_user_backend(self, backend: BaseUserBackend):
|
||||||
""" Registeres a user backend """
|
"""Registeres a user backend"""
|
||||||
if backend.name in self.backends:
|
if backend.name in self.backends:
|
||||||
raise UserBackendException(
|
raise UserBackendException(
|
||||||
f"The user backend {backend.name} already exists."
|
f"The user backend {backend.name} already exists."
|
||||||
@ -75,7 +75,7 @@ class UserBackendManager:
|
|||||||
return self.backends[name]
|
return self.backends[name]
|
||||||
|
|
||||||
def get_backends_for_client(self) -> Dict[str, Dict[str, Any]]:
|
def get_backends_for_client(self) -> Dict[str, Dict[str, Any]]:
|
||||||
""" Formats the backends for the client """
|
"""Formats the backends for the client"""
|
||||||
return {name: backend.for_client() for name, backend in self.backends.items()}
|
return {name: backend.for_client() for name, backend in self.backends.items()}
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ class UserViewSet(ModelViewSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def assert_list_of_ints(self, ids, ids_name="user_ids"):
|
def assert_list_of_ints(self, ids, ids_name="user_ids"):
|
||||||
""" Asserts, that ids is a list of ints. Raises a ValidationError, if not. """
|
"""Asserts, that ids is a list of ints. Raises a ValidationError, if not."""
|
||||||
if not isinstance(ids, list):
|
if not isinstance(ids, list):
|
||||||
raise ValidationError({"detail": "{0} must be a list", "args": [ids_name]})
|
raise ValidationError({"detail": "{0} must be a list", "args": [ids_name]})
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
@ -20,7 +20,6 @@ AutoupdateFormat = TypedDict(
|
|||||||
|
|
||||||
|
|
||||||
def disable_history() -> None:
|
def disable_history() -> None:
|
||||||
""""""
|
|
||||||
with autoupdate_bundle() as bundle:
|
with autoupdate_bundle() as bundle:
|
||||||
bundle.disable_history()
|
bundle.disable_history()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class AutoupdateBundle:
|
|||||||
self._disable_history = False
|
self._disable_history = False
|
||||||
|
|
||||||
def add(self, elements: Iterable[AutoupdateElement]) -> None:
|
def add(self, elements: Iterable[AutoupdateElement]) -> None:
|
||||||
""" Adds the elements to the bundle """
|
"""Adds the elements to the bundle"""
|
||||||
for element in elements:
|
for element in elements:
|
||||||
self.autoupdate_elements[element["collection_string"]][
|
self.autoupdate_elements[element["collection_string"]][
|
||||||
element["id"]
|
element["id"]
|
||||||
@ -103,7 +103,7 @@ class AutoupdateBundle:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def element_iterator(self) -> Iterable[AutoupdateElement]:
|
def element_iterator(self) -> Iterable[AutoupdateElement]:
|
||||||
""" Iterator for all elements in this bundle """
|
"""Iterator for all elements in this bundle"""
|
||||||
for elements in self.autoupdate_elements.values():
|
for elements in self.autoupdate_elements.values():
|
||||||
yield from elements.values()
|
yield from elements.values()
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ class RedisCacheProvider:
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
async def get_schema_version(self) -> Optional[SchemaVersion]:
|
async def get_schema_version(self) -> Optional[SchemaVersion]:
|
||||||
""" Retrieves the schema version of the cache or None, if not existent """
|
"""Retrieves the schema version of the cache or None, if not existent"""
|
||||||
async with get_connection(read_only=True) as redis:
|
async with get_connection(read_only=True) as redis:
|
||||||
try:
|
try:
|
||||||
schema_version = await redis.hgetall(self.schema_cache_key)
|
schema_version = await redis.hgetall(self.schema_cache_key)
|
||||||
@ -441,7 +441,7 @@ class RedisCacheProvider:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def set_schema_version(self, schema_version: SchemaVersion) -> None:
|
async def set_schema_version(self, schema_version: SchemaVersion) -> None:
|
||||||
""" Sets the schema version for this cache. """
|
"""Sets the schema version for this cache."""
|
||||||
async with get_connection() as redis:
|
async with get_connection() as redis:
|
||||||
await redis.hmset_dict(self.schema_cache_key, schema_version)
|
await redis.hmset_dict(self.schema_cache_key, schema_version)
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ class RedisCacheProvider:
|
|||||||
async def _eval(
|
async def _eval(
|
||||||
self, redis: Any, script_name: str, keys: List[str] = [], args: List[Any] = []
|
self, redis: Any, script_name: str, keys: List[str] = [], args: List[Any] = []
|
||||||
) -> Any:
|
) -> Any:
|
||||||
""" Do a real eval of the script (no hash used here). Catches "cache_reset". """
|
"""Do a real eval of the script (no hash used here). Catches "cache_reset"."""
|
||||||
try:
|
try:
|
||||||
return await redis.eval(self.scripts[script_name][0], keys, args)
|
return await redis.eval(self.scripts[script_name][0], keys, args)
|
||||||
except aioredis.errors.ReplyError as e:
|
except aioredis.errors.ReplyError as e:
|
||||||
|
@ -142,7 +142,7 @@ class InvalidConnection(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class ConnectionPool(ChannelRedisConnectionPool):
|
class ConnectionPool(ChannelRedisConnectionPool):
|
||||||
""" Adds a trivial, soft limit for the pool """
|
"""Adds a trivial, soft limit for the pool"""
|
||||||
|
|
||||||
def __init__(self, host: Any) -> None:
|
def __init__(self, host: Any) -> None:
|
||||||
self.counter = 0
|
self.counter = 0
|
||||||
|
@ -28,7 +28,7 @@ class WebsocketLatencyLogger:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def add_latency(cls, latency: int) -> None:
|
async def add_latency(cls, latency: int) -> None:
|
||||||
""" Add the latency to the logger. """
|
"""Add the latency to the logger."""
|
||||||
# pass the latency value to the single instance
|
# pass the latency value to the single instance
|
||||||
if cls.instance is None:
|
if cls.instance is None:
|
||||||
cls.instance = cls()
|
cls.instance = cls()
|
||||||
@ -49,7 +49,7 @@ class WebsocketLatencyLogger:
|
|||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
def flush(self) -> None:
|
def flush(self) -> None:
|
||||||
""" Calc Stats and print to logger. """
|
"""Calc Stats and print to logger."""
|
||||||
N = len(self.latencies)
|
N = len(self.latencies)
|
||||||
mean = sum(self.latencies) / N
|
mean = sum(self.latencies) / N
|
||||||
std = sum((latency - mean) ** 2 for latency in self.latencies)
|
std = sum((latency - mean) ** 2 for latency in self.latencies)
|
||||||
@ -58,7 +58,7 @@ class WebsocketLatencyLogger:
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
""" Resets the stats. """
|
"""Resets the stats."""
|
||||||
self.latencies: List[int] = []
|
self.latencies: List[int] = []
|
||||||
self.time = time.time()
|
self.time = time.time()
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class WebsocketThroughputLogger:
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
""" Resets the stats. """
|
"""Resets the stats."""
|
||||||
self.send_compressed = 0
|
self.send_compressed = 0
|
||||||
self.send_uncompressed = 0
|
self.send_uncompressed = 0
|
||||||
self.receive_compressed = 0
|
self.receive_compressed = 0
|
||||||
|
@ -266,7 +266,7 @@ class TestUpdate(TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_update_parent_id(self):
|
def test_update_parent_id(self):
|
||||||
""" Assert, that the parent id does not change """
|
"""Assert, that the parent id does not change"""
|
||||||
response = self.client.put(
|
response = self.client.put(
|
||||||
reverse("mediafile-detail", args=[self.mediafileA.pk]),
|
reverse("mediafile-detail", args=[self.mediafileA.pk]),
|
||||||
{"title": self.mediafileA.title, "parent_id": None},
|
{"title": self.mediafileA.title, "parent_id": None},
|
||||||
|
@ -881,7 +881,7 @@ class VoteMotionPollNamed(TestCase):
|
|||||||
self.assertFalse(MotionPoll.objects.get().get_votes().exists())
|
self.assertFalse(MotionPoll.objects.get().get_votes().exists())
|
||||||
|
|
||||||
def setup_vote_delegation(self, with_delegation=True):
|
def setup_vote_delegation(self, with_delegation=True):
|
||||||
""" user -> admin """
|
"""user -> admin"""
|
||||||
self.start_poll()
|
self.start_poll()
|
||||||
self.make_admin_delegate()
|
self.make_admin_delegate()
|
||||||
self.make_admin_present()
|
self.make_admin_present()
|
||||||
@ -1392,7 +1392,7 @@ class ResetMotionPoll(TestCase):
|
|||||||
|
|
||||||
class TestMotionPollWithVoteDelegationAutoupdate(TestCase):
|
class TestMotionPollWithVoteDelegationAutoupdate(TestCase):
|
||||||
def advancedSetUp(self):
|
def advancedSetUp(self):
|
||||||
""" Set up user -> other_user delegation. """
|
"""Set up user -> other_user delegation."""
|
||||||
self.motion = Motion(
|
self.motion = Motion(
|
||||||
title="test_title_dL91JqhMTiQuQLSDRItZ",
|
title="test_title_dL91JqhMTiQuQLSDRItZ",
|
||||||
text="test_text_R7nURdXKVEfEnnJBXJYa",
|
text="test_text_R7nURdXKVEfEnnJBXJYa",
|
||||||
|
@ -660,7 +660,7 @@ class TestMotionCommentSectionSorting(TestCase):
|
|||||||
self.assert_not_changed()
|
self.assert_not_changed()
|
||||||
|
|
||||||
def assert_not_changed(self):
|
def assert_not_changed(self):
|
||||||
""" Asserts, that every comment section has the default weight of 10000. """
|
"""Asserts, that every comment section has the default weight of 10000."""
|
||||||
for section in MotionCommentSection.objects.all():
|
for section in MotionCommentSection.objects.all():
|
||||||
self.assertEqual(section.weight, 10000)
|
self.assertEqual(section.weight, 10000)
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertIsNone(admin.vote_delegated_to_id)
|
self.assertIsNone(admin.vote_delegated_to_id)
|
||||||
|
|
||||||
def setup_vote_delegation(self):
|
def setup_vote_delegation(self):
|
||||||
""" login and setup user -> user2 delegation """
|
"""login and setup user -> user2 delegation"""
|
||||||
self.user, _ = self.create_user()
|
self.user, _ = self.create_user()
|
||||||
self.user2, _ = self.create_user()
|
self.user2, _ = self.create_user()
|
||||||
self.user.vote_delegated_to = self.user2
|
self.user.vote_delegated_to = self.user2
|
||||||
@ -354,7 +354,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertEqual(user.vote_delegated_to_id, self.user2.id)
|
self.assertEqual(user.vote_delegated_to_id, self.user2.id)
|
||||||
|
|
||||||
def test_update_nested_vote_delegation_1(self):
|
def test_update_nested_vote_delegation_1(self):
|
||||||
""" user -> user2 -> admin """
|
"""user -> user2 -> admin"""
|
||||||
self.setup_vote_delegation()
|
self.setup_vote_delegation()
|
||||||
response = self.client.patch(
|
response = self.client.patch(
|
||||||
reverse("user-detail", args=[self.user2.pk]),
|
reverse("user-detail", args=[self.user2.pk]),
|
||||||
@ -366,7 +366,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertIsNone(user2.vote_delegated_to_id)
|
self.assertIsNone(user2.vote_delegated_to_id)
|
||||||
|
|
||||||
def test_update_nested_vote_delegation_2(self):
|
def test_update_nested_vote_delegation_2(self):
|
||||||
""" admin -> user -> user2 """
|
"""admin -> user -> user2"""
|
||||||
self.setup_vote_delegation()
|
self.setup_vote_delegation()
|
||||||
response = self.client.patch(
|
response = self.client.patch(
|
||||||
reverse("user-detail", args=[self.admin.pk]),
|
reverse("user-detail", args=[self.admin.pk]),
|
||||||
@ -391,7 +391,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertIsNone(user.vote_delegated_to_id)
|
self.assertIsNone(user.vote_delegated_to_id)
|
||||||
|
|
||||||
def test_update_vote_delegated_from_nested_1(self):
|
def test_update_vote_delegated_from_nested_1(self):
|
||||||
""" admin -> user -> user2 """
|
"""admin -> user -> user2"""
|
||||||
self.setup_vote_delegation()
|
self.setup_vote_delegation()
|
||||||
response = self.client.patch(
|
response = self.client.patch(
|
||||||
reverse("user-detail", args=[self.user.pk]),
|
reverse("user-detail", args=[self.user.pk]),
|
||||||
@ -403,7 +403,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertIsNone(admin.vote_delegated_to_id)
|
self.assertIsNone(admin.vote_delegated_to_id)
|
||||||
|
|
||||||
def test_update_vote_delegated_from_nested_2(self):
|
def test_update_vote_delegated_from_nested_2(self):
|
||||||
""" user -> user2 -> admin """
|
"""user -> user2 -> admin"""
|
||||||
self.setup_vote_delegation()
|
self.setup_vote_delegation()
|
||||||
response = self.client.patch(
|
response = self.client.patch(
|
||||||
reverse("user-detail", args=[self.admin.pk]),
|
reverse("user-detail", args=[self.admin.pk]),
|
||||||
@ -415,7 +415,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertIsNone(user2.vote_delegated_to_id)
|
self.assertIsNone(user2.vote_delegated_to_id)
|
||||||
|
|
||||||
def test_update_vote_delegation_both_1(self):
|
def test_update_vote_delegation_both_1(self):
|
||||||
""" Change user -> user2 to admin -> user in one request. """
|
"""Change user -> user2 to admin -> user in one request."""
|
||||||
self.user2 = User.objects.create_user(
|
self.user2 = User.objects.create_user(
|
||||||
username="user2",
|
username="user2",
|
||||||
password="non-admin 1WywRnqKbcdtQwS2",
|
password="non-admin 1WywRnqKbcdtQwS2",
|
||||||
@ -446,7 +446,7 @@ class UserUpdate(TestCase):
|
|||||||
self.assertEqual(user2.vote_delegated_from_users.count(), 0)
|
self.assertEqual(user2.vote_delegated_from_users.count(), 0)
|
||||||
|
|
||||||
def test_update_vote_delegation_both_2(self):
|
def test_update_vote_delegation_both_2(self):
|
||||||
""" Change user -> user2 to user2 -> admin in one request. """
|
"""Change user -> user2 to user2 -> admin in one request."""
|
||||||
self.user2 = User.objects.create_user(
|
self.user2 = User.objects.create_user(
|
||||||
username="user2",
|
username="user2",
|
||||||
password="non-admin 1WywRnqKbcdtQwS2",
|
password="non-admin 1WywRnqKbcdtQwS2",
|
||||||
@ -519,7 +519,7 @@ class UserDelete(TestCase):
|
|||||||
self.assertFalse(User.objects.filter(pk__in=ids).exists())
|
self.assertFalse(User.objects.filter(pk__in=ids).exists())
|
||||||
|
|
||||||
def test_bulk_delete_self(self):
|
def test_bulk_delete_self(self):
|
||||||
""" The own id should be excluded, so nothing should happen. """
|
"""The own id should be excluded, so nothing should happen."""
|
||||||
response = self.admin_client.post(
|
response = self.admin_client.post(
|
||||||
reverse("user-bulk-delete"), {"user_ids": [1]}
|
reverse("user-bulk-delete"), {"user_ids": [1]}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user