def get_ticket_table(tickets: QuerySet[EventTicket]): ticket_dicts = [ { 'ref_link': link_to_admin_change_form(ticket, text=ticket.pk), 'user_name_link': link_to_admin_change_form(ticket.user, text=ticket.name) if ticket.user else "-", 'user_email': ticket.email, 'comment': ticket.comment, 'language': ticket.get_language_display(), } for ticket in tickets.select_related('user') ] return get_template('admin/news/event/change_form_ticket_table.html').render({ 'ticket_dicts': ticket_dicts, })
def get_categories(self, question: Question): category_strings = [ link_to_admin_change_form(category) for category in question.categories.all() ] return html_utils.block_join(category_strings, sep="<b>•</b>") or None
def get_last_occurrence(self, event: Event): if not event.past_time_places: return None last_occurrence = event.past_time_places[0] occurrence_string = link_to_admin_change_form(last_occurrence, text=short_datetime_format(last_occurrence.start_time)) # Use `block_join()` to format the rendered occurrence string in the same way as the other columns return html_utils.block_join([occurrence_string], sep="")
def get_number_of_tickets(self, event: Event): if event.standalone: return f"{event.ticket_count}/{event.number_of_tickets}" else: time_place_ticket_strings = [ mark_safe( f"{time_place.ticket_count}/{time_place.number_of_tickets} " + link_to_admin_change_form(time_place, text=f"({short_datetime_format(time_place.start_time)})") ) for time_place in event.existing_time_places ] if len(time_place_ticket_strings) > self.MAX_TICKET_OCCURRENCES_LISTED: truncated_strings_count = len(time_place_ticket_strings[self.MAX_TICKET_OCCURRENCES_LISTED:]) time_place_ticket_strings = time_place_ticket_strings[:self.MAX_TICKET_OCCURRENCES_LISTED] time_place_ticket_strings.append(_("{count} more...").format(count=truncated_strings_count)) return html_utils.block_join(time_place_ticket_strings, sep="<b>•</b>") or None
def get_event(self, ticket: EventTicket): return link_to_admin_change_form(ticket.event) if ticket.event else None
def get_timeplace(self, ticket: EventTicket): return link_to_admin_change_form(ticket.timeplace) if ticket.timeplace else None
def get_user(self, ticket: EventTicket): return link_to_admin_change_form(ticket.user, text=ticket.name or ticket.user)
def get_event(self, time_place: TimePlace): return link_to_admin_change_form(time_place.event)
def get_future_occurrences(self, event: Event): occurrence_strings = [ link_to_admin_change_form(time_place, text=short_datetime_format(time_place.start_time)) for time_place in event.future_time_places ] return html_utils.block_join(occurrence_strings, sep="<b>•</b>") or None