示例#1
0
 class Arguments:
     movie_id = graphene.Int(required=True)
     movie_title = graphene.String(required=True)
     movie_cover = graphene.String()
     movie_trailer = graphene.String()
     length = graphene.Time()
     description = graphene.String()
     gallary_urls = graphene.String()
     studio = graphene.String()
     director = graphene.String()
     release_date = graphene.Date()
     genres = graphene.String()
     rating = graphene.Int()
     tags = graphene.String()
     performers = graphene.String()
示例#2
0
文件: types.py 项目: saurabh1e/saleor
class CheckoutShipping(CountableDjangoObjectType):
    delivery_date = graphene.Date(description="Date of delivery of the order.")
    time_slot = graphene.String(
        description="Time slot of the delivery of the order.")

    class Meta:
        description = "Represents shipping date of particular order."
        model = models.CheckoutShipping
        interfaces = [graphene.relay.Node]
        only_fields = [
            "id",
            "delivery_date",
            "time_slot",
        ]
        filter_fields = ["id"]
示例#3
0
class ContractUpdateInputType(OpenIMISMutation.Input):
    id = graphene.UUID(required=True)
    code = graphene.String(required=False, max_length=32)
    policy_holder_id = graphene.UUID(required=False)

    amount_notified = graphene.Decimal(max_digits=18,
                                       decimal_places=2,
                                       required=False)
    amount_rectified = graphene.Decimal(max_digits=18,
                                        decimal_places=2,
                                        required=False)
    amount_due = graphene.Decimal(max_digits=18,
                                  decimal_places=2,
                                  required=False)

    date_approved = graphene.DateTime(required=False)
    date_payment_due = graphene.Date(required=False)

    payment_reference = graphene.String(required=False)
    amendment = graphene.Int(required=False)

    date_valid_from = graphene.Date(required=False)
    date_valid_to = graphene.Date(required=False)
    json_ext = graphene.types.json.JSONString(required=False)
class CreateSinhVien(graphene.Mutation):
    id = graphene.Int()
    name = graphene.String()
    msv = graphene.String()
    lop = graphene.String()
    ngaysinh = graphene.Date()
    class Arguments:
        name = graphene.String()
        msv = graphene.String()
        lop = graphene.String()
        ngaysinh = graphene.Date()
    def mutate(self, info, name, ngaysinh, msv = "", lop = ""):
        sinhVien = SinhVien(name = name, msv = msv, lop = lop, ngaysinh = ngaysinh)
        sinhVien.save()
        return CreateSinhVien(id = sinhVien.id, name = sinhVien.name, msv = sinhVien.msv, lop = sinhVien.lop, ngaysinh = sinhVien.ngaysinh)
示例#5
0
class CollectionInput(graphene.InputObjectType):
    is_published = graphene.Boolean(
        description='Informs whether a collection is published.')
    name = graphene.String(description='Name of the collection.')
    slug = graphene.String(description='Slug of the collection.')
    description = graphene.String(
        description='Description of the collection (HTML/text).')
    description_json = graphene.JSONString(
        description='Description of the collection (JSON).')
    background_image = Upload(description='Background image file.')
    background_image_alt = graphene.String(
        description='Alt text for an image.')
    seo = SeoInput(description='Search engine optimization fields.')
    publication_date = graphene.Date(
        description='Publication date. ISO 8601 standard.')
示例#6
0
    class Arguments:
        # User fields
        user = UserInput(required=True)
        gender = GenderEnum()
        birth_date = graphene.Date()
        address = graphene.String()
        city = graphene.String()
        phone_number = graphene.String()
        state = graphene.String()
        zipcode = graphene.String()
        google_auth_enabled = graphene.Boolean()
        google_auth_email = graphene.String()

        # Admin fields
        admin_type = AdminTypeEnum(required=True)
示例#7
0
class EntryUpdateInputType(graphene.InputObjectType):
    id = graphene.ID(required=True)
    # document = Upload(required=False)
    # url = graphene.String()
    article_title = graphene.String()
    source = graphene.String()
    publisher = graphene.String()
    publish_date = graphene.Date()
    source_methodology = graphene.String()
    source_excerpt = graphene.String()
    source_breakdown = graphene.String()
    event = graphene.ID()
    idmc_analysis = graphene.String()
    methodology = graphene.String()
    tags = graphene.List(graphene.String)
    reviewers = graphene.List(graphene.ID)
