danbretl / mid-tier

django webapp
1 stars 0 forks source link

Update registration resource, forms, and api tests for first and last name fields #75

Closed rabialam closed 12 years ago

rabialam commented 12 years ago

Currently, there is no way to submit first and last names as fields for user creation, nor any way to retrieve these profile fields for a given user.

rabialam commented 12 years ago

Currently, the user profile resource is not implemented correctly -- it uses a subset of fields off of User query set when it should really use the UserProfile query set. However, right now, a corresponding UserProfile object is not created when the User object is created through interaction with the registration endpoint.

rabialam commented 12 years ago

User profile resource now implemented to use UserProfile query set. Email signup form modified to create UserProfile after creating new user. API tests updated to reflect changes.

rabialam commented 12 years ago

To use this new resource:

Example call (from my unit test): (note that here, self.uri = '/api/v1/userprofile/')

        auth_header = 'Basic %s' % base64.b64encode('%s:%s' %
                (user_profile.user.email, self.password))
        resp = self.client.get(self.uri, data=self.auth_params,
                HTTP_AUTHORIZATION=auth_header)

Then, we get this in resp.content:

{'meta': {'limit': 20,
          'next': None,
          'offset': 0,
          'previous': None,
          'total_count': 1},
 'objects': [{'first_name': '1',
              'last_name': '1',
              'resource_uri': '/api/v1/userprofile/1/'}]}