示例#1
0
class TopicStruct(Struct):
    id = fields.IntegerField()
    type_id = fields.IntegerField()
    type = fields.StringField()
    duration = fields.IntegerField()
    title = fields.StringField()
    description = fields.StringField()
    recommended_participants = fields.IntegerField()
    rank = fields.IntegerField()
    public = fields.BooleanField()
    active = fields.BooleanField()
    level = fields.IntegerField()
示例#2
0
class RequisitionResource(Resource):
    class Meta:
        resource_name = "requisitions"
        model_class = JobRequisition
        methods = ["GET", "POST", "PUT", "DELETE"]
        bulk_methods = ["GET"]
        filtering = {
            "id": ["eq"],
            "tenant__id": ["eq"],
            "tenant_id": ["eq"],
            "status": ["eq"],
            "title": ["eq", "istartswith"],
            "deleted": ["eq"]
        }
        related_methods = {"requisition_technologies": ["GET"]}
        related_bulk_methods = {"requisition_technologies": ["GET"]}
        with_relations = [r"^requisition_technologies(__technology)?$"]
        ordering = [
            "created", "employer_requisition_identifier", "title", "status"
        ]
        limit = 40

    id = fields.EncodedField(primary_key=True)
    tenant_id = fields.EncodedField()
    user_id = fields.EncodedField()
    location = EnumField(LocationEnum, model_attname="location_id")
    created = fields.DateTimeField(nullable=True, readonly=True)
    status = EnumField(RequisitionStatusEnum, model_attname="status_id")
    position_type = EnumField(PositionTypeEnum,
                              model_attname="position_type_id")
    title = fields.StringField()
    description = fields.StringField()
    salary = fields.StringField()
    telecommute = fields.BooleanField()
    relocation = fields.BooleanField()
    equity = fields.StringField(nullable=True)
    employer_requisition_identifier = fields.StringField(nullable=True)
    deleted = fields.BooleanField(hidden=True)

    tenant = fields.EncodedForeignKey(TenantResource, backref="requisitions")
    user = fields.EncodedForeignKey(UserResource, backref="requisitions")
    technologies = fields.ManyToMany(TechnologyResource,
                                     through=JobRequisitionTechnology,
                                     backref="requisitions+")

    objects = AlchemyResourceManager(db_session_factory)
    # TODO objects = RequisitionManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = TenantAuthorizer(['tenant', 'tenant_id'], ['GET'])
示例#3
0
class ArchiveResource(Resource):
    class Meta:
        resource_name = "archives"
        model_class = ChatArchive
        methods = ["GET"]
        bulk_methods = ["GET"]

        filtering = {
            "id": ["eq"],
            "public": ["eq"],
            "chat__id": ["eq"]
        }    

        limit = 20

    id = fields.IntegerField(primary_key=True, readonly=True)
    type = EnumField(ChatArchiveTypeEnum, model_attname="type_id", readonly=True)
    mime_type = EnumField(MimeTypeEnum, model_attname="mime_type_id", readonly=True)
    chat_id = fields.EncodedField(readonly=True)
    path = fields.StringField(readonly=True)
    url = CdnUrlField(cdn_url=CDN_URL, model_attname="path", readonly=True)
    ssl_url = CdnUrlField(cdn_url=CDN_SSL_URL, model_attname="path", readonly=True)
    streaming_url = CdnUrlField(cdn_url=CDN_STREAMING_URL, model_attname="path", readonly=True)
    public = fields.BooleanField(readonly=True)
    length = fields.IntegerField(nullable=True, readonly=True)
    offset = fields.IntegerField(nullable=True, readonly=True)
    waveform = fields.StringField(nullable=True, readonly=True)
    waveform_path = fields.StringField(nullable=True, readonly=True)
    waveform_url = CdnUrlField(cdn_url=CDN_URL, model_attname="waveform_path", nullable=True, readonly=True)

    chat = fields.EncodedForeignKey(ChatResource, backref="archives", model_name="chat", model_attname="chat_id")

    objects = ArchiveManager(db_session_factory)
    authenticator = SessionAuthenticator()
