Пример #1
0
class ratioOrders(helpers.BaseField):
    def resolve(self, _, info, **pager):
        return models.Order.objects.relay_page(order='-created', **pager)

    permissions = PERMISSIONS
    args = helpers.connection_args()
    result = g.NN(types.RatioOrderConnection)
Пример #2
0
class cashierPayments(helpers.BaseField):
    permissions = [staffonly]
    args = helpers.connection_args()
    result = g.NN(CashierPaymentConnection)

    def resolve(self, _, info, **pager):
        return models.Payment.objects.relay_page(**pager)  # FIXME - order
Пример #3
0
class ofdDocuments(helpers.BaseField):
    def resolve(self, _, info, **pager):
        return models.OfdDocument.objects.relay_page(**pager)

    permissions = [user_perm('kkm.ofd')]

    args = helpers.connection_args()
    result = g.NN(types.OfdDocumentConnection)
Пример #4
0
class ratioTestimonials(helpers.BaseField):
    def resolve(self, _, info, **pager):
        return models.Testimonial.objects.select_related('product').relay_page(
            **pager)

    permissions = []
    args = helpers.connection_args()
    result = g.NN(types.RatioTestimonialConnection)
Пример #5
0
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)
Пример #6
0
class cm2Orders(helpers.BaseField):
    permissions = [staffonly]
    args = {'status': Optional[str], **helpers.connection_args()}
    result = g.NN(types.Cm2OrderConnection)

    def resolve(self, _, info, status=None, **pager):
        qs = models.Order.objects.all()
        if status:
            qs = qs.filter_by_status(status)
        return qs.relay_page(**pager)
Пример #7
0
class cm2Customers(helpers.BaseField):
    permissions = [staffonly]
    args = {'search': Optional[str], **helpers.connection_args()}
    result = g.NN(types.Cm2CustomerConnection)

    def resolve(self, obj, info, search=None, **pager):
        qs = models.Customer.objects.all()
        if search:
            qs = qs.search(search)
        return qs.relay_page(**pager)
Пример #8
0
class zadarmaPbxCalls(helpers.BaseField):
    permissions = [staffonly]
    args = helpers.connection_args()
    result = g.NN(types.ZadarmaPbxCallConnection)

    def resolve(self, _, info, **pager):
        qs = models.PbxCall.objects.all()
        if not info.context.user.has_perm('zadarma.admin'):
            qs = qs.filter(data__staff_member__user__pk=info.context.user.pk)

        return qs.relay_page(order='-ts', **pager)
Пример #9
0
class ofdShifts(helpers.BaseField):
    def resolve(self, _, info, filter=None, **pager):
        qs = models.OfdShift.objects.all()
        if filter:
            if filter.get('open_only'):
                qs = qs.filter(close_dt__isnull=True)
        return qs.relay_page(**pager)

    permissions = [user_perm('kkm.ofd')]

    FilterInput = g.InputObjectType(
        'OfdShiftsFilterInput', g.input_fields({'open_only': Optional[bool]}))
    args = {**helpers.connection_args(), 'filter': FilterInput}
    result = g.NN(types.OfdShiftConnection)
Пример #10
0
class ratioTrainings(helpers.BaseField):
    def resolve(self, _, info, filter=None, **pager):
        qs = models.Training.objects.all()
        if filter:
            if 'eternal' in filter:
                qs = qs.filter(date__isnull=filter['eternal'])
        return qs.relay_page(**pager)

    permissions = PERMISSIONS

    FilterInput = g.InputObjectType(
        'RatioTrainingsFilterInput',
        g.input_fields({'eternal': Optional[bool]}))
    args = {**helpers.connection_args(), 'filter': FilterInput}

    result = g.NN(types.RatioTrainingConnection)
