-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge main into stable/4.0.x. Update 20231101
* commit 'daba71c3e49e414f9455a542104a0e181b22d6d9': Fix speaker.delete and speaker.update for deleted users (#1935) Fix opentelemetry in backend (#1915) Allow strikthrough short tag (#1932) Introduce speaker deletion logic to user.update and user.delete (#1921)
- Loading branch information
Showing
16 changed files
with
360 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
|
||
from .shared.env import Environment | ||
from .shared.otel import init as otel_init | ||
from .shared.otel import instrument_requests as otel_instrument_requests | ||
|
||
otel_init(Environment(os.environ), "backend") | ||
otel_instrument_requests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
openslides_backend/action/actions/user/conditional_speaker_cascade_mixin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Any, Dict, Optional | ||
|
||
from openslides_backend.shared.filters import And, FilterOperator | ||
|
||
from ....services.datastore.commands import GetManyRequest | ||
from ...action import Action | ||
from ..speaker.delete import SpeakerDeleteAction | ||
|
||
|
||
class ConditionalSpeakerCascadeMixin(Action): | ||
""" | ||
Mixin for user actions that deletes unstarted speeches of users that were either deleted, or removed from a meeting | ||
""" | ||
|
||
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]: | ||
removed_meeting_id = self.get_removed_meeting_id(instance) | ||
if removed_meeting_id is not None: | ||
filter_: Any = FilterOperator("user_id", "=", instance["id"]) | ||
if removed_meeting_id: | ||
filter_ = And( | ||
filter_, FilterOperator("meeting_id", "=", removed_meeting_id) | ||
) | ||
meeting_users = self.datastore.filter( | ||
"meeting_user", filter_, ["speaker_ids"] | ||
) | ||
speaker_ids = [ | ||
speaker_id | ||
for val in meeting_users.values() | ||
if val.get("speaker_ids") | ||
for speaker_id in val.get("speaker_ids", []) | ||
] | ||
speakers = self.datastore.get_many( | ||
[ | ||
GetManyRequest( | ||
"speaker", | ||
speaker_ids, | ||
[ | ||
"begin_time", | ||
"id", | ||
], | ||
) | ||
] | ||
) | ||
speakers_to_delete = [ | ||
speaker | ||
for speaker in speakers.get("speaker", {}).values() | ||
if speaker.get("begin_time") is None | ||
] | ||
|
||
if len(speakers_to_delete): | ||
self.execute_other_action( | ||
SpeakerDeleteAction, | ||
[{"id": speaker["id"]} for speaker in speakers_to_delete], | ||
) | ||
|
||
return super().update_instance(instance) | ||
|
||
def get_removed_meeting_id(self, instance: Dict[str, Any]) -> Optional[int]: | ||
""" | ||
Get the id of the meetings from which the user is removed. | ||
If the user is removed from all meetings, the return value will be 0. | ||
If the user is removed from no meetings, it will be None. | ||
""" | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"blockquote", | ||
# text formating | ||
"strike", | ||
"s", | ||
"del", | ||
"ins", | ||
"strong", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
export DATASTORE_COMMIT_HASH=0720dd02b04b5d77a6269b5cd8611b1eab154e9f | ||
export DATASTORE_COMMIT_HASH=3d217923ab5ed5a4a4bae8f334f6e8404ab884be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.