diff --git a/.gitignore b/.gitignore index 71572ed17..7f0c6c5d1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ Thumbs.db # Virtual Environment .virtualenv*/* .venv/* +server/.venv ## Compatibility # OS4-Submodules diff --git a/.travis.yml b/.travis.yml index dc89cfd38..a71818155 100644 --- a/.travis.yml +++ b/.travis.yml @@ -109,7 +109,7 @@ jobs: script: - flake8 openslides tests - isort --check-only --diff --recursive openslides tests - - black --check --diff --target-version py36 openslides tests + - black --check --diff openslides tests - mypy openslides/ tests/ - pytest --cov --cov-fail-under=75 @@ -122,7 +122,7 @@ jobs: script: - flake8 openslides tests - isort --check-only --diff --recursive openslides tests - - black --check --diff --target-version py36 openslides tests + - black --check --diff openslides tests - mypy openslides/ tests/ - pytest --cov --cov-fail-under=75 diff --git a/server/openslides/agenda/models.py b/server/openslides/agenda/models.py index cbb608330..b3fddb52d 100644 --- a/server/openslides/agenda/models.py +++ b/server/openslides/agenda/models.py @@ -360,8 +360,6 @@ class ListOfSpeakersManager(BaseManager): class ListOfSpeakers(RESTModelMixin, models.Model): - """ - """ access_permissions = ListOfSpeakersAccessPermissions() objects = ListOfSpeakersManager() diff --git a/server/openslides/assignments/migrations/0010_voting_3.py b/server/openslides/assignments/migrations/0010_voting_3.py index b3f8bf115..54b8f7d72 100644 --- a/server/openslides/assignments/migrations/0010_voting_3.py +++ b/server/openslides/assignments/migrations/0010_voting_3.py @@ -20,5 +20,5 @@ class Migration(migrations.Migration): migrations.RemoveField(model_name="assignmentpoll", name="votesabstain"), migrations.RemoveField(model_name="assignmentpoll", name="votesno"), migrations.RemoveField(model_name="assignmentpoll", name="published"), - migrations.RemoveField(model_name="assignmentrelateduser", name="elected",), + migrations.RemoveField(model_name="assignmentrelateduser", name="elected"), ] diff --git a/server/openslides/assignments/migrations/0012_assignment_vote_unique_together.py b/server/openslides/assignments/migrations/0012_assignment_vote_unique_together.py index 2a7e822ea..bc3722295 100644 --- a/server/openslides/assignments/migrations/0012_assignment_vote_unique_together.py +++ b/server/openslides/assignments/migrations/0012_assignment_vote_unique_together.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( - name="assignmentvote", unique_together={("user", "option")}, + name="assignmentvote", unique_together={("user", "option")} ), ] diff --git a/server/openslides/assignments/views.py b/server/openslides/assignments/views.py index c86fa4c5a..8fbdd6274 100644 --- a/server/openslides/assignments/views.py +++ b/server/openslides/assignments/views.py @@ -465,14 +465,14 @@ class AssignmentPollViewSet(BasePollViewSet): ) if ( poll.pollmethod == AssignmentPoll.POLLMETHOD_YNA - and value not in ("Y", "N", "A",) + and value not in ("Y", "N", "A") ): raise ValidationError( {"detail": "Every value must be Y, N or A"} ) elif ( poll.pollmethod == AssignmentPoll.POLLMETHOD_YN - and value not in ("Y", "N",) + and value not in ("Y", "N") ): raise ValidationError({"detail": "Every value must be Y or N"}) @@ -526,7 +526,7 @@ class AssignmentPollViewSet(BasePollViewSet): for option_id, result in data.items(): option = options.get(pk=option_id) vote = AssignmentVote.objects.create( - option=option, user=vote_user, value=result, weight=weight, + option=option, user=vote_user, value=result, weight=weight ) inform_changed_data(vote, no_delete_on_restriction=True) inform_changed_data(option, no_delete_on_restriction=True) diff --git a/server/openslides/core/migrations/0028_projector_size_3.py b/server/openslides/core/migrations/0028_projector_size_3.py index 81b623232..13a612b37 100644 --- a/server/openslides/core/migrations/0028_projector_size_3.py +++ b/server/openslides/core/migrations/0028_projector_size_3.py @@ -9,6 +9,4 @@ class Migration(migrations.Migration): ("core", "0027_projector_size_2"), ] - operations = [ - migrations.RemoveField(model_name="projector", name="height",), - ] + operations = [migrations.RemoveField(model_name="projector", name="height")] diff --git a/server/openslides/core/migrations/0030_voting_projection_defaults.py b/server/openslides/core/migrations/0030_voting_projection_defaults.py index 0dd201757..a264404b2 100644 --- a/server/openslides/core/migrations/0030_voting_projection_defaults.py +++ b/server/openslides/core/migrations/0030_voting_projection_defaults.py @@ -14,7 +14,7 @@ def add_poll_projection_defaults(apps, schema_editor): projectiondefaults.append( ProjectionDefault( - name="assignment_poll", display_name="Ballots", projector=default_projector, + name="assignment_poll", display_name="Ballots", projector=default_projector ) ) projectiondefaults.append( diff --git a/server/openslides/motions/access_permissions.py b/server/openslides/motions/access_permissions.py index 6000b552d..dcfde0d6c 100644 --- a/server/openslides/motions/access_permissions.py +++ b/server/openslides/motions/access_permissions.py @@ -53,11 +53,15 @@ class MotionAccessPermissions(BaseAccessPermissions): # Parse values of restriction field. # If at least one restriction is ok, permissions are granted. for value in restriction: - if value in ( - "motions.can_see_internal", - "motions.can_manage_metadata", - "motions.can_manage", - ) and await async_has_perm(user_id, value): + if ( + value + in ( + "motions.can_see_internal", + "motions.can_manage_metadata", + "motions.can_manage", + ) + and await async_has_perm(user_id, value) + ): permission = True break elif value == "is_submitter" and is_submitter: diff --git a/server/openslides/motions/migrations/0035_motion_vote_unique_together.py b/server/openslides/motions/migrations/0035_motion_vote_unique_together.py index 0678fba94..25d49d5af 100644 --- a/server/openslides/motions/migrations/0035_motion_vote_unique_together.py +++ b/server/openslides/motions/migrations/0035_motion_vote_unique_together.py @@ -13,6 +13,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( - name="motionvote", unique_together={("user", "option")}, - ), + name="motionvote", unique_together={("user", "option")} + ) ] diff --git a/server/openslides/motions/models.py b/server/openslides/motions/models.py index 66a3ec8ea..73cee0870 100644 --- a/server/openslides/motions/models.py +++ b/server/openslides/motions/models.py @@ -193,7 +193,7 @@ class Motion(RESTModelMixin, AgendaItemWithListOfSpeakersMixin, models.Model): """ motion_block = models.ForeignKey( - "MotionBlock", on_delete=SET_NULL_AND_AUTOUPDATE, null=True, blank=True, + "MotionBlock", on_delete=SET_NULL_AND_AUTOUPDATE, null=True, blank=True ) """ ForeignKey to one block of motions. diff --git a/server/openslides/motions/views.py b/server/openslides/motions/views.py index 55f1f7afa..a9d7253dc 100644 --- a/server/openslides/motions/views.py +++ b/server/openslides/motions/views.py @@ -1744,8 +1744,6 @@ class StateViewSet(ModelViewSet, ProtectedErrorMessageMixin): return result def create(self, request, *args, **kwargs): - """ - """ result = super().create(request, *args, **kwargs) workflow_id = request.data[ "workflow_id" diff --git a/server/openslides/utils/cache.py b/server/openslides/utils/cache.py index bfa87b2b7..31828a7b7 100644 --- a/server/openslides/utils/cache.py +++ b/server/openslides/utils/cache.py @@ -165,7 +165,7 @@ class ElementCache: logger.info("Done saving the cache data.") def _build_cache_get_elementid_model_mapping( - self, config_only: bool = False, + self, config_only: bool = False ) -> Dict[str, str]: """ Do NOT call this in an asynchronous context! diff --git a/server/openslides/utils/consumer_autoupdate_strategy.py b/server/openslides/utils/consumer_autoupdate_strategy.py index 0c4922028..63bde7021 100644 --- a/server/openslides/utils/consumer_autoupdate_strategy.py +++ b/server/openslides/utils/consumer_autoupdate_strategy.py @@ -98,5 +98,5 @@ class ConsumerAutoupdateStrategy: self.client_change_id = max_change_id # It will be send, so we can set the client_change_id await self.consumer.send_json( - type="autoupdate", content=autoupdate, in_response=in_response, + type="autoupdate", content=autoupdate, in_response=in_response ) diff --git a/server/openslides/utils/websocket.py b/server/openslides/utils/websocket.py index 42e5b802f..4157d7ce2 100644 --- a/server/openslides/utils/websocket.py +++ b/server/openslides/utils/websocket.py @@ -143,7 +143,7 @@ class ProtocollAsyncJsonWebsocketConsumer(AsyncCompressedJsonWebsocketConsumer): ) async def send_exception( - self, e: BaseWebsocketException, silence_errors: Optional[bool] = True, + self, e: BaseWebsocketException, silence_errors: Optional[bool] = True ) -> None: """ Send generic error messages with a custom status code (see above) and a text message. diff --git a/server/openslides/utils/websocket_client_messages.py b/server/openslides/utils/websocket_client_messages.py index d66eb1f58..ce8c62759 100644 --- a/server/openslides/utils/websocket_client_messages.py +++ b/server/openslides/utils/websocket_client_messages.py @@ -62,7 +62,7 @@ class Notify(BaseWebsocketClientMessage): perm = self.notify_permissions.get(content["name"]) if perm is not None and not await async_has_perm(consumer.user_id, perm): raise NotAuthorizedException( - f"You need '{perm}' to send this message.", in_response=id, + f"You need '{perm}' to send this message.", in_response=id ) else: # Some logging diff --git a/server/tests/integration/assignments/test_polls.py b/server/tests/integration/assignments/test_polls.py index aa1a07257..e0bc8ee34 100644 --- a/server/tests/integration/assignments/test_polls.py +++ b/server/tests/integration/assignments/test_polls.py @@ -105,7 +105,7 @@ def create_assignment_polls(): class CreateAssignmentPoll(TestCase): def advancedSetUp(self): self.assignment = Assignment.objects.create( - title="test_assignment_ohneivoh9caiB8Yiungo", open_posts=1, + title="test_assignment_ohneivoh9caiB8Yiungo", open_posts=1 ) self.assignment.add_candidate(self.admin) @@ -576,7 +576,7 @@ class UpdateAssignmentPoll(TestCase): def test_patch_groups_to_empty(self): response = self.client.patch( - reverse("assignmentpoll-detail", args=[self.poll.pk]), {"groups_id": []}, + reverse("assignmentpoll-detail", args=[self.poll.pk]), {"groups_id": []} ) self.assertHttpStatusVerbose(response, status.HTTP_200_OK) poll = AssignmentPoll.objects.get() @@ -869,7 +869,7 @@ class VoteAssignmentPollAnalogYNA(VoteAssignmentPollBaseTestClass): def test_wrong_data_format(self): self.start_poll() response = self.client.post( - reverse("assignmentpoll-vote", args=[self.poll.pk]), [1, 2, 5], + reverse("assignmentpoll-vote", args=[self.poll.pk]), [1, 2, 5] ) self.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST) self.assertFalse(AssignmentVote.objects.exists()) @@ -1063,7 +1063,7 @@ class VoteAssignmentPollNamedYNA(VoteAssignmentPollBaseTestClass): option2 = self.poll2.options.get() # Do request to poll with option2 (which is wrong...) response = self.client.post( - reverse("assignmentpoll-vote", args=[self.poll.pk]), {str(option2.id): "Y"}, + reverse("assignmentpoll-vote", args=[self.poll.pk]), {str(option2.id): "Y"} ) self.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST) self.assertEqual(AssignmentVote.objects.count(), 0) diff --git a/server/tests/integration/motions/test_polls.py b/server/tests/integration/motions/test_polls.py index 8714a103c..2b93759bd 100644 --- a/server/tests/integration/motions/test_polls.py +++ b/server/tests/integration/motions/test_polls.py @@ -488,7 +488,7 @@ class UpdateMotionPoll(TestCase): def test_patch_groups_to_empty(self): response = self.client.patch( - reverse("motionpoll-detail", args=[self.poll.pk]), {"groups_id": []}, + reverse("motionpoll-detail", args=[self.poll.pk]), {"groups_id": []} ) self.assertHttpStatusVerbose(response, status.HTTP_200_OK) poll = MotionPoll.objects.get() @@ -641,7 +641,7 @@ class VoteMotionPollAnalog(TestCase): def test_vote_missing_data(self): self.start_poll() response = self.client.post( - reverse("motionpoll-vote", args=[self.poll.pk]), {"Y": "4", "N": "22.6"}, + reverse("motionpoll-vote", args=[self.poll.pk]), {"Y": "4", "N": "22.6"} ) self.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST) self.assertFalse(MotionPoll.objects.get().get_votes().exists()) @@ -879,7 +879,7 @@ class VoteMotionPollNamed(TestCase): class VoteMotionPollNamedAutoupdates(TestCase): - """ 3 important users: + """3 important users: self.admin: manager, has can_see, can_manage, can_manage_polls (in admin group) self.user1: votes, has can_see perms and in in delegate group self.other_user: Just has can_see perms and is NOT in the delegate group. @@ -1018,7 +1018,7 @@ class VoteMotionPollNamedAutoupdates(TestCase): class VoteMotionPollPseudoanonymousAutoupdates(TestCase): - """ 3 important users: + """3 important users: self.admin: manager, has can_see, can_manage, can_manage_polls (in admin group) self.user: votes, has can_see perms and in in delegate group self.other_user: Just has can_see perms and is NOT in the delegate group. diff --git a/server/tests/integration/users/test_viewset.py b/server/tests/integration/users/test_viewset.py index 8af4588fa..9f7dad1e7 100644 --- a/server/tests/integration/users/test_viewset.py +++ b/server/tests/integration/users/test_viewset.py @@ -723,7 +723,7 @@ class GroupCreate(TestCase): self.client.login(username="admin", password="admin") response = self.client.post( - reverse("group-list"), {"name": "Test name ldr59xq2mvt96rdayhju"}, + reverse("group-list"), {"name": "Test name ldr59xq2mvt96rdayhju"} ) self.assertEqual(response.status_code, status.HTTP_201_CREATED)