Fixing black

This commit is contained in:
Finn Stutzenstein 2020-08-31 13:24:16 +02:00
parent 9a4f8e1781
commit 325c5ea1f4
No known key found for this signature in database
GPG Key ID: 9042F605C6324654
19 changed files with 35 additions and 36 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ Thumbs.db
# Virtual Environment # Virtual Environment
.virtualenv*/* .virtualenv*/*
.venv/* .venv/*
server/.venv
## Compatibility ## Compatibility
# OS4-Submodules # OS4-Submodules

View File

@ -109,7 +109,7 @@ jobs:
script: script:
- flake8 openslides tests - flake8 openslides tests
- isort --check-only --diff --recursive 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/ - mypy openslides/ tests/
- pytest --cov --cov-fail-under=75 - pytest --cov --cov-fail-under=75
@ -122,7 +122,7 @@ jobs:
script: script:
- flake8 openslides tests - flake8 openslides tests
- isort --check-only --diff --recursive 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/ - mypy openslides/ tests/
- pytest --cov --cov-fail-under=75 - pytest --cov --cov-fail-under=75

View File

@ -360,8 +360,6 @@ class ListOfSpeakersManager(BaseManager):
class ListOfSpeakers(RESTModelMixin, models.Model): class ListOfSpeakers(RESTModelMixin, models.Model):
"""
"""
access_permissions = ListOfSpeakersAccessPermissions() access_permissions = ListOfSpeakersAccessPermissions()
objects = ListOfSpeakersManager() objects = ListOfSpeakersManager()

View File

@ -20,5 +20,5 @@ class Migration(migrations.Migration):
migrations.RemoveField(model_name="assignmentpoll", name="votesabstain"), migrations.RemoveField(model_name="assignmentpoll", name="votesabstain"),
migrations.RemoveField(model_name="assignmentpoll", name="votesno"), migrations.RemoveField(model_name="assignmentpoll", name="votesno"),
migrations.RemoveField(model_name="assignmentpoll", name="published"), migrations.RemoveField(model_name="assignmentpoll", name="published"),
migrations.RemoveField(model_name="assignmentrelateduser", name="elected",), migrations.RemoveField(model_name="assignmentrelateduser", name="elected"),
] ]

View File

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.AlterUniqueTogether( migrations.AlterUniqueTogether(
name="assignmentvote", unique_together={("user", "option")}, name="assignmentvote", unique_together={("user", "option")}
), ),
] ]

View File

@ -465,14 +465,14 @@ class AssignmentPollViewSet(BasePollViewSet):
) )
if ( if (
poll.pollmethod == AssignmentPoll.POLLMETHOD_YNA poll.pollmethod == AssignmentPoll.POLLMETHOD_YNA
and value not in ("Y", "N", "A",) and value not in ("Y", "N", "A")
): ):
raise ValidationError( raise ValidationError(
{"detail": "Every value must be Y, N or A"} {"detail": "Every value must be Y, N or A"}
) )
elif ( elif (
poll.pollmethod == AssignmentPoll.POLLMETHOD_YN 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"}) raise ValidationError({"detail": "Every value must be Y or N"})
@ -526,7 +526,7 @@ class AssignmentPollViewSet(BasePollViewSet):
for option_id, result in data.items(): for option_id, result in data.items():
option = options.get(pk=option_id) option = options.get(pk=option_id)
vote = AssignmentVote.objects.create( 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(vote, no_delete_on_restriction=True)
inform_changed_data(option, no_delete_on_restriction=True) inform_changed_data(option, no_delete_on_restriction=True)

View File

@ -9,6 +9,4 @@ class Migration(migrations.Migration):
("core", "0027_projector_size_2"), ("core", "0027_projector_size_2"),
] ]
operations = [ operations = [migrations.RemoveField(model_name="projector", name="height")]
migrations.RemoveField(model_name="projector", name="height",),
]

View File

@ -14,7 +14,7 @@ def add_poll_projection_defaults(apps, schema_editor):
projectiondefaults.append( projectiondefaults.append(
ProjectionDefault( ProjectionDefault(
name="assignment_poll", display_name="Ballots", projector=default_projector, name="assignment_poll", display_name="Ballots", projector=default_projector
) )
) )
projectiondefaults.append( projectiondefaults.append(

View File

@ -53,11 +53,15 @@ class MotionAccessPermissions(BaseAccessPermissions):
# Parse values of restriction field. # Parse values of restriction field.
# If at least one restriction is ok, permissions are granted. # If at least one restriction is ok, permissions are granted.
for value in restriction: for value in restriction:
if value in ( if (
value
in (
"motions.can_see_internal", "motions.can_see_internal",
"motions.can_manage_metadata", "motions.can_manage_metadata",
"motions.can_manage", "motions.can_manage",
) and await async_has_perm(user_id, value): )
and await async_has_perm(user_id, value)
):
permission = True permission = True
break break
elif value == "is_submitter" and is_submitter: elif value == "is_submitter" and is_submitter:

View File

@ -13,6 +13,6 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.AlterUniqueTogether( migrations.AlterUniqueTogether(
name="motionvote", unique_together={("user", "option")}, name="motionvote", unique_together={("user", "option")}
), )
] ]

View File

@ -193,7 +193,7 @@ class Motion(RESTModelMixin, AgendaItemWithListOfSpeakersMixin, models.Model):
""" """
motion_block = models.ForeignKey( 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. ForeignKey to one block of motions.

View File

@ -1744,8 +1744,6 @@ class StateViewSet(ModelViewSet, ProtectedErrorMessageMixin):
return result return result
def create(self, request, *args, **kwargs): def create(self, request, *args, **kwargs):
"""
"""
result = super().create(request, *args, **kwargs) result = super().create(request, *args, **kwargs)
workflow_id = request.data[ workflow_id = request.data[
"workflow_id" "workflow_id"

View File

@ -165,7 +165,7 @@ class ElementCache:
logger.info("Done saving the cache data.") logger.info("Done saving the cache data.")
def _build_cache_get_elementid_model_mapping( def _build_cache_get_elementid_model_mapping(
self, config_only: bool = False, self, config_only: bool = False
) -> Dict[str, str]: ) -> Dict[str, str]:
""" """
Do NOT call this in an asynchronous context! Do NOT call this in an asynchronous context!

View File

@ -98,5 +98,5 @@ class ConsumerAutoupdateStrategy:
self.client_change_id = max_change_id self.client_change_id = max_change_id
# It will be send, so we can set the client_change_id # It will be send, so we can set the client_change_id
await self.consumer.send_json( await self.consumer.send_json(
type="autoupdate", content=autoupdate, in_response=in_response, type="autoupdate", content=autoupdate, in_response=in_response
) )

View File

@ -143,7 +143,7 @@ class ProtocollAsyncJsonWebsocketConsumer(AsyncCompressedJsonWebsocketConsumer):
) )
async def send_exception( async def send_exception(
self, e: BaseWebsocketException, silence_errors: Optional[bool] = True, self, e: BaseWebsocketException, silence_errors: Optional[bool] = True
) -> None: ) -> None:
""" """
Send generic error messages with a custom status code (see above) and a text message. Send generic error messages with a custom status code (see above) and a text message.

View File

@ -62,7 +62,7 @@ class Notify(BaseWebsocketClientMessage):
perm = self.notify_permissions.get(content["name"]) perm = self.notify_permissions.get(content["name"])
if perm is not None and not await async_has_perm(consumer.user_id, perm): if perm is not None and not await async_has_perm(consumer.user_id, perm):
raise NotAuthorizedException( 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: else:
# Some logging # Some logging

View File

@ -105,7 +105,7 @@ def create_assignment_polls():
class CreateAssignmentPoll(TestCase): class CreateAssignmentPoll(TestCase):
def advancedSetUp(self): def advancedSetUp(self):
self.assignment = Assignment.objects.create( 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) self.assignment.add_candidate(self.admin)
@ -576,7 +576,7 @@ class UpdateAssignmentPoll(TestCase):
def test_patch_groups_to_empty(self): def test_patch_groups_to_empty(self):
response = self.client.patch( 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) self.assertHttpStatusVerbose(response, status.HTTP_200_OK)
poll = AssignmentPoll.objects.get() poll = AssignmentPoll.objects.get()
@ -869,7 +869,7 @@ class VoteAssignmentPollAnalogYNA(VoteAssignmentPollBaseTestClass):
def test_wrong_data_format(self): def test_wrong_data_format(self):
self.start_poll() self.start_poll()
response = self.client.post( 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.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST)
self.assertFalse(AssignmentVote.objects.exists()) self.assertFalse(AssignmentVote.objects.exists())
@ -1063,7 +1063,7 @@ class VoteAssignmentPollNamedYNA(VoteAssignmentPollBaseTestClass):
option2 = self.poll2.options.get() option2 = self.poll2.options.get()
# Do request to poll with option2 (which is wrong...) # Do request to poll with option2 (which is wrong...)
response = self.client.post( 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.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST)
self.assertEqual(AssignmentVote.objects.count(), 0) self.assertEqual(AssignmentVote.objects.count(), 0)

View File

@ -488,7 +488,7 @@ class UpdateMotionPoll(TestCase):
def test_patch_groups_to_empty(self): def test_patch_groups_to_empty(self):
response = self.client.patch( 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) self.assertHttpStatusVerbose(response, status.HTTP_200_OK)
poll = MotionPoll.objects.get() poll = MotionPoll.objects.get()
@ -641,7 +641,7 @@ class VoteMotionPollAnalog(TestCase):
def test_vote_missing_data(self): def test_vote_missing_data(self):
self.start_poll() self.start_poll()
response = self.client.post( 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.assertHttpStatusVerbose(response, status.HTTP_400_BAD_REQUEST)
self.assertFalse(MotionPoll.objects.get().get_votes().exists()) self.assertFalse(MotionPoll.objects.get().get_votes().exists())

View File

@ -723,7 +723,7 @@ class GroupCreate(TestCase):
self.client.login(username="admin", password="admin") self.client.login(username="admin", password="admin")
response = self.client.post( 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) self.assertEqual(response.status_code, status.HTTP_201_CREATED)