示例#8
0
    class Arguments:
        # User fields
        user = UserInput(required=True)
        gender = GenderEnum()
        birth_date = graphene.Date()
        address = graphene.String()
        city = graphene.String()
        phone_number = graphene.String()
        state = graphene.String()
        zipcode = graphene.String()

        # Student fields
        grade = graphene.Int()
        school_id = graphene.ID(name='school')
        primary_parent_id = graphene.ID(name='primaryParent')
        secondary_parent_id = graphene.ID(name='secondaryParent')
示例#9
0
    class Arguments:
        # User fields
        user = UserInput(required=True)
        gender = GenderEnum()
        birth_date = graphene.Date()
        address = graphene.String()
        city = graphene.String()
        phone_number = graphene.String()
        state = graphene.String()
        zipcode = graphene.String()

        # Instructor fields
        biography = graphene.String()
        experience = graphene.String()
        language = graphene.String()
        subjects = graphene.List(graphene.ID)
class DeleteSinhVien(graphene.Mutation):
    id = graphene.Int()
    name = graphene.String()
    msv = graphene.String()
    lop = graphene.String()
    ngaysinh = graphene.Date()
    class Arguments:
        id = graphene.Int()
    def mutate(self, info, id):
        try:
            id = int(id)
        except ValueError:
            raise Exception("ID không hợp lệ: {}".format(id))                
        sinhVien = SinhVien.objects.get(pk = id)
        sinhVien.delete()
        return CreateSinhVien(id = sinhVien.id, name = sinhVien.name, msv = sinhVien.msv, lop = sinhVien.lop, ngaysinh = sinhVien.ngaysinh)        
示例#11
0
class OrderShipping(CountableDjangoObjectType):
    delivery_date = graphene.Date(description="Date of delivery of the order.")
    time_slot = graphene.String(
        description="Time slot of the delivery of the order.")
    order = graphene.Field(Order,
                           description="shipping details of this order.")

    class Meta:
        description = "Represents shipping date of particular order."
        model = models.OrderShipping
        interfaces = [relay.Node]
        only_fields = [
            "id",
            "delivery_date",
            "time_slot",
        ]
示例#12
0
class StudentInput(graphene.InputObjectType):
    # User fields
    user = UserInput(required=True)
    gender = GenderEnum()
    birth_date = graphene.Date()
    address = graphene.String()
    city = graphene.String()
    phone_number = graphene.String()
    state = graphene.String()
    zipcode = graphene.String()

    # Student fields
    grade = graphene.Int()
    school_id = graphene.ID(name="school")
    primary_parent_id = graphene.ID(name="primaryParent")
    secondary_parent_id = graphene.ID(name="secondaryParent")
示例#13
0
class UserBasicObj(graphene.ObjectType):
    username = graphene.String()
    firstName = graphene.String()
    lastName = graphene.String()
    fullName = graphene.String()
    email = graphene.String()
    avatar = graphene.Field(AvatarObj)
    isMembershipActive = graphene.Boolean()
    isAdmin = graphene.Boolean()
    joinDateTime = graphene.types.datetime.DateTime()
    statusUpdateCount = graphene.Int()
    lastStatusUpdate = graphene.Date()
    admissionYear = graphene.Int()
    profile = graphene.Field(ProfileObj)

    def resolve_firstName(self, info):
        return self['first_name']

    def resolve_lastName(self, info):
        return self['last_name']

    def resolve_fullName(self, info):
        return self['first_name'] + " " + self['last_name']

    def resolve_joinDateTime(self, info):
        return self['date_joined']

    def resolve_isMembershipActive(self, info):
        return self['is_active']

    def resolve_isAdmin(self, info):
        return self['is_superuser']

    def resolve_avatar(self, info):
        return Profile.objects.values().get(user__username=self['username'])

    def resolve_statusUpdateCount(self, info):
        return Message.objects.values().filter(member__username=self['username']).count()

    def resolve_lastStatusUpdate(self, info):
        return Message.objects.values().filter(member__username=self['username']).order_by('-date').first()['date']

    def resolve_admissionYear(self, info):
        return Profile.objects.values().get(user__username=self['username'])['batch']

    def resolve_profile(self, info):
        return Profile.objects.values().get(user__username=self['username'])