示例#4
0
class ApplicationVoteResource(Resource):
    class Meta:
        resource_name = "application_votes"
        model_class = JobApplicationVote
        methods = ["GET", "POST", "PUT"]
        bulk_methods = ["GET"]
        filtering = {
            "id": ["eq"],
            "user_id": ["eq"],
            "tenant__id": ["eq"],
            "application_id": ["eq"],
            "application__id": ["eq"]
        }
        with_relations = []

    id = fields.EncodedField(primary_key=True)
    tenant_id = fields.EncodedField()
    user_id = fields.EncodedField()
    application_id = fields.EncodedField()
    yes = fields.BooleanField(nullable=True)

    tenant = fields.EncodedForeignKey(TenantResource,
                                      backref="application_votes+")
    user = fields.EncodedForeignKey(UserResource, backref="application_votes+")
    application = fields.EncodedForeignKey(ApplicationResource,
                                           backref="application_votes")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = RequestMethodAuthorizer({
        "GET":
        TenantAuthorizer(['tenant', 'tenant_id']),
        ("POST", "PUT", "DELETE"):
        TenantUserAuthorizer(['tenant', 'tenant_id'], ['user', 'user_id'])
    })
示例#5
0
class TopicSearchResource(Resource):
    class Meta:
        resource_name = "search"
        es_index = "topics"
        es_doc = "topic"
        bulk_methods = ["GET"]
        filtering = {
            "q": ["eq"],
            "active": ["eq"],
            "duration": ["eq", "in", "range", "ranges"],
            "tags__name": ["eq", "in"]
        }
        with_relations = ["^topic$"]
        ordering = ["title"]
        limit = 20

    #options
    f_tags_size = Option(default=10, field=fields.IntegerField())

    #fields
    id = fields.EncodedField(primary_key=True)
    topic_id = fields.EncodedField(model_attname='id')
    type = fields.StringField()
    #type = EnumField(TopicTypeEnum, model_attname="type_id")
    title = fields.StringField(sort_ext=".raw")
    description = fields.StringField()
    tree = fields.ListField(field=fields.StructField(TopicStruct, dict))
    tags = fields.ListField(field=fields.StructField(TagStruct, dict))
    duration = fields.IntegerField()
    active = fields.BooleanField()
    q = MultiMatchQueryField(es_fields=[
        'title^6', 'description^3', 'tags.name^2', 'subtopic_summary^1'
    ],
                             nullable=True)

    #related fields
    topic = fields.EncodedForeignKey(TopicResource, backref="searches+")

    #facets
    f_duration = RangeFacet(title="Duration", field="duration").\
        add(0, 301, name="under 5 mins").\
        add(302, 601, name="5 to 10 mins").\
        add(602, 3600, name="10+ mins")
    f_tags = TermsFacet(title="Tags",
                        field="tags__name",
                        es_field="tags.name.raw",
                        size_option="f_tags_size")

    #objects
    objects = TopicSearchManager(es_client_pool)
    authenticator = SessionAuthenticator()
示例#6
0
class TopicResource(Resource):
    class Meta:
        resource_name = "topics"
        model_class = Topic
        methods = ["GET"]
        bulk_methods = ["GET"]
        related_methods = {
            "children": ["GET"],
            "talking_points": ["GET"],
            "tags": ["GET"],
        }
        related_bulk_methods = {
            "talking_points": ["GET"],
            "chats": ["GET"],
            "tags": ["GET"],
        }
        filtering = {
            "id": ["eq"],
            "parent_id": ["eq"],
            "children": ["eq"],
            "parent": ["eq"],
            "title": ["eq", "istartswith"],
        }
        with_relations = [
            r"^tree$", r"^children$", r"^talking_points$", r"^tags$"
        ]
        ordering = ["id"]
        limit = 20

    id = fields.EncodedField(primary_key=True)
    parent_id = fields.EncodedField(nullable=True)
    type = EnumField(TopicTypeEnum, model_attname="type_id")
    title = fields.StringField()
    description = fields.StringField()
    duration = fields.IntegerField()
    tree = TopicTreeField("self")
    rank = fields.IntegerField()
    level = fields.IntegerField(nullable=True)
    user_id = fields.EncodedField()
    public = fields.BooleanField()
    recommended_participants = fields.IntegerField()

    parent = fields.EncodedForeignKey("self",
                                      backref="children",
                                      nullable=True)
    user = fields.EncodedForeignKey(UserResource, backref="topics+")
    tags = fields.ManyToMany(TagResource, through=TopicTag, backref="topics+")

    objects = TopicManager(db_session_factory)
    authorizer = UserAuthorizer(['user', 'user_id'], ["GET"])
