Пример #1
0
class TechnologyPreferenceResource(Resource):
    class Meta:
        resource_name = "technology_prefs"
        model_class = JobTechnologyPref
        methods = ["GET", "PUT", "POST", "DELETE"]
        bulk_methods = ["GET"]

        filtering = {"id": ["eq"], "user__id": ["eq"]}
        with_relations = ['^technology$']
        ordering = ["id"]
        limit = 20

    id = fields.IntegerField(primary_key=True)
    user_id = fields.EncodedField()
    technology_id = fields.IntegerField()

    user = fields.EncodedForeignKey(UserResource,
                                    backref="technology_prefs",
                                    model_name="user",
                                    model_attname="user_id")
    technology = fields.ForeignKey(TechnologyResource,
                                   backref="technology_prefs+",
                                   model_name="technology",
                                   model_attname="technology_id")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user_id'], ['GET'])
Пример #2
0
class SkillResource(Resource):
    class Meta:
        resource_name = "skills"
        model_class = Skill
        methods = ["GET", "POST", "PUT", "DELETE"]
        bulk_methods = ["GET"]
        related_methods = {
            "user": ["GET"],
            "technology": ["GET"]
        }

        filtering = {
            "id": ["eq"],
            "expertise": ["eq", "in"],
            "yrs_experience": ["eq", "lt", "lte", "gt", "gte", "ranges"],
            "user__id": ["eq"],
            "technology__id": ["eq"]
        }    
        with_relations = ["user", "technology"]
        ordering = ["id"]
        limit = 20

    id = fields.IntegerField(primary_key=True)
    yrs_experience = fields.IntegerField()
    user_id = fields.EncodedField()
    technology_id = fields.IntegerField()
    expertise = EnumField(ExpertiseTypeEnum, model_attname="expertise_type_id")

    user = fields.EncodedForeignKey(UserResource, backref="skills", model_name="user", model_attname="user_id")
    technology = fields.ForeignKey(TechnologyResource, backref="skills+", model_name="technology", model_attname="technology_id")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user_id'], ['GET'])
Пример #3
0
class PositionPreferenceResource(Resource):
    class Meta:
        resource_name = "position_prefs"
        model_class = JobPositionTypePref
        methods = ["GET", "POST", "PUT", "DELETE"]
        bulk_methods = ["GET"]
        related_methods = {"user": ["GET"]}

        filtering = {"id": ["eq"], "user__id": ["eq"]}
        with_relations = []
        ordering = ["id"]
        limit = 20

    id = fields.IntegerField(primary_key=True)
    user_id = fields.EncodedField()
    type = EnumField(PositionTypeEnum, model_attname="position_type_id")

    user = fields.EncodedForeignKey(UserResource,
                                    backref="position_prefs",
                                    model_name="user",
                                    model_attname="user_id")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user_id'], ['GET'])
Пример #4
0
class ChatReelResource(Resource):
    class Meta:
        resource_name = "chat_reels"
        model_class = ChatReel
        methods = ["GET", "POST", "PUT", "DELETE"]
        bulk_methods = ["GET"]
        related_methods = {
            "user": ["GET"],
            "chat": ["GET"]
        }

        filtering = {
            "id": ["eq"],
            "user_id": ["eq"],
            "user__id": ["eq"],
            "chat__id": ["eq"]
        }    
        with_relations = ["user", "chat__topic"]
        ordering = ["id", "rank"]
        limit = 20

    id = fields.IntegerField(primary_key=True)
    user_id = fields.EncodedField()
    chat_id = fields.EncodedField()
    rank = fields.IntegerField()

    user = fields.EncodedForeignKey(UserResource, backref="chat_reels", model_name="user", model_attname="user_id")
    chat = fields.EncodedForeignKey(ChatResource, backref="chat_reels+", model_name="chat", model_attname="chat_id")

    objects = ChatReelManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user', 'user_id'], ["GET"])
Пример #5
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"])
Пример #6
0
class EmployerProfileResource(Resource):
    class Meta:
        resource_name = "employer_profiles"
        model_class = EmployerProfile
        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()

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

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['user', 'user_id'], ['GET'])
Пример #7
0
class UserResource(Resource):
    class Meta:
        resource_name = "users"
        model_class = User
        methods = ["GET", "PUT"]
        bulk_methods = ["GET"]
        related_methods = {
            "tenant": ["GET"],
            "developer_profile": ["GET"],
            "employer_profile": ["GET"],
            "chats": ["GET"],
            "chat_reels": ["GET"],
            "skills": ["GET"],
            "locations": ["GET"],
            "location_prefs": ["GET"],
            "technologies": ["GET"],
            "technology_prefs": ["GET"],
            "position_prefs": ["GET"],
            "applications": ["GET"],
            "job_notes": ["GET"],
            "interview_offers": ["GET"]
        }
        related_bulk_methods = {
            "chats": ["GET"],
            "chat_reels": ["GET"],
            "skills": ["GET"],
            "locations": ["GET"],
            "location_prefs": ["GET"],
            "technologies": ["GET"],
            "technology_prefs": ["GET"],
            "position_prefs": ["GET"],
            "applications": ["GET"],
            "job_notes": ["GET"],
            "interview_offers": ["GET"]
        }
        filtering = {
            "id": ["eq", "in"],
            "tenant_id": ["eq"],
            "tenant__id": ["eq"],
            "technology_prefs__id": ["eq"],
            "chats__id": ["eq"],
            "position_prefs__id": ["eq"]
        }
        with_relations = [
            r"^tenant$", r"^developer_profile$", r"^employer_profile$",
            r"^chats(__topic)?$", r"^chat_reels(__chat(__topic)?)?$",
            r"^locations$", r"^location_prefs(__location)?$",
            r"^skills(__technology)?$", r"^technologies$",
            r"^technology_prefs(__technology)?$", r"^position_prefs$"
        ]
        ordering = []
        limit = 20

    #fields
    id = fields.EncodedField(primary_key=True)
    tenant_id = fields.EncodedField(primary_key=True)
    first_name = fields.StringField()
    last_name = fields.StringField()
    email = fields.StringField(readonly=True)

    tenant = fields.EncodedForeignKey(TenantResource, backref="users")
    locations = fields.ManyToMany(LocationResource,
                                  through=JobLocationPref,
                                  backref="users+")
    technologies = fields.ManyToMany(TechnologyResource,
                                     through=JobTechnologyPref,
                                     backref="users")

    objects = AlchemyResourceManager(db_session_factory)
    authenticator = SessionAuthenticator()
    authorizer = UserAuthorizer(['id'], ['GET'])
    sanitizer = UserSanitizer()