示例#14
0
 class Arguments:
     user_id = graphene.ID(description='National ID')
     first_name = graphene.String()
     last_name = graphene.String()
     username = graphene.String()
     email = graphene.String()
     dob = graphene.Date(description='\
                                     \n eg: 1900-01-01')
     role = graphene.String(description='''\
                           \n eg: System admin, Customer or System user ''')
     phone_no = graphene.String(description='Telephone Number')
     country = graphene.String(description='Country of origin')
     status = graphene.String(description='\n eg: active or deactivated')
     city = graphene.String()
     street_no = graphene.String(description='Street Number')
     post_code = graphene.String()
     password = graphene.String()
示例#15
0
class CollectionTagObj(graphene.ObjectType):
    name = graphene.String()
    author = graphene.Field(UserBasicObj)
    date = graphene.Date(required=True)
    cover = graphene.String(required=True)

    def resolve_name(self, info):
        return self['name']

    def resolve_author(self, info):
        return User.objects.values().get(id=self['author_id'])

    def resolve_date(self, info):
        return self['date']

    def resolve_cover(self, info):
        return self['cover']
示例#16
0
class RemovePlayer(graphene.Mutation):
    class Arguments:
        username = graphene.String()

    username = graphene.String()
    score = graphene.Int()
    alive = graphene.Boolean()
    date_joined = graphene.Date()

    async def mutate(parrent, info, username):
        player = find_player(username)
        global players
        if player is not None:
            new_players = filter(lambda p: p.username != username, players)
            players = new_players
            await queue_of_type("deleted").put(player)
            return player
示例#17
0
class PhotoObj(graphene.ObjectType):
    caption = graphene.String()
    image = graphene.String()
    uploader = graphene.Field(UserBasicObj)
    date = graphene.Date()

    def resolve_caption(self, info):
        return self['caption']

    def resolve_image(self, info):
        return self['image']

    def resolve_uploader(self, info):
        return User.objects.values().get(id=self['uploader_id'])

    def resolve_date(self, info):
        return self['date']
示例#18
0
class ProductChannelListingAddInput(PublishableChannelListingInput):
    visible_in_listings = graphene.Boolean(
        description=(
            "Determines if product is visible in product listings "
            "(doesn't apply to product collections)."
        )
    )
    is_available_for_purchase = graphene.Boolean(
        description="Determine if product should be available for purchase.",
    )
    available_for_purchase_date = graphene.Date(
        description=(
            "A start date from which a product will be available for purchase. "
            "When not set and isAvailable is set to True, "
            "the current day is assumed."
        )
    )
示例#19
0
class EntryCreateInputType(graphene.InputObjectType):
    url = graphene.String()
    preview = graphene.ID(required=False)
    document = Upload(required=False)
    article_title = graphene.String(required=True)
    source = graphene.String(required=True)
    publisher = graphene.String(required=True)
    publish_date = graphene.Date(required=True)
    source_methodology = graphene.String()
    source_excerpt = graphene.String()
    source_breakdown = graphene.String()
    event = graphene.ID(required=True)
    figures = graphene.List(NestedFigureCreateInputType)
    idmc_analysis = graphene.String()
    methodology = graphene.String()
    tags = graphene.List(graphene.String, required=False)
    reviewers = graphene.List(graphene.ID)
示例#20
0
class OrderInput:
    lease_id = graphene.ID()
    customer_id = graphene.ID(
        description="**Doesn't have an effect** until the price input is added."
    )
    status = OrderStatusEnum()
    comment = graphene.String()
    due_date = graphene.Date()
    product_id = graphene.ID(
        description=
        "**OBSOLETE**: The product is determined based on the lease passed. "
        "If no lease is provided, an explicit price must be specified (not implemented yet). "
        "This field has no effect at all and will be removed on a later version.",
        deprecation_reason=
        "**OBSOLETE**: The product is determined based on the lease passed. "
        "If no lease is provided, an explicit price must be specified (not implemented yet) "
        "This field has no effect at all and will be removed on a later version.",
    )
示例#21
0
class BlogPostObjectType(graphene.ObjectType):
    body = StreamField()
    body_word_count = graphene.Int()
    authors = graphene.List(AuthorObjectType)
    date = graphene.Date()
    feed_image = graphene.Field(ImageObjectType)
    listing_summary = graphene.String()
    related_services = graphene.List(ServiceObjectType)

    def resolve_authors(self, info):
        return Author.objects.filter(
            id__in=self.authors.values_list('author_id', flat=True))

    def resolve_related_services(self, info):
        return self.related_services.order_by('sort_order').all()

    class Meta:
        interfaces = [PageInterface]
