Esempio n. 1
0
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'
Esempio n. 2
0
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'
Esempio n. 3
0
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'
Esempio n. 4
0
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'
Esempio n. 5
0
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'
Esempio n. 6
0
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'
Esempio n. 7
0
    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'
Esempio n. 8
0
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'
Esempio n. 9
0
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'
Esempio n. 10
0
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'
Esempio n. 11
0
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'
Esempio n. 12
0
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'
Esempio n. 13
0
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'
Esempio n. 14
0
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'
Esempio n. 15
0
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'
Esempio n. 16
0
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'
Esempio n. 17
0
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'
Esempio n. 18
0
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'
Esempio n. 19
0
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"
Esempio n. 20
0
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"
Esempio n. 21
0
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'
Esempio n. 22
0
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'
Esempio n. 23
0
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'
Esempio n. 24
0
    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'