dispatch/modules/content/mixins.py
def get_author_type_string(self):
        """Returns list of authors as a comma-separated string
        sorted by author type (with 'and' before last author)."""

        authorTypeString = ''
        aStringA = ''
        aStringB = ''
        aStringC = ''
        aStringD = ''

        authors = dict((k, list(v)) for k, v in groupby(self.authors.all(), lambda a: a.type))
        for author in authors:
            if author == 'author':
                aStringA += 'Written by ' + self.get_author_string(authors['author'])
            if author == 'photographer':
                aStringB += 'Photos by ' + self.get_author_string(authors['photographer'])
            if author == 'illustrator':
                aStringC += 'Illustrations by ' + self.get_author_string(authors['illustrator'])
            if author == 'videographer':
                aStringD += 'Videos by ' + self.get_author_string(authors['videographer'])
        if aStringA != '':
            authorTypeString += aStringA
        if aStringB != '':
            authorTypeString += ', ' + aStringB
        if aStringC != '':
            authorTypeString += ', ' + aStringC
        if aStringD != '':
            authorTypeString += ', ' + aStringD
        return authorTypeString
def get_author_type_string(self):
        """Returns list of authors as a comma-separated string
        sorted by author type (with 'and' before last author)."""

        authorTypeString = ''
        aStringA = ''
        aStringB = ''
        aStringC = ''
        aStringD = ''

        authors = dict((k, list(v)) for k, v in groupby(self.authors.all(), lambda a: a.type))
        for author in authors:
            if author == 'author':
                aStringA += 'Written by ' + self.get_author_string(authors['author'])
            if author == 'photographer':
                aStringB += 'Photos by ' + self.get_author_string(authors['photographer'])
            if author == 'illustrator':
                aStringC += 'Illustrations by ' + self.get_author_string(authors['illustrator'])
            if author == 'videographer':
                aStringD += 'Videos by ' + self.get_author_string(authors['videographer'])
        if aStringA != '':
            authorTypeString += aStringA
        if aStringB != '':
            authorTypeString += ', ' + aStringB
        if aStringC != '':
            authorTypeString += ', ' + aStringC
        if aStringD != '':
            authorTypeString += ', ' + aStringD
        return authorTypeString
def get_author_type_string ( self ) : authorTypeString = '' aStringA = '' aStringB = '' aStringC = '' aStringD = '' authors = dict ( ( k , list ( v ) ) for k , v in groupby ( self . authors . all ( ) , lambda a : a . type ) ) for author in authors : if author == 'author' : aStringA += 'Written by ' + self . get_author_string ( authors [ 'author' ] ) if author == 'photographer' : aStringB += 'Photos by ' + self . get_author_string ( authors [ 'photographer' ] ) if author == 'illustrator' : aStringC += 'Illustrations by ' + self . get_author_string ( authors [ 'illustrator' ] ) if author == 'videographer' : aStringD += 'Videos by ' + self . get_author_string ( authors [ 'videographer' ] ) if aStringA != '' : authorTypeString += aStringA if aStringB != '' : authorTypeString += ', ' + aStringB if aStringC != '' : authorTypeString += ', ' + aStringC if aStringD != '' : authorTypeString += ', ' + aStringD return authorTypeString
Returns list of authors as a comma-separated string
        sorted by author type (with 'and' before last author).
Returns list of authors as a comma - separated string sorted by author type ( with and before last author ) .