示例#22
0
    class Input:
        id = graphene.ID(required=True)
        action = graphene.Field(OrderActionEnum)

        shipping_name = graphene.String()
        shipping_street1 = graphene.String()
        shipping_street2 = graphene.String()
        shipping_city = graphene.String()
        shipping_country = graphene.String()
        shipping_state_region = graphene.String()
        shipping_postcode = graphene.String()
        shipping_phone = graphene.String()
        shipping_tracking_num = graphene.String()
        shipping_date = graphene.Date()
        shipping_method_id = graphene.ID()

        product_offers = graphene.List(ProductOfferInput)
        offer_item_replacements = graphene.List(OfferItemReplacementInput)
示例#23
0
 class Arguments:
     performer_id = graphene.Int(required=True)
     name = graphene.String(required=True)
     description = graphene.String()
     gender = graphene.String()
     profile_pic = graphene.String()
     date_of_birth = graphene.Date()
     years_active = graphene.String()
     ethnicity = graphene.String()
     birth_Place = graphene.String()
     height = graphene.String()
     hair_color = graphene.String()
     eye_color = graphene.String()
     boobs = graphene.String()
     tattoos = graphene.String()
     piercings = graphene.String()
     measurments = graphene.String()
     rating = graphene.Float()
示例#24
0
class Page(ModelObjectType):
    id = graphene.GlobalID(required=True)
    seo_title = graphene.String()
    seo_description = graphene.String()
    title = graphene.String(required=True)
    content = JSONString(description="Content of the page (JSON).")
    publication_date = graphene.Date()
    is_published = graphene.Boolean(required=True)
    slug = graphene.String(required=True)
    page_type = graphene.Field(PageType, required=True)
    created = graphene.DateTime(required=True)
    content_json = JSONString(
        description="Content of the page (JSON).",
        deprecation_reason=f"{DEPRECATED_IN_3X_FIELD} Use the `content` field instead.",
        required=True,
    )
    translation = TranslationField(PageTranslation, type_name="page")
    attributes = graphene.List(
        graphene.NonNull(SelectedAttribute),
        required=True,
        description="List of attributes assigned to this product.",
    )

    class Meta:
        description = (
            "A static page that can be manually added by a shop operator through the "
            "dashboard."
        )
        interfaces = [graphene.relay.Node, ObjectWithMetadata]
        model = models.Page

    @staticmethod
    def resolve_page_type(root: models.Page, info):
        return PageTypeByIdLoader(info.context).load(root.page_type_id)

    @staticmethod
    def resolve_content_json(root: models.Page, info):
        content = root.content
        return content if content is not None else {}

    @staticmethod
    def resolve_attributes(root: models.Page, info):
        return SelectedAttributesByPageIdLoader(info.context).load(root.id)
示例#25
0
class InvoiceFilter(graphene.InputObjectType):
    q = graphene.String()
    id = graphene.ID()
    ids = graphene.List(graphene.ID)
    tenant = graphene.ID(default_value='default')
    invoice_number = graphene.String()
    invoice_date = graphene.Date()
    customer_tag = graphene.String()

    def to_dict(self):
        return {
            "q": self.q,
            "id": self.id,
            "ids": self.ids,
            "tenant": self.tenant,
            "invoice_number": self.invoice_number,
            "invoice_date": self.invoice_date,
            "customer_tag": self.customer_tag,
        }
示例#26
0
class BlogObj(graphene.ObjectType):
    title = graphene.String(required=True)
    slug = graphene.String(required=True)
    author = graphene.Field(UserBasicObj)
    date = graphene.Date(required=True)
    tags = graphene.List(TagObj)
    draft = graphene.String(required=True)
    featured = graphene.Boolean()
    description = graphene.String(required=True)
    cover = graphene.String(required=True)
    category = graphene.Field(CategoryObj)

    def resolve_title(self, info):
        return self['title']

    def resolve_slug(self, info):
        return self['slug']

    def resolve_author(self, info):
        return User.objects.values().get(id=self['author_id'])

    def resolve_date(self, info):
        return self['date']

    @graphene.resolve_only_args
    def resolve_tags(self):
        return Blog.objects.values().annotate(
            name=F('tags__name'), ).filter(id=self['id'])

    def resolve_draft(self, info):
        return self['draft']

    def resolve_featured(self, info):
        return self['featured']

    def resolve_description(self, info):
        return self['description']

    def resolve_cover(self, info):
        return self['cover']

    def resolve_category(self, info):
        return Category.objects.values().get(id=self['category_id'])
