Esempio n. 1
0
 def radio_choices(self, s):
     people, dummy = search_people(s, use_distance=False)
     choices = []
     p = ''
     for p in people:
         last_production = p.productions.extra(select={'best_date': 'IFNULL(productions_place.press_date, IF(productions_place.end_date!="", productions_place.end_date, productions_place.start_date))'}).order_by('-best_date', 'place__press_date')[:1]
         if len(last_production):
             part = last_production[0].part_set.filter(person=p)[:1]
             if len(part):
                 part = part[0].role
             else:
                 part = 'unknown'
             last = u'last in %s as %s' % (last_production[0], part)
         else:
             last_play = p.plays.order_by('-id')[:1]
             if len(last_play):
                 last = 'author of %s' % last_play[0].get_title_display()
             else:
                 last = 'nothing yet on this site'
         choices.append( (p.id, prettify(mark_safe('<a target="_blank" href="' + p.get_absolute_url() + '">' + unicode(p) + '</a> <small>(new window)</small>, ' + unicode(last))) ) )
     if len(choices) > 1:
         choices.append( ( 'new', prettify('None of these, a new person called \'' + s + '\'') ) )
     elif unicode(p) == s:
         choices.append( ( 'new', prettify('A new person also called \'' + s + '\'') ) )
     else:
         return []
     choices.append( ( 'back', 'I misspelled, and will enter a new name below:' ) )
     return choices
Esempio n. 2
0
    def play_radio_choices(self, s):
        choices = []
        p = ''

        # For database order of articles
        m = re.match('(?i)^(A|An|The) (.*)$', s)
        if m:
            article, rest = m.groups()
            q = Q(title__iendswith=' %s' % article, title__istartswith=rest)
        else:
            q = Q(title__icontains=s)

        for p in Play.objects.filter(q):
            choices.append((p.id, prettify(str(p))))
        if len(choices) > 1:
            choices.append(
                ('new',
                 prettify('None of these, a new play called \'' + s + '\'')))
        elif str(p) == s:
            choices.append(
                ('new', prettify('A new play also called \'' + s + '\'')))
        else:
            choices.append(
                ('new', prettify('A new play called \'' + s + '\'')))
        choices.append(
            ('back', 'I misspelled, and will enter a new title below:'))
        return choices
Esempio n. 3
0
 def radio_choices(self, s):
     people, dummy = search_people(s, use_distance=False)
     choices = []
     p = ''
     for p in people:
         last_production = p.productions.extra(
             select={
                 'best_date':
                 'IFNULL(productions_place.press_date, IF(productions_place.end_date!="", productions_place.end_date, productions_place.start_date))'
             }).order_by('-best_date', 'place__press_date')[:1]
         if len(last_production):
             part = last_production[0].part_set.filter(person=p)[:1]
             if len(part):
                 part = part[0].role
             else:
                 part = 'unknown'
             last = u'last in %s as %s' % (last_production[0], part)
         else:
             last_play = p.plays.order_by('-id')[:1]
             if len(last_play):
                 last = 'author of %s' % last_play[0].get_title_display()
             else:
                 last = 'nothing yet on this site'
         choices.append(
             (p.id,
              prettify(
                  mark_safe('<a target="_blank" href="' +
                            p.get_absolute_url() + '">' + str(p) +
                            '</a> <small>(new window)</small>, ' +
                            str(last)))))
     if len(choices) > 1:
         choices.append(
             ('new',
              prettify('None of these, a new person called \'' + s + '\'')))
     elif str(p) == s:
         choices.append(
             ('new', prettify('A new person also called \'' + s + '\'')))
     else:
         choices.append(
             ('new', prettify('A new person called \'' + s + '\'')))
     choices.append(
         ('back', 'I misspelled, and will enter a new name below:'))
     return choices
Esempio n. 4
0
    def play_radio_choices(self, s):
        choices = []
        p = ''

        # For database order of articles
        m = re.match('^(A|An|The) (.*)$(?i)', s)
        if m:
            article, rest = m.groups()
            q = Q(title__iendswith=' %s' % article, title__istartswith=rest)
        else:
            q = Q(title__icontains=s)

        for p in Play.objects.filter(q):
            choices.append( ( p.id, prettify(unicode(p)) ) )
        if len(choices) > 1:
            choices.append( ( 'new', prettify('None of these, a new play called \'' + s + '\'') ) )
        elif unicode(p) == s:
            choices.append( ( 'new', prettify('A new play also called \'' + s + '\'') ) )
        else:
            choices.append( ( 'new', prettify('A new play called \'' + s + '\'') ) )
        choices.append( ( 'back', 'I misspelled, and will enter a new title below:' ) )
        return choices
Esempio n. 5
0
 def get_companies_display(self, html=True):
     companies = self._get_companies()
     num = len(companies)
     if html:
         companies = [
             '<span itemscope itemtype="http://schema.org/TheaterGroup"><a itemprop="url" href="%s">%s</a></span>'
             % (x.get_absolute_url(), prettify(x)) for x in companies
         ]
     else:
         companies = [str(x) for x in companies]
     if num > 2:
         s = u', '.join(companies[:num - 2]) + u', ' + u', and '.join(
             companies[num - 2:])
     elif num == 2:
         s = u' and '.join(companies)
     elif num == 1:
         s = companies[0]
     else:
         s = u''
     return mark_safe(s)
Esempio n. 6
0
 def get_authors_display(self, html=True):
     num = self.authors.count()
     if html:
         authors = [
             '<span itemprop="author" itemscope itemtype="http://schema.org/Person"><a itemprop="url" href="%s">%s</a></span>'
             % (x.get_absolute_url(), prettify(x))
             for x in self.authors.all()
         ]
     else:
         authors = [str(x) for x in self.authors.all()]
     if num > 2:
         s = u', '.join(authors[:num - 2]) + u', ' + u', and '.join(
             authors[num - 2:])
     elif num == 2:
         s = u' and '.join(authors)
     elif num == 1:
         s = authors[0]
     else:
         s = u''
     return mark_safe(s)
Esempio n. 7
0
 def get_companies_display(self, html=True):
     companies = self._get_companies()
     num = len(companies)
     if html:
         companies = map(lambda x: u'<span itemscope itemtype="http://schema.org/TheaterGroup"><a itemprop="url" href="%s">%s</a></span>' % (x.get_absolute_url(), prettify(x)), companies)
     else:
         companies = [ unicode(x) for x in companies ]
     if num > 2:
         str = u', '.join(companies[:num-2]) + u', ' + u', and '.join(companies[num-2:])
     elif num == 2:
         str = u' and '.join(companies)
     elif num == 1:
         str = companies[0]
     else:
         str = u''
     return mark_safe(str)
Esempio n. 8
0
 def get_authors_display(self, html=True):
     num = self.authors.count()
     if html:
         authors = map(lambda x: u'<span itemprop="author" itemscope itemtype="http://schema.org/Person"><a itemprop="url" href="%s">%s</a></span>' % (x.get_absolute_url(), prettify(x)), self.authors.all())
     else:
         authors = [ unicode(x) for x in self.authors.all() ]
     if num > 2:
         str = u', '.join(authors[:num-2]) + u', ' + u', and '.join(authors[num-2:])
     elif num == 2:
         str = u' and '.join(authors)
     elif num == 1:
         str = authors[0]
     else:
         str = u''
     return mark_safe(str)