Пример #1
0
    def get(self, contact_id):
        if not is_authorized_view(contact_id): 
            return unauthorized()

        res = Resume.query.filter_by(contact_id=contact_id)
        res_list = resumes_schema.dump(res)
        return {'status': 'success', 'data': res_list}, 200
Пример #2
0
    def get(self, contact_id):

        if not is_authorized_view(contact_id):
            return unauthorized()

        contact = Contact.query.get(contact_id)
        result = program_app_schema.dump(contact)
        return {'status': 'success', 'data': result}, 200
Пример #3
0
    def get(self, contact_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        program_contacts = ProgramContact.query.filter_by(
            contact_id=contact_id)
        result = program_contacts_schema.dump(program_contacts)
        return {'status': 'success', 'data': result}, 200
Пример #4
0
    def get(self, contact_id):
        achievement = Achievement.query.filter_by(contact_id=contact_id)
        achievement_list = achievements_schema.dump(achievement)

        if not is_authorized_view(contact_id):
            return unauthorized()

        return {'status': 'success', 'data': achievement_list}, 200
Пример #5
0
 def get(self, contact_id):
     if not is_authorized_view(contact_id):
         return unauthorized()
     contact = Contact.query.get(contact_id)
     if not contact:
         return {'message': 'Contact does not exist'}, 404
     result = instructions_schema.dump(contact)
     return {'status': 'success', 'data': result}, 200
Пример #6
0
 def get(self, contact_id):
     if not is_authorized_view(contact_id):
         return unauthorized()
     opportunity_apps = (OpportunityApp.query
         .filter(OpportunityApp.contact_id==contact_id,
                 OpportunityApp.stage>=ApplicationStage.submitted.value)
         .all())
     data = opportunity_app_schema_many.dump(opportunity_apps)
     return {'status': 'success', 'data': data}, 200
Пример #7
0
    def get(self, contact_id, program_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        program_contact = query_one_program_contact(contact_id, program_id)
        if not program_contact:
            return {'message': 'Record does not exist'}, 404
        result = program_contact_schema.dump(program_contact)
        return {'status': 'success', 'data': result}, 200
Пример #8
0
    def get(self, resume_id):
        res = Resume.query.get(resume_id)
        if not res:
            return {'message': 'Resume does not exist'}, 404
        if not is_authorized_view(res.contact.id): 
            return unauthorized()

        sections = ResumeSection.query.filter_by(resume_id=resume_id)
        result = resume_sections_schema.dump(sections)
        return {'status': 'success', 'data': result}, 200
Пример #9
0
    def get(self, contact_id):
        contact = Contact.query.get(contact_id)
        if not contact:
            return {'message': 'Contact does not exist'}, 404

        if not is_authorized_view(contact.id):
            return unauthorized()

        contact = contact_full_schema.dump(contact)
        return {'status': 'success', 'data': contact}, 200
Пример #10
0
    def get(self, contact_id, tag_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        tag = (TagItem.query.filter_by(contact_id=contact_id,
                                       tag_id=tag_id).first())
        if not tag:
            return {'message': 'TagItem does not exist'}, 404
        tag_data = tag_item_schema.dump(tag)
        return {'status': 'success', 'data': tag_data}, 200
Пример #11
0
    def get(self, contact_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        contact = Contact.query.get(contact_id)
        if not contact:
            return {'message': 'Contact not found'}, 404

        skills = skills_schema.dump(contact.skills)
        skills.sort(key=lambda s: s['name'])
        return {'status': 'success', 'data': skills}, 200
Пример #12
0
    def post(self, contact_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        contact = Contact.query.get(contact_id)

        if not contact:
            return {'message': 'Contact does not exist'}, 404

        if contact.profile:
            return {'message': 'Profile already exists'}, 400

        profile = create_profile(contact)
        db.session.add(profile)
        db.session.commit()

        result = profile_schema.dump(contact)

        return {'status': 'success', 'data': result}, 201
Пример #13
0
    def get(self, contact_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        type_arg = request.args.get('type')
        if type_arg:
            if type_arg not in TagType.__members__:
                return {
                    'message':
                    f'No such tag type, '
                    f'choose an option from this list: {type_list}'
                }, 400
            tags = (TagItem.query.join(Tag).filter(
                TagItem.contact_id == contact_id,
                Tag.type == TagType[type_arg]))
        else:
            tags = TagItem.query.filter_by(contact_id=contact_id)
        tags_list = tag_items_schema.dump(tags)
        return {'status': 'success', 'data': tags_list}, 200
Пример #14
0
    def post(self, contact_id):
        if not is_authorized_view(contact_id):
            return unauthorized()

        # query contact and check that all submission criteria is met
        contact = Contact.query.get(contact_id)
        email = contact.email_main
        if not contact:
            return {'message': 'Contact does not exist'}, 404
        if not (contact.about_me_complete['is_complete']
                and contact.profile_complete['is_complete']):
            return {'message': 'Not all profile sections are complete'}, 400
        if contact.stage >= 2:
            return {'message': 'Profile already submitted'}, 400


        # Start of Trello specific code
        PROGRAMS_DICT = {
            'Fellowship': 'Fellowship',
            'Mayoral Fellowship': 'Mayoral Fellowship',
            'Place for Purpose': 'PFP',
            'Public Allies': 'PA',
            'JHU Carey Humanities Fellowship': 'JHU - Carey'
        }

        #query board and check that a card doesn't already exist
        board_id = get_intake_talent_board_id(program_id=1)
        board = Board(query_board_data(board_id))
        existing_card = board.find_card_by_custom_field('Email', email)
        if existing_card:
            return {'message': 'Application has already been submitted'}, 400

        # parses form data to fill the card description
        profile = contact.profile
        roles = ['- '+role for role in profile.roles_list]
        roles_str = '\n'.join(roles)
        programs = [PROGRAMS_DICT[app.program.name]
                    for app in contact.program_apps
                    if app.is_interested]
        programs_str = '\n'.join(['- ' + p for p in programs])

        #formats the string for the description
        card_data = {
            'name': (
                f"{contact.first_name} {contact.last_name}"
                ),
            'desc': (
                "**Racial Equity & Baltimore: "
                "Why is racial equity work in Baltimore "
                "important to you?**\n\n"
                f"{profile.value_question1}\n\n---\n\n"
                "**Sector Effectiveness: How has your background"
                " and experiences prepared you for today’s work"
                " in Baltimore’s social impact sector?**\n\n"
                f"{profile.value_question2}\n\n---\n\n"
                f"**Level of Experience:** {profile.years_exp}\n\n"
                f"**Types of roles they're interested in:**\n\n"
                f"{roles_str}\n\n---\n\n"
                f"**Programs/Services they are interested in:**\n\n"
                f"{programs_str}\n\n---\n\n"
                f"**Currently a student:**\n\n"
                f"{profile.current_edu_status}\n\n---\n\n"
            )
        }
        fields_data = {
            'Phone': contact.phone_primary,
            'Email': email,
            'External ID': str(contact.id)
        }

        #creates the card with the information parsed from the form
        submitted_list = board.lists['stage'][2]
        card = submitted_list.add_card_from_template(**card_data)
        card.add_attachment(
            url=f'https://app.baltimorecorps.org/profile/{contact_id}',
            name='Profile'
        )
        labels = set(card.label_names + programs)
        card.set_labels(labels)
        card.set_custom_field_values(**fields_data)

        # updates the contact to stage 2
        contact.stage = 2
        contact.card_id = card.id
        db.session.commit()

        result = instructions_schema.dump(contact)

        return {'status': 'success', 'data': result}, 201