Skip to content

Commit

Permalink
updated the reformatting using black
Browse files Browse the repository at this point in the history
  • Loading branch information
Pursottam6003 committed Mar 31, 2024
1 parent 728de7d commit b8237b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/dataset/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# import resource
import resource
from django.contrib import admin
from import_export.admin import ImportExportActionModelAdmin
from .resources import *
Expand Down
10 changes: 7 additions & 3 deletions backend/notifications/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@

def delete_excess_Notification(user):
if user.notification_limit is not None:
user_notifications_count = len(Notification.objects.filter(reciever_user_id=user))
user_notifications_count = len(
Notification.objects.filter(reciever_user_id=user)
)
if user_notifications_count >= user.notification_limit:
excess_notifications = Notification.objects.filter(
reciever_user_id=user
).order_by("created_at")[: user_notifications_count - user.notification_limit]
).order_by("created_at")[
: user_notifications_count - user.notification_limit
]
for excess_notification in excess_notifications:
excess_notification.reciever_user_id.remove(user)
if len(excess_notification.reciever_user_id.all()) == 0:
Expand Down Expand Up @@ -51,7 +55,7 @@ def create_notification_handler(
new_notif.reciever_user_id.add(receiver_user)
delete_excess_Notification(receiver_user)
except Exception as e:
print(e,NOTIFICATION_CREATION_FAILED)
print(e, NOTIFICATION_CREATION_FAILED)
print(NOTIFICATION_CREATED)
else:
print(NOTIFICATION_CREATED)
Expand Down
16 changes: 9 additions & 7 deletions backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ def remove_annotator(self, request, pk=None, freeze_user=True):
)
notification_ids.extend(ids)
notification_ids_set = list(set(notification_ids))
createNotification(title, notification_type, notification_ids_set,pk)
createNotification(title, notification_type, notification_ids_set, pk)
return Response(
{"message": "User removed from project"},
status=status.HTTP_201_CREATED,
Expand Down Expand Up @@ -1542,7 +1542,9 @@ def remove_reviewer(self, request, pk=None, freeze_user=True):
)
notification_ids.extend(ids)
notification_ids_set = list(set(notification_ids))
createNotification(title, notification_type, notification_ids_set,project.id)
createNotification(
title, notification_type, notification_ids_set, project.id
)

return Response(
{"message": "User removed from the project"}, status=status.HTTP_200_OK
Expand Down Expand Up @@ -1622,7 +1624,7 @@ def remove_superchecker(self, request, pk=None, freeze_user=True):
)
notification_ids.extend(ids)
notification_ids_set = list(set(notification_ids))
createNotification(title, notification_type, notification_ids_set,pk)
createNotification(title, notification_type, notification_ids_set, pk)

return Response(
{"message": "User removed from the project"}, status=status.HTTP_200_OK
Expand Down Expand Up @@ -1955,7 +1957,7 @@ def update(self, request, pk=None, *args, **kwargs):
super_checkers_bool=True,
project_manager_bool=True,
)
createNotification(title, notification_type, notification_ids,pk)
createNotification(title, notification_type, notification_ids, pk)
return super().update(request, *args, **kwargs)

@is_project_editor
Expand Down Expand Up @@ -3375,7 +3377,7 @@ def add_project_annotators(self, request, pk=None, *args, **kwargs):
project_manager_bool=True,
)

createNotification(title, notification_type, notification_ids,pk)
createNotification(title, notification_type, notification_ids, pk)

return Response(
{"message": "Annotator added to the project"}, status=status.HTTP_200_OK
Expand Down Expand Up @@ -3500,7 +3502,7 @@ def add_project_supercheckers(self, request, pk, *args, **kwargs):
super_checkers_bool=True,
project_manager_bool=True,
)
createNotification(title, notification_type, notification_ids,pk)
createNotification(title, notification_type, notification_ids, pk)

return Response(
{"message": "SuperCheckers added"}, status=status.HTTP_200_OK
Expand Down Expand Up @@ -4072,7 +4074,7 @@ def project_publish(self, request, pk=None, *args, **kwargs):
super_checkers_bool=True,
project_manager_bool=True,
)
createNotification(title, notification_type, notification_ids,pk)
createNotification(title, notification_type, notification_ids, pk)
return Response(PROJECT_IS_PUBLISHED_ERROR, status=status.HTTP_200_OK)
serializer = ProjectUsersSerializer(project, many=False)
# ret_dict = serializer.data
Expand Down

0 comments on commit b8237b9

Please sign in to comment.