Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.
Open
5 changes: 4 additions & 1 deletion wavepool/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def teaser(self):

@property
def source_divesite_name(self):
return 'Industry Dive'
# Implementation based on naive assumption that URL is in a
# <protocol>://www.<hostname>.xyz/asdf-asdf-asdf format
hostname = self.source.split('/')[2].split('.')[1]
return DIVESITE_SOURCE_NAMES[hostname]
Comment on lines +35 to +38
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source_divesite_name was hardcoded before. I have modified this to resolve the hostname from the URL and then return the lookup from DIVESITE_SOURCE_NAMES

Copy link
Author

@codein codein Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really like and prefer an implementation similar to ref in branch set_coverstory_for_front_page

    def source_divesite_name(self):
        return 'Industry Dive'
        """ Return the real divesite source name for the newspost's source
        """
        source_dive = 'Industry Dive'

        url_parts = self.source.split('/')
        dive_domain = url_parts[2]
        domain_parts = dive_domain.split('.')
        dive_domain = domain_parts[1]
        if dive_domain in DIVESITE_SOURCE_NAMES:
            return DIVESITE_SOURCE_NAMES[dive_domain]
        return source_dive

However i didn't want to just copy it


def tags(self):
return [
Expand Down