[permissions.manage_events]), 'timing_description_override': helpers.field_with_permissions(g.NN(g.String), [permissions.manage_events]), 'tickets': django_utils.related_field( models.Event, 'tickets', item_type=EventsTicket, permissions=[permissions.manage_events], ), 'feedbacks': django_utils.related_field( models.Event, 'feedbacks', item_type=EventsFeedback, permissions=[permissions.manage_events], ), 'youtube_videos': django_utils.related_field( models.Event, 'youtube_videos', item_type=EventsYoutubeVideo, ), }) Event = g.ObjectType('Event', fields=build_event_fields) EventConnection = helpers.ConnectionType(Event)
from typing import Optional from kocherga.graphql import g, helpers from .event import Event MyEventsTicket = g.ObjectType( 'MyEventsTicket', g.fields({ 'id': g.Field(g.NN(g.ID), resolve=lambda obj, info: obj.event.uuid), 'event': g.NN(Event), 'status': str, 'created': Optional[str], 'zoom_link': Optional[str], }), ) MyEventsTicketConnection = helpers.ConnectionType(MyEventsTicket)
'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'), 'product': RatioTestimonialProduct, }, ) RatioTestimonialConnection = helpers.ConnectionType(RatioTestimonial)
from kocherga.graphql import g, helpers, django_utils from kocherga.auth.schema.types import AuthUser from ... import models CashierPayment = django_utils.DjangoObjectType( 'CashierPayment', model=models.Payment, db_fields=['id', 'amount', 'created_dt', 'redeem_dt', 'comment'], method_fields=['is_redeemed'], extra_fields={'whom': g.NN(AuthUser)}, ) CashierPaymentConnection = helpers.ConnectionType(CashierPayment)
from typing import Optional from kocherga.graphql import g, helpers Cm2Order = g.ObjectType( 'Cm2Order', fields=lambda: g.fields({ 'id': 'ID!', 'start': str, 'end': Optional[str], 'customer': Cm2Customer, 'value': int, }), ) Cm2OrderConnection = helpers.ConnectionType(Cm2Order) def resolve_Cm2Customer_orders(obj, info, **pager): return obj.orders.filter_by_customer_id(obj.pk).relay_page(**pager) Cm2Customer = g.ObjectType( 'Cm2Customer', g.fields({ 'id': 'ID!', 'card_id': int, 'first_name': str,
'check_type', ], extra_fields={ 'created': g.Field( g.NN(g.String), resolve=lambda obj, info: datetime.datetime.fromtimestamp( obj.timestamp), ), }, related_fields=lambda: { 'items': OfdDocumentItem, }, ) OfdDocumentConnection = helpers.ConnectionType(OfdDocument) OfdDocumentItem = django_utils.DjangoObjectType( 'OfdDocumentItem', model=models.OfdDocumentItem, db_fields=[ 'id', 'name', 'quantity', 'price', 'sum', 'product_type', 'payment_type', ], )
model=models.Lead, db_fields=['id', 'name', 'description', 'created', 'updated'], related_fields=lambda: { 'events': event_types.Event, 'initiatives': CommunityInitiative, }, extra_fields={ 'created_by': auth_types.AuthUser, 'curated_by': auth_types.AuthUser, 'status': g.NN(CommunityLeadStatus), **build_commentable_fields(permissions=[permissions.manage_crm]), }, interfaces=[comment_types.Commentable], ) CommunityLeadConnection = helpers.ConnectionType(CommunityLead) # -------------------- CommunityInitiativeStatus = g.EnumType('CommunityInitiativeStatus', models.Initiative.Status) CommunityInitiative = django_utils.DjangoObjectType( 'CommunityInitiative', model=models.Initiative, db_fields=['id', 'title', 'description', 'created', 'updated'], related_fields={ 'leads': CommunityLead, }, extra_fields={ 'created_by': auth_types.AuthUser,
extra_fields=lambda: { 'record': record_field(), 'id': g.Field(g.NN(g.ID), resolve=lambda obj, info: obj.call_id), }, ) def record_field(): def resolve(obj, info): return obj.record.url if obj.record else None return g.Field(g.String, resolve=resolve) ZadarmaData = g.ObjectType('ZadarmaData', fields=g.fields( {'staff_member': staff_types.StaffMember})) ZadarmaPbxCall = django_utils.DjangoObjectType( 'ZadarmaPbxCall', model=models.PbxCall, db_fields=['pbx_call_id', 'ts'], related_fields={'calls': ZadarmaCall}, extra_fields={ 'data': ZadarmaData, 'id': g.Field(g.NN(g.ID), resolve=lambda obj, info: obj.pbx_call_id), }, ) ZadarmaPbxCallConnection = helpers.ConnectionType(ZadarmaPbxCall)
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)
args = helpers.connection_args() result = g.NN(RatioPromocodeConnection) RatioTraining = django_utils.DjangoObjectType( 'RatioTraining', model=models.Training, db_fields=[ 'id', 'name', 'slug', 'training_type', 'date', 'telegram_link', 'salaries_paid', 'discount_by_email', 'discount_percent_by_email', 'promocode_email', 'new_ticket_email', 'notion_created_email', ], related_fields=related_fields, method_fields=['tickets_count', 'total_income'], extra_fields={ **fields.as_dict(), }, ) RatioTrainingConnection = helpers.ConnectionType(RatioTraining)
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) EmailSubscribeChannelLogConnection = helpers.ConnectionType( EmailSubscribeChannelLog) EmailSubscribeChannel = DjangoObjectType( 'EmailSubscribeChannel', model=models.SubscribeChannel, db_fields=['id', 'slug'], related_fields=lambda: {'interests': EmailMailchimpInterest}, extra_fields=lambda: { 'log': helpers.ConnectionField(g.NN(EmailSubscribeChannelLogConnection), resolve=resolve_log) }, )