def display_object(self): from . import Order, Voucher, Quota, Item, ItemCategory, Question, Event, TaxRule, SubEvent if self.content_type.model_class() is Event: return '' co = self.content_object a_map = None a_text = None if isinstance(co, Order): a_text = _('Order {val}') a_map = { 'href': reverse('control:event.order', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'code': co.code }), 'val': escape(co.code), } elif isinstance(co, Voucher): a_text = _('Voucher {val}…') a_map = { 'href': reverse('control:event.voucher', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'voucher': co.id }), 'val': escape(co.code[:6]), } elif isinstance(co, Item): a_text = _('Product {val}') a_map = { 'href': reverse('control:event.item', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'item': co.id }), 'val': escape(co.name), } elif isinstance(co, SubEvent): a_text = pgettext_lazy('subevent', 'Date {val}') a_map = { 'href': reverse('control:event.subevent', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'subevent': co.id }), 'val': escape(str(co)) } elif isinstance(co, Quota): a_text = _('Quota {val}') a_map = { 'href': reverse('control:event.items.quotas.show', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'quota': co.id }), 'val': escape(co.name), } elif isinstance(co, ItemCategory): a_text = _('Category {val}') a_map = { 'href': reverse('control:event.items.categories.edit', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'category': co.id }), 'val': escape(co.name), } elif isinstance(co, Question): a_text = _('Question {val}') a_map = { 'href': reverse('control:event.items.questions.show', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'question': co.id }), 'val': escape(co.question), } elif isinstance(co, TaxRule): a_text = _('Tax rule {val}') a_map = { 'href': reverse('control:event.settings.tax.edit', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'rule': co.id }), 'val': escape(co.name), } if a_text and a_map: a_map['val'] = '<a href="{href}">{val}</a>'.format_map(a_map) return a_text.format_map(a_map) elif a_text: return a_text else: for receiver, response in logentry_object_link.send(self.event, logentry=self): if response: return response return ''
def display_object(self): from . import Order, Voucher, Quota, Item, ItemCategory, Question, Event, TaxRule, SubEvent try: if self.content_type.model_class() is Event: return '' co = self.content_object except: return '' a_map = None a_text = None if isinstance(co, Order): a_text = _('Order {val}') a_map = { 'href': reverse('control:event.order', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'code': co.code }), 'val': escape(co.code), } elif isinstance(co, Voucher): a_text = _('Voucher {val}…') a_map = { 'href': reverse('control:event.voucher', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'voucher': co.id }), 'val': escape(co.code[:6]), } elif isinstance(co, Item): a_text = _('Product {val}') a_map = { 'href': reverse('control:event.item', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'item': co.id }), 'val': escape(co.name), } elif isinstance(co, SubEvent): a_text = pgettext_lazy('subevent', 'Date {val}') a_map = { 'href': reverse('control:event.subevent', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'subevent': co.id }), 'val': escape(str(co)) } elif isinstance(co, Quota): a_text = _('Quota {val}') a_map = { 'href': reverse('control:event.items.quotas.show', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'quota': co.id }), 'val': escape(co.name), } elif isinstance(co, ItemCategory): a_text = _('Category {val}') a_map = { 'href': reverse('control:event.items.categories.edit', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'category': co.id }), 'val': escape(co.name), } elif isinstance(co, Question): a_text = _('Question {val}') a_map = { 'href': reverse('control:event.items.questions.show', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'question': co.id }), 'val': escape(co.question), } elif isinstance(co, TaxRule): a_text = _('Tax rule {val}') a_map = { 'href': reverse('control:event.settings.tax.edit', kwargs={ 'event': self.event.slug, 'organizer': self.event.organizer.slug, 'rule': co.id }), 'val': escape(co.name), } if a_text and a_map: a_map['val'] = '<a href="{href}">{val}</a>'.format_map(a_map) return a_text.format_map(a_map) elif a_text: return a_text else: for receiver, response in logentry_object_link.send(self.event, logentry=self): if response: return response return ''