Skip to content

feat: OPTIC-1183: Improve is_delete flow #6473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion label_studio/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ def reset_token(self) -> Token:
def get_initials(self, is_deleted=False):
initials = '?'

if flag_set('fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=self) and is_deleted:
if (
getattr(settings, 'CLOUD_INSTANCE', False)
or flag_set('fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=self)
) and is_deleted:

return 'DU'

if not self.first_name and not self.last_name:
Expand Down
8 changes: 6 additions & 2 deletions label_studio/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def get_avatar(self, instance):
return instance.avatar_url

def get_initials(self, instance):
if flag_set('fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=instance):
if getattr(settings, 'CLOUD_INSTANCE', False) or flag_set(
'fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=instance
):
return instance.get_initials(self._is_deleted(instance))
else:
return instance.get_initials()
Expand Down Expand Up @@ -65,7 +67,9 @@ def to_representation(self, instance):
if uid not in self.context[key]:
self.context[key][uid] = super().to_representation(instance)

if flag_set('fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=instance):
if getattr(settings, 'CLOUD_INSTANCE', False) or flag_set(
'fflag_feat_all_optic_114_soft_delete_for_churned_employees', user=instance
):
if self._is_deleted(instance):
for field in ['username', 'first_name', 'last_name', 'email']:
self.context[key][uid][field] = 'User' if field == 'last_name' else 'Deleted'
Expand Down
Loading