示例#27
0
class Collection(CountableDjangoObjectType):
    products = gql_optimizer.field(
        PrefetchingConnectionField(
            Product, description='List of products in this collection.'),
        prefetch_related=prefetch_products)
    background_image = graphene.Field(
        Image, size=graphene.Int(description='Size of the image'))
    published_date = graphene.Date(
        deprecation_reason=(
            'publishedDate is deprecated, use publicationDate instead'))

    class Meta:
        description = "Represents a collection of products."
        exclude_fields = [
            'voucher_set', 'sale_set', 'menuitem_set', 'background_image_alt']
        interfaces = [relay.Node]
        model = models.Collection

    def resolve_background_image(self, info, size=None, **kwargs):
        if not self.background_image:
            return None
        return resolve_background_image(
            self.background_image, self.background_image_alt, size, info)

    def resolve_products(self, info, **kwargs):
        if hasattr(self, 'prefetched_products'):
            return self.prefetched_products
        qs = self.products.visible_to_user(info.context.user)
        return gql_optimizer.query(qs, info)

    @classmethod
    def get_node(cls, info, id):
        if info.context:
            user = info.context.user
            try:
                return cls._meta.model.objects.visible_to_user(
                    user).get(pk=id)
            except cls._meta.model.DoesNotExist:
                return None
        return None

    def resolve_published_date(self, info):
        return self.publication_date
示例#28
0
class Page(CountableDjangoObjectType):
    available_on = graphene.Date(
        deprecation_reason=
        "availableOn is deprecated, use publicationDate instead")
    is_visible = graphene.Boolean(
        deprecation_reason="isVisible is deprecated, use isPublished instead")
    translation = graphene.Field(
        PageTranslation,
        language_code=graphene.Argument(
            LanguageCodeEnum,
            description="A language code to return the translation for.",
            required=True,
        ),
        description=
        "Returns translated Page fields for the given language code.",
        resolver=resolve_translation,
    )

    class Meta:
        description = """A static page that can be manually added by a shop
               operator through the dashboard."""
        only_fields = [
            "content",
            "content_json",
            "created",
            "id",
            "is_published",
            "publication_date",
            "seo_description",
            "seo_title",
            "slug",
            "title",
        ]
        interfaces = [relay.Node]
        model = models.Page

    @staticmethod
    def resolve_available_on(root: models.Page, _info):
        return root.publication_date

    @staticmethod
    def resolve_is_visible(root: models.Page, _info):
        return root.is_published
示例#29
0
class Page(CountableDjangoObjectType):
    available_on = graphene.Date(deprecation_reason=(
        'availableOn is deprecated, use publicationDate instead'))
    is_visible = graphene.Boolean(deprecation_reason=(
        'isVisible is deprecated, use isPublished instead'))

    class Meta:
        description = dedent(
            """A static page that can be manually added by a shop
        operator through the dashboard.""")
        exclude_fields = ['voucher_set', 'sale_set', 'menuitem_set']
        interfaces = [relay.Node]
        model = models.Page

    def resolve_available_on(self, info):
        return self.publication_date

    def resolve_is_visible(self, info):
        return self.is_published
示例#30
0
class Stages(DjangoObjectType):
    system = graphene.String()
    touch_points = graphene.List(Touchpoints,
                                 trace_id=graphene.String(),
                                 metric=graphene.String(),
                                 dt=graphene.Date(),
                                 brand=graphene.String())

    class Meta:
        model = System_traceability

    def resolve_touch_points(self, info, size=100, page=1, **kwargs):
        print(kwargs)
        trace_id = kwargs['trace_id']
        qs = Trace_ids.objects.all()
        qs = qs.filter(trace_id=trace_id)
        obj = None

        for each in qs:

            if each.type == 'system':
                obj = System_traceability.objects.all()
                obj = obj.filter(**kwargs).distinct().order_by('-step')
                print(obj, 'ghefgeku')
                break
            elif each.type == 'pipeline':
                obj = Pipeline_traceability.objects.all()
                obj = obj.filter(**kwargs).distinct().order_by('-step')
                break

        res = Traceability_results.objects.all()
        res = res.filter(trace_id=trace_id).filter(dt=kwargs['dt'])
        data = ''
        for each in res:
            data = each.results
        json_data = json.loads(data)
        # print(json_data)
        v = json_data['breakdown'][kwargs['metric']][
            kwargs['brand']]['Variance%age']
        # print(json_data['breakdown'][kwargs['metric']][kwargs['brand']]['Totals'][sys_name])
        # return get_wrapper_detail(Touchpoints, obj, page, size)
        return obj