Beispiel #1
0
    def get_metadata_display(self, field_formats={}, escape=True):
        """Returns object metadata that has been selected to be displayed to
        users, compiled as a string.
        """
        def field_format(field):
            if field in field_formats:
                return field_formats[field]
            return u'%s'

        t = join_formatted('',
                           self.title,
                           format=field_format('title'),
                           escape=escape)
        t = join_formatted(t, self.description, u'%s: %s', escape=escape)
        if self.publish_author:
            t = join_formatted(t,
                               self.author,
                               u'%s' + u' – ' + u'Author: %s',
                               u'%s' + u'Author: %s',
                               escape=escape)
        if self.publish_copyright:
            t = join_formatted(t, self.copyright, u'%s, %s', escape=escape)
        if self.publish_date_time and self.date_time:
            date_time_formatted = dateformat.format(self.date_time,
                                                    get_format('DATE_FORMAT'))
            t = join_formatted(t,
                               date_time_formatted,
                               u'%s (%s)',
                               '%s%s',
                               escape=escape)
        return t
Beispiel #2
0
 def get_metadata_display(self, field_formats = {}, escape=True):
     """Returns object metadata that has been selected to be displayed to
     users, compiled as a string.
     """
     def field_format(field):
         if field in field_formats:
             return field_formats[field]
         return u'%s'
     t = join_formatted('', self.title, format=field_format('title'), escape=escape)
     t = join_formatted(t, self.description, u'%s: %s', escape=escape)
     if self.publish_author:
         t = join_formatted(t, self.author, u'%s' + u' – ' + u'Author: %s', u'%s' + u'Author: %s', escape=escape)
     if self.publish_copyright:
         t = join_formatted(t, self.copyright, u'%s, %s', escape=escape)
     if self.publish_date_time and self.date_time:
         date_time_formatted = dateformat.format(self.date_time, get_format('DATE_FORMAT'))
         t = join_formatted(t, date_time_formatted, u'%s (%s)', '%s%s', escape=escape)
     return t