From 72296dbd80684912bdada3a2b1ce6aca97c4a485 Mon Sep 17 00:00:00 2001 From: Michael Volo Date: Wed, 16 Oct 2024 14:19:38 -0500 Subject: [PATCH] stub review data until FE removes them --- salesforce/management/commands/update_partners.py | 2 -- salesforce/models.py | 13 +++++++++++++ salesforce/serializers.py | 10 ++++++++++ salesforce/urls.py | 4 +++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/salesforce/management/commands/update_partners.py b/salesforce/management/commands/update_partners.py index df35e608..836f3d20 100644 --- a/salesforce/management/commands/update_partners.py +++ b/salesforce/management/commands/update_partners.py @@ -23,8 +23,6 @@ def handle(self, *args, **options): query = "SELECT " \ "Id, " \ "Name, " \ - "Logo__c, " \ - "Public_Logo_Link__c, " \ "Partner_Type__c, " \ "Books_Offered__c, " \ "Description__c, " \ diff --git a/salesforce/models.py b/salesforce/models.py index 8b9f0c32..3e7d4a21 100644 --- a/salesforce/models.py +++ b/salesforce/models.py @@ -253,6 +253,19 @@ def partner_logo_tag(self): else: return mark_safe(u'') + # TODO: the next three methods about reviews should be removed once the FE is updated to not expect them + @property + def reviews(self): + return [] + + @property + def average_rating(self): + return {'rating__avg': 0.0} + + @property + def rating_count(self): + return 0 + @hooks.register('register_admin_menu_item') def register_partner_menu_item(): return MenuItem('Partners', '/django-admin/salesforce/partner/', classname='icon icon-group', order=3000) diff --git a/salesforce/serializers.py b/salesforce/serializers.py index 8667ce8a..548a0871 100644 --- a/salesforce/serializers.py +++ b/salesforce/serializers.py @@ -77,6 +77,11 @@ class Meta: ) class PartnerSerializer(serializers.ModelSerializer): + # TODO: remove + reviews = serializers.ReadOnlyField() + average_rating = serializers.ReadOnlyField() + rating_count = serializers.ReadOnlyField() + def __init__(self, *args, **kwargs): super(PartnerSerializer, self).__init__(*args, **kwargs) @@ -86,6 +91,11 @@ def __init__(self, *args, **kwargs): def to_representation(self, instance): ret = super().to_representation(instance) + # TODO: remove + # if looking at an individual partner instance, include the reviews - else, exclude + if not isinstance(self.instance, Partner): + ret['reviews'] = False + # Here we filter the null values and creates a new dictionary # We use OrderedDict like in original method ret = OrderedDict(filter(lambda x: x[1] is not False, ret.items())) diff --git a/salesforce/urls.py b/salesforce/urls.py index cb2e7f11..b8b94087 100644 --- a/salesforce/urls.py +++ b/salesforce/urls.py @@ -11,6 +11,8 @@ urlpatterns = [ path('', include(router.urls)), - path('adoption-status/', views.get_adoption_status), + #TODO: remove + path('reviews/', views.AdoptionOpportunityRecordViewSet.as_view({'get': 'list'}), path('renewal/', views.AdoptionOpportunityRecordViewSet.as_view({'get': 'list'})) + ]