dinukadesilva commented on code in PR #88:
URL:
https://github.com/apache/airavata-django-portal/pull/88#discussion_r886175439
##########
django_airavata/apps/api/serializers.py:
##########
@@ -1081,11 +1081,39 @@ class NotificationSerializer(
publishedTime = UTCPosixTimestampDateTimeField()
expirationTime = UTCPosixTimestampDateTimeField()
userHasWriteAccess = serializers.SerializerMethodField()
+ showInDashboard = serializers.BooleanField(default=False)
def get_userHasWriteAccess(self, userProfile):
request = self.context['request']
return request.is_gateway_admin
+ def validate(self, attrs):
+ del attrs["showInDashboard"]
+
+ return attrs
+
+ def to_representation(self, notification):
+ notification_extension_list =
models.NotificationExtension.objects.filter(
+ notification_id=notification.notificationId)
+ setattr(notification, "showInDashboard",
+ False if len(notification_extension_list) == 0 else
notification_extension_list[0].showInDashboard)
+
+ return super().to_representation(notification)
+
+ def update_notification_extension(self, request, notification):
Review Comment:
@machristie The notification create has the following step which required
the `request` so I wasn't able to have it inside the serializer since it's not
a model-based serializer.
```
notificationId = self.request.airavata_client.createNotification(
self.authz_token, notification)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]