Skip to content

Commit

Permalink
stub review data until FE removes them
Browse files Browse the repository at this point in the history
  • Loading branch information
mwvolo committed Oct 16, 2024
1 parent f2053b3 commit 72296db
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 0 additions & 2 deletions salesforce/management/commands/update_partners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, " \
Expand Down
13 changes: 13 additions & 0 deletions salesforce/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ def partner_logo_tag(self):
else:
return mark_safe(u'<img src="" />')

# 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)
Expand Down
10 changes: 10 additions & 0 deletions salesforce/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()))
Expand Down
4 changes: 3 additions & 1 deletion salesforce/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}))

]

0 comments on commit 72296db

Please sign in to comment.