Ejemplo n.º 1
0
def save_address_profile(body):  # noqa: E501
    """save_address_profile

    Creates an address # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        body = UserProfile.from_dict(connexion.request.get_json())  # noqa: E501
        
        address = DBAddress(
            address_id=body.address_id,
            street=body.street,
            outer_number=body.outer_number,
            inner_number=body.inner_number,
            neighborhood_id=body.neighborhood_id,
            muncipality_id=body.muncipality_id,
            zip_code=body.zip_code,
            state_id=body.state_id
        )

        db.session.add(address)
        db.session.commit()

    return (Response(), 201)
    def test_save_user_profile(self):
        """Test case for save_user_profile

        
        """
        body = UserProfile()
        response = self.client.open('/userProfile',
                                    method='POST',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Ejemplo n.º 3
0
def get_user_profile_by_id(uid):  # noqa: E501
    """get_user_profile_by_id

    Displays a User defined by ID # noqa: E501

    :param uid: Unique identifier
    :type uid: str

    :rtype: UserProfile
    """

    user = DBUser.query.filter(DBUser.uid== uid).first()

    if user == None:
        abort(404)

    profile = DBProfile.query.filter(DBProfile.id == user.id).first()

    if profile == None:
        abort(404)
    return UserProfile(
        userprofile_id=profile.id,
        first_name=profile.first_name,
        second_name=profile.second_name,
        first_surname=profile.first_surname,
        second_surname=profile.second_surname,
        birthdate=profile.birthdate,
        curp=profile.curp,
        mobile_number=profile.mobile_number,
        home_number=profile.home_number,
        office_number=profile.office_number,
        facebook_profile=profile.facebook_profile,
        linkedin_profile=profile.linkedin_profile,
        twitter_profile=profile.twitter_profile,
        id_image=profile.id_image,
        status=profile.status,
        created=profile.created,
        updated=profile.updated,
        # credentials_id=profile.credentials_id,
        # org_id = profile.org_id,
        address=profile.address
    )
Ejemplo n.º 4
0
def save_user_profile(body):  # noqa: E501
    """save_user_profile

    Creates a user profile # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: str
    """
    if connexion.request.is_json:
        body = UserProfile.from_dict(connexion.request.get_json())  # noqa: E501

        profile = DBProfile(
                id=body.id,
                first_name=body.first_name,
                second_name=body.second_name,
                first_surname=body.first_surname,
                second_surname=body.second_surname,
                birthdate=body.birthdate,
                curp=body.curp,
                mobile_number=body.mobile_number,
                home_number=body.home_number,
                office_number=body.office_number,
                facebook_profile=body.facebook_profile,
                linkedin_profile=body.linkedin_profile,
                twitter_profile=body.twitter_profile,
                id_image=body.id_image,
                status=body.status,
                created=body.created,
                updated=body.updated,
                # credentials_id=body.credentials_id,
                # org_id = body.org_id,
                address=body.address
        )

        db.session.add(profile)
        db.session.commit()

    return (Response(), 201)
Ejemplo n.º 5
0
def update_user(body):  # noqa: E501
    """Update an existing user_profile

    :param body: UserProfile object that needs to be added to the store
    :type body: dict | bytes

    :rtype: UserProfile
    """
    if connexion.request.is_json:
        body = UserProfile.from_dict(connexion.request.get_json())  # noqa: E501

        profile = DBProfile.query.filter(DBProfile.id == body.userprofile_id).first()

        profile.id = body.id,
        profile.first_name = body.first_name,
        profile.second_name = body.second_name,
        profile.first_surname = body.first_surname,
        profile.second_surname = body.second_surname,
        profile.birthdate = body.birthdate,
        profile.curp = body.curp,
        profile.mobile_number = body.mobile_number,
        profile.home_number = body.home_number,
        profile.office_number = body.office_number,
        profile.facebook_profile = body.facebook_profile,
        profile.linkedin_profile = body.linkedin_profile,
        profile.twitter_profile = body.twitter_profile,
        profile.id_image = body.id_image,
        profile.status = body.status,
        profile.created = body.created,
        profile.updated = body.updated,
        # profile.credentials_id = body.credentials_id,
        profile.org_id = body.org_id,
        profile.address = body.address

        db.session.commit()

    return (Response(), 204)
Ejemplo n.º 6
0
def get_provider_by_id(provider_id):  # noqa: E501
    """get_provider_by_id

    Shows a provider identified by id # noqa: E501

    :param provider_id: id del proveedor de servicios
    :type provider_id: int

    :rtype: UserProfile
    """
    profile = DBProfile.query.filter(
        DBProfile.provider_id == provider_id).first()

    if profile == None:
        abort(404)

    return UserProfile(userprofile_id=profile.userprofile_id,
                       first_name=profile.first_name,
                       second_name=profile.second_name,
                       first_surname=profile.first_surname,
                       second_surname=profile.second_surname,
                       birthdate=profile.birthdate,
                       curp=profile.curp,
                       mobile_number=profile.mobile_number,
                       home_number=profile.home_number,
                       office_number=profile.office_number,
                       facebook_profile=profile.facebook_profile,
                       linkedin_profile=profile.linkedin_profile,
                       twitter_profile=profile.twitter_profile,
                       id_image=profile.id_image,
                       status=profile.status,
                       created=profile.created,
                       updated=profile.updated,
                       credentials_id=profile.credentials_id,
                       org_id=profile.org_id,
                       address=profile.address)