Пример #11
0
class publicEvents(helpers.BaseField):
    def resolve(self, obj, info, from_date=None, project_id=None, **pager):
        qs = models.Event.objects.public_only()
        if from_date:
            qs = qs.filter_by_period(
                from_date=datetime.strptime(from_date, '%Y-%m-%d').date()
            )

        if project_id is not None:
            qs = qs.filter(project_id=project_id)

        return qs.relay_page(order='start', **pager)

    permissions = []
    args = {**helpers.connection_args(), 'from_date': Optional[str], 'project_id': 'ID'}

    result = g.NN(types.EventConnection)
Пример #12
0
class tickets(helpers.BaseField):
    permissions = [authenticated]
    args = helpers.connection_args()
    result = g.NN(types.MyEventsTicketConnection)

    def resolve(self, _, info, **pager):
        # TODO - move to models' manager
        qs = models.Ticket.objects.filter(
            user=info.context.user,
            # only future tickets are supported for now
            event__start__gte=datetime.combine(datetime.today().date(),
                                               time.min,
                                               tzinfo=TZ),
            status='ok',
        )

        return qs.relay_page(**pager, order='event__start')
Пример #13
0
class communityInitiatives(helpers.BaseField):
    def resolve(self, _, info, filter=None, **pager):
        qs = models.Initiative.objects.all()
        if filter:
            if filter.get('status'):
                qs = qs.filter(status=filter['status'])
        return qs.relay_page(**pager)

    permissions = [permissions.manage_crm]

    FilterInput = g.InputObjectType(
        'CommunityInitiativesFilterInput',
        g.input_fields({
            'status': types.CommunityInitiativeStatus,
        }),
    )
    args = {**helpers.connection_args(), 'filter': FilterInput}
    result = g.NN(types.CommunityInitiativeConnection)
Пример #14
0
class communityLeads(helpers.BaseField):
    def resolve(self, _, info, filter=None, **pager):
        qs = models.Lead.objects.all()
        if filter:
            if filter.get('status'):
                qs = qs.filter(status=filter['status'])
            if filter.get('curated_by_me'):
                qs = qs.filter(curated_by=info.context.user)
            if filter.get('curated_by_empty'):
                qs = qs.filter(curated_by__isnull=True)

        if filter and filter.get('search'):
            s = get_search_backend()
            nodes = list(s.search(filter['search'], qs))
            return RelayConnection(
                pageInfo=PageInfo(
                    hasPreviousPage=False,
                    hasNextPage=False,
                    startCursor='search',
                    endCursor='search',
                ),
                nodes=nodes,
                edges=[{
                    'node': node
                } for node in nodes],
            )

        return qs.relay_page(**pager)

    permissions = [permissions.manage_crm]

    FilterInput = g.InputObjectType(
        'CommunityLeadsFilterInput',
        g.input_fields({
            'status': types.CommunityLeadStatus,
            'curated_by_me': Optional[bool],
            'curated_by_empty': Optional[bool],
            'search': Optional[str],
        }),
    )
    args = {**helpers.connection_args(), 'filter': FilterInput}
    result = g.NN(types.CommunityLeadConnection)
Пример #15
0
class ratioTickets(helpers.BaseField):
    def resolve(self, _, info, filter=None, **pager):
        qs = models.Ticket.objects.all()
        if filter:
            if filter.get('with_missing_payments', False):
                qs = qs.with_missing_payments()
            if filter.get('with_unfiscalized_checks', False):
                qs = qs.with_unfiscalized_checks()
            if filter.get('without_notion_link', False):
                qs = qs.without_notion_link()
        return qs.relay_page(**pager)

    permissions = PERMISSIONS
    FilterInput = g.InputObjectType(
        'RatioTicketsFilterInput',
        g.input_fields({
            'with_missing_payments': Optional[bool],
            'with_unfiscalized_checks': Optional[bool],
            'without_notion_link': Optional[bool],
        }),
    )
    args = {**helpers.connection_args(), 'filter': FilterInput}
    result = g.NN(types.RatioTicketConnection)