def poc_link(instance): if instance: pocs = Prodoptchoice.objects.filter(productoption=instance) c = pocs.count() if c: if c == 1: poc = pocs[0] return link( poc.choice.name, href='/admin/products/choice/%s' % poc.choice. id, # could double-check this matches defaultchocie, here title= "Go to the choice referenced by this prodopt's legacy POCs: %s" % instance) else: return link( "%s choices / POCs" % c, href= '/admin/products/choice/?prodoptchoice__productoption=%s' % instance.id, title= 'Go to the list of choices which are referenced by the prodoptchoices for this prodopt: %s :\n%s' % (instance, '\n'.join( pocs.values_list('choice__name', flat=True)))) return 'None'
def choice_refs (instance): if instance: choices = instance.choice_set c = choices.count() if c: if c==1: choice = choices.all() [0] return link (choice.name, href='/admin/products/choice/%s' % choice.id, title='Go to this choice: %s' % choice) else: return link ("%s choice%s" % (c, '' if c==1 else 's'), href='/admin/products/choice/?choicecategory__id__exact=%s' % instance.id, title='Go to the list of these choices: ' + '\n'.join (escape (v) for v in choices.values_list('name', flat=True))) return 'None'
def product_link(instance): if instance: product = instance.product # Prodopt.objects.get (product=instance.product) return link(product.sku, href='/admin/products/product/%s' % product.id, title='Go to the product for this ProdOpt: %s' % product) return 'None'
def prodopt_refs (instance): if instance: pos = Prodopt.objects.filter (choices=instance, product__published=True) c = pos.count() if c: if c==1: po = pos[0] return link (po.calc_name, href='/admin/products/prodopt/%s' % po.id, title='Go to the prodopt which references this choice: %s' % po) else: return link ("%s prodopts" % c, href='/admin/products/prodopt/?choices__id__exact=%s' % instance.id, title='Go to the list of prodopts which reference this choice' ) return 'None'
def poc_count (instance): if instance: pocs = Prodoptchoice.objects.filter (choice=instance, productoption__product__published=True) c = pocs.count() if c: if c==1: poc = pocs[0] return link (poc, href='/admin/products/prodoptchoice/%s' % poc.id, title='Used to go to the prodoptchoice - deprecated') else: return link ("%s poc's" % c, href='/admin/products/prodoptchoice/?choice__id__exact=%s' % instance.id, title='Used to go to the list of these prodoptchoices - deprecated') return 'None'
def default_refs (instance): if instance: pos = Prodopt.objects.filter (defaultchoice=instance, product__published=True) c = pos.count() if c: if c==1: po = pos[0] return link (po.calc_name, href='/admin/products/prodopt/%s' % po.id, title='Go to the prodopt for this choice: %s' % po) else: return link ('%s defaults' % c, href='/admin/products/prodopt/?defaultchoice__id__exact=%s' % instance.id, title='Go to prodopts that have this default choice') return 'None'
def choices_link (self, instance): if instance: choices = instance.choices.all() c = choices.count() if c: if c==1: choice = choices[0] return link (choice.name, href='/admin/products/choice/%s' % choice.id, # could double-check this matches defaultchoice, here title='Go to the choice referenced by this prodopt: %s' % instance) else: return link ("%s choices" % c, href='/admin/products/choice/?options__id__exact=%s' % instance.id, title="Go to the list of choices which are referenced by this option: %s :\n%s" % (instance, '\n'.join (choices.values_list ('name', flat=True)))) return 'None'
def poc_link (instance): if instance: pocs = Prodoptchoice.objects.filter (productoption=instance) c = pocs.count() if c: if c==1: poc = pocs[0] return link (poc.choice.name, href='/admin/products/choice/%s' % poc.choice.id, # could double-check this matches defaultchocie, here title="Go to the choice referenced by this prodopt's legacy POCs: %s" % instance) else: return link ("%s choices / POCs" % c, href='/admin/products/choice/?prodoptchoice__productoption=%s' % instance.id, title='Go to the list of choices which are referenced by the prodoptchoices for this prodopt: %s :\n%s' % (instance, '\n'.join (pocs.values_list ('choice__name', flat=True)))) return 'None'
def product_link (instance): if instance: product = instance.product # Prodopt.objects.get (product=instance.product) return link (product.sku, href='/admin/products/product/%s' % product.id, title='Go to the product for this ProdOpt: %s' % product) return 'None'
def option_link (instance): if instance: option = instance.option # Prodopt.objects.get (option=instance.option) return link (option.name, href='/admin/products/option/%s' % option.id, title='Go to the option for this ProdOpt: %s' % option) return 'None'
def customer_link (instance): if instance: cust = instance.customer return link (cust, href='/admin/customers/customer/%s' % cust.id, title='Go to the customer for Order #%s: %s' % (instance.id, cust)) return 'None'
def option_link(instance): if instance: option = instance.option # Prodopt.objects.get (option=instance.option) return link(option.name, href='/admin/products/option/%s' % option.id, title='Go to the option for this ProdOpt: %s' % option) return 'None'
def option_refs (instance): if instance: options = Option.objects.filter (choices=instance) # , productoption__product__published=True) c = options.count() if c: if c==1: option = options [0] return link (option.name, href='/admin/products/option/%s' % option.id, title='Go to the option which references this choice: %s' % option) else: return link ("%s option%s" % (c, '' if c==1 else 's'), href='/admin/products/option/?choices__id__exact=%s' % instance.id, title='Go to the list of these options') return 'None'
def customer_link(instance): if instance: cust = instance.customer return link(cust, href='/admin/customers/customer/%s' % cust.id, title='Go to the customer for Order #%s: %s' % (instance.id, cust)) return 'None'
def default_refs(instance): if instance: pos = Prodopt.objects.filter(defaultchoice=instance, product__published=True) c = pos.count() if c: if c == 1: po = pos[0] return link(po.calc_name, href='/admin/products/prodopt/%s' % po.id, title='Go to the prodopt for this choice: %s' % po) else: return link( '%s defaults' % c, href='/admin/products/prodopt/?defaultchoice__id__exact=%s' % instance.id, title='Go to prodopts that have this default choice') return 'None'
def choice_refs(instance): if instance: choices = instance.choice_set c = choices.count() if c: if c == 1: choice = choices.all()[0] return link(choice.name, href='/admin/products/choice/%s' % choice.id, title='Go to this choice: %s' % choice) else: return link( "%s choice%s" % (c, '' if c == 1 else 's'), href='/admin/products/choice/?choicecategory__id__exact=%s' % instance.id, title='Go to the list of these choices: ' + '\n'.join( escape(v) for v in choices.values_list('name', flat=True))) return 'None'
def prodopt_refs(instance): if instance: pos = Prodopt.objects.filter(choices=instance, product__published=True) c = pos.count() if c: if c == 1: po = pos[0] return link( po.calc_name, href='/admin/products/prodopt/%s' % po.id, title='Go to the prodopt which references this choice: %s' % po) else: return link( "%s prodopts" % c, href='/admin/products/prodopt/?choices__id__exact=%s' % instance.id, title= 'Go to the list of prodopts which reference this choice') return 'None'
def option_refs(instance): if instance: options = Option.objects.filter( choices=instance) # , productoption__product__published=True) c = options.count() if c: if c == 1: option = options[0] return link( option.name, href='/admin/products/option/%s' % option.id, title='Go to the option which references this choice: %s' % option) else: return link( "%s option%s" % (c, '' if c == 1 else 's'), href='/admin/products/option/?choices__id__exact=%s' % instance.id, title='Go to the list of these options') return 'None'
def is_default_count(instance): if instance: pos = Prodopt.objects.filter(defaultchoice=instance, product__published=True) c = pos.count() if c: return link( "%s defaults" % c, href="/admin/legacy/prodopt/?defaultchoice__id__exact=%s" % instance.id, title="Go to prodopts for these default choices", ) return "None"
def poc_count(instance): if instance: pocs = Prodoptchoice.objects.filter(choice=instance, productoption__product__published=True) c = pocs.count() if c: return link( "%s poc's" % c, href="/admin/legacy/prodoptchoice/?choice__id__exact=%s" % instance.id, title="Go to the list of these prodoptchoices", ) return "None"
def is_default_count(instance): if instance: pos = Prodopt.objects.filter(defaultchoice=instance, product__published=True) c = pos.count() if c: return link( '%s defaults' % c, href='/admin/legacy/prodopt/?defaultchoice__id__exact=%s' % instance.id, title='Go to prodopts for these default choices') return 'None'
def poc_count(instance): if instance: pocs = Prodoptchoice.objects.filter( choice=instance, productoption__product__published=True) c = pocs.count() if c: if c == 1: poc = pocs[0] return link( poc, href='/admin/products/prodoptchoice/%s' % poc.id, title='Used to go to the prodoptchoice - deprecated') else: return link( "%s poc's" % c, href='/admin/products/prodoptchoice/?choice__id__exact=%s' % instance.id, title= 'Used to go to the list of these prodoptchoices - deprecated' ) return 'None'
def poc_count(instance): if instance: pocs = Prodoptchoice.objects.filter( choice=instance, productoption__product__published=True) c = pocs.count() if c: return link( "%s poc's" % c, href='/admin/legacy/prodoptchoice/?choice__id__exact=%s' % instance.id, title='Go to the list of these prodoptchoices') return 'None'
def choices_link(self, instance): if instance: choices = instance.choices.all() c = choices.count() if c: if c == 1: choice = choices[0] return link( choice.name, href='/admin/products/choice/%s' % choice. id, # could double-check this matches defaultchoice, here title='Go to the choice referenced by this prodopt: %s' % instance) else: return link( "%s choices" % c, href='/admin/products/choice/?options__id__exact=%s' % instance.id, title= "Go to the list of choices which are referenced by this option: %s :\n%s" % (instance, '\n'.join( choices.values_list('name', flat=True)))) return 'None'