示例#7
0
class DeveloperProfileResource(Resource):
    class Meta:
        resource_name = "developer_profiles"
        model_class = DeveloperProfile
        methods = ["GET", "PUT"]
        bulk_methods = ["GET"]
        filtering = {"id": ["eq"], "user__id": ["eq"]}
        ordering = []
        limit = 20

    id = fields.EncodedField(primary_key=True)
    user_id = fields.EncodedField()
    location = fields.StringField(nullable=True)
    actively_seeking = fields.BooleanField()

    user = fields.EncodedOneToOne(UserResource,
                                  backref="developer_profile",
                                  model_name="user",
                                  model_attname="user_id")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user', 'user_id'], ['GET'])
示例#8
0
class UserSearchResource(Resource):
    class Meta:
        resource_name = "search"
        es_index = "users"
        es_doc = "user"
        bulk_methods = ["GET"]
        filtering = {
            "q": ["eq"],
            "yrs_experience": ["eq", "in", "range", "ranges"],
            "joined": ["eq", "in", "range", "ranges"],
            "skills__name": ["eq", "in"],
            "chats__topic_title": ["eq", "in"],
            "location_prefs__region": ["eq", "in"],
            "position_prefs__type": ["eq", "in"],
            "technology_prefs__name": ["eq", "in"],
            "demo": ["eq"]
        }
        with_relations = ["^user(__skills)?$"]
        ordering = []
        limit = 20

    #options
    f_skills_size = Option(default=10, field=fields.IntegerField())
    f_chats_size = Option(default=10, field=fields.IntegerField())
    f_location_prefs_size = Option(default=10, field=fields.IntegerField())
    f_position_prefs_size = Option(default=10, field=fields.IntegerField())
    f_technology_prefs_size = Option(default=10, field=fields.IntegerField())

    #fields
    id = fields.EncodedField(primary_key=True)
    user_id = fields.EncodedField(model_attname="id")
    yrs_experience = fields.IntegerField()
    joined = fields.DateTimeField()
    location = fields.StringField(nullable=True)
    actively_seeking = fields.BooleanField()
    skills = fields.ListField(field=fields.StructField(Skill, dict))
    location_prefs = fields.ListField(
        field=fields.StructField(LocationPref, dict))
    position_prefs = fields.ListField(
        field=fields.StructField(PositionPref, dict))
    technology_prefs = fields.ListField(
        field=fields.StructField(TechnologyPref, dict))
    chats = fields.ListField(field=fields.StructField(Chat, dict))
    q = CustomScoreMultiMatchQueryField(
        es_score_field='score',
        es_fields=['skills.name', 'location_prefs.region'],
        nullable=True)
    demo = fields.BooleanField()

    #related fields
    user = fields.EncodedForeignKey(UserResource, backref="searches+")

    #facets
    f_skills = TermsFacet(title="Skills",
                          field="skills__name",
                          es_field="skills.name.raw",
                          size_option="f_skills_size")
    f_chats = TermsFacet(title="Chats",
                         field="chats__topic_title",
                         es_field="chats.topic_title.raw",
                         size_option="f_chats_size")
    f_location_prefs = TermsFacet(title="Location Preferences",
                                  field="location_prefs__region",
                                  es_field="location_prefs.region.raw",
                                  size_option="f_location_prefs_size")
    f_position_prefs = TermsFacet(title="Position Preferences",
                                  field="position_prefs__type",
                                  es_field="position_prefs.type.raw",
                                  size_option="f_position_prefs_size")
    f_technology_prefs = TermsFacet(title="Technology Preferences",
                                    field="technology_prefs__name",
                                    es_field="technology_prefs.name.raw",
                                    size_option="f_technology_prefs_size")
    f_yrs_experience = RangeFacet(title="Years Experience",
            field="yrs_experience")\
            .add(0,2).add(3,5).add(6, 10).add(11, 100, name="10+")
    f_joined = DateRangeFacet(title="Joined", field="joined")\
            .add("now-7d", "now", name="Last 7 days")\
            .add("now-30d", "now", name="Last 30 days")\
            .add("now-3M", "now", name="Last 3 months")\
            .add("now-12M", "now", name="Last year")

    #objects
    objects = UserSearchManager(es_client_pool)
    authenticator = SessionAuthenticator()