Пример #1
0
from kocherga.graphql import helpers
from kocherga.graphql.django_utils import DjangoObjectType
from kocherga.wagtail import graphql_utils as wagtail_utils

from ... import models

RatioTestimonialProduct = DjangoObjectType(
    'RatioTestimonialProduct',
    model=models.TestimonialProduct,
    db_fields=[
        'id',
        'title',
        'color',
        'link',
    ],
)

RatioTestimonial = DjangoObjectType(
    'RatioTestimonial',
    model=models.Testimonial,
    db_fields=[
        'id',
        'author_name',
        'author_description',
    ],
    extra_fields={
        'author_image':
        wagtail_utils.image_rendition_field(models.Testimonial,
                                            'author_image'),
        'text':
        wagtail_utils.richtext_field(models.Testimonial, 'text'),
Пример #2
0
from kocherga.graphql.django_utils import DjangoObjectType
from kocherga.graphql import g

from ... import models


def extra_fields():
    from .ticket import RatioTicket

    return {'ticket': g.NN(RatioTicket)}


RatioPayment = DjangoObjectType(
    'RatioPayment',
    model=models.Payment,
    db_fields=[
        'id',
        'amount',
        'payment_type',
        'status',
        'fiscalization_status',
        'comment',
        'custom_kkm_title',
    ],
    extra_fields=extra_fields,  # delay import
)
Пример #3
0
from kocherga.graphql.django_utils import DjangoObjectType

logger = logging.getLogger(__name__)

from django.utils import timezone
from kocherga.graphql import helpers

from .. import models

c = helpers.Collection()


SpecialOffer = DjangoObjectType(
    'SpecialOffer',
    model=models.SpecialOffer,
    db_fields=['id', 'text', 'link', 'button_text', 'until', 'hide_duration'],
)


@c.class_field
class specialOffer(helpers.BaseField):
    def resolve(self, _, info):
        try:
            result = models.SpecialOffer.objects.get(pk=1, until__gt=timezone.now())
        except models.SpecialOffer.DoesNotExist:
            return None

        return result

    permissions = []
Пример #4
0
from kocherga.graphql.django_utils import DjangoObjectType
from kocherga.graphql import helpers

from ... import models

RatioPromocode = DjangoObjectType(
    'RatioPromocode',
    model=models.Promocode,
    db_fields=[
        'id',
        'code',
        'discount',
        'discount_percent',
        'uses_max',
        'uses_count',
        'for_email',
    ],
)

RatioPromocodeConnection = helpers.ConnectionType(RatioPromocode)
Пример #5
0
    result = int


@fields.class_field
class promocodes(helpers.BaseField):
    def resolve(self, obj, info, **pager):
        return models.Promocode.objects.filter(
            ticket_type_promocodes=obj.pk).relay_page(**pager)

    permissions = [user_perm('ratio.manage')]

    args = helpers.connection_args()
    result = g.NN(RatioPromocodeConnection)


RatioTicketType = DjangoObjectType(
    'RatioTicketType',
    model=models.TicketType,
    db_fields=[
        'price',
        'name',
        'discount_by_email',
        'discount_percent_by_email',
    ],
    extra_fields={
        'id': g.Field(g.NN(g.ID), resolve=lambda obj, info: obj.uuid),
        **fields.as_dict(),
    },
)
Пример #6
0
from kocherga.graphql.django_utils import DjangoObjectType
from kocherga.graphql import g, helpers

from .. import models

EmailMailchimpInterest = DjangoObjectType(
    'EmailMailchimpInterest',
    model=models.MailchimpInterest,
    db_fields=['id', 'interest_id', 'name', 'subscriber_count'],
    extra_fields=lambda: {'category': g.NN(EmailMailchimpCategory)},
)

EmailMailchimpCategory = DjangoObjectType(
    'EmailMailchimpCategory',
    model=models.MailchimpCategory,
    db_fields=['id', 'title', 'category_id'],
    related_fields={'interests': EmailMailchimpInterest},
)

EmailSubscribeChannelLog = DjangoObjectType(
    'EmailSubscribeChannelLog',
    model=models.SubscribeChannelLog,
    db_fields=['id', 'dt', 'email'],
)


def resolve_log(obj, info, **pager):
    return models.SubscribeChannelLog.objects.filter(channel=obj).relay_page(
        order='-dt', **pager)

Пример #7
0
from kocherga.graphql.django_utils import DjangoObjectType

from ... import models

EventsYoutubeVideo = DjangoObjectType(
    'EventsYoutubeVideo',
    model=models.YoutubeVideo,
    db_fields=['id', 'embed_id'],
    # TODO - event field
)