Commit fad63938 by cahrens Committed by Andy Armstrong

New bio field in UserProfile.

parent 0a962bf9
...@@ -249,6 +249,7 @@ class UserProfile(models.Model): ...@@ -249,6 +249,7 @@ class UserProfile(models.Model):
country = CountryField(blank=True, null=True) country = CountryField(blank=True, null=True)
goals = models.TextField(blank=True, null=True) goals = models.TextField(blank=True, null=True)
allow_certificate = models.BooleanField(default=1) allow_certificate = models.BooleanField(default=1)
bio = models.TextField(blank=True, null=True)
def get_meta(self): # pylint: disable=missing-docstring def get_meta(self): # pylint: disable=missing-docstring
js_str = self.meta js_str = self.meta
......
...@@ -21,7 +21,8 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer): ...@@ -21,7 +21,8 @@ class AccountLegacyProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = UserProfile model = UserProfile
fields = ( fields = (
"name", "gender", "goals", "year_of_birth", "level_of_education", "language", "country", "mailing_address" "name", "gender", "goals", "year_of_birth", "level_of_education", "language", "country",
"mailing_address", "bio"
) )
# Currently no read-only field, but keep this so view code doesn't need to know. # Currently no read-only field, but keep this so view code doesn't need to know.
read_only_fields = () read_only_fields = ()
......
...@@ -85,6 +85,7 @@ class UserAPITestCase(APITestCase): ...@@ -85,6 +85,7 @@ class UserAPITestCase(APITestCase):
legacy_profile.year_of_birth = 1900 legacy_profile.year_of_birth = 1900
legacy_profile.goals = "world peace" legacy_profile.goals = "world peace"
legacy_profile.mailing_address = "Park Ave" legacy_profile.mailing_address = "Park Ave"
legacy_profile.bio = "Tired mother of twins"
legacy_profile.save() legacy_profile.save()
...@@ -110,7 +111,7 @@ class TestAccountAPI(UserAPITestCase): ...@@ -110,7 +111,7 @@ class TestAccountAPI(UserAPITestCase):
self.assertIsNone(data["profile_image"]) self.assertIsNone(data["profile_image"])
self.assertIsNone(data["time_zone"]) self.assertIsNone(data["time_zone"])
self.assertIsNone(data["languages"]) self.assertIsNone(data["languages"])
self.assertIsNone(data["bio"]) self.assertEqual("Tired mother of twins", data["bio"])
def _verify_private_account_response(self, response): def _verify_private_account_response(self, response):
""" """
...@@ -139,6 +140,7 @@ class TestAccountAPI(UserAPITestCase): ...@@ -139,6 +140,7 @@ class TestAccountAPI(UserAPITestCase):
self.assertEqual(self.user.email, data["email"]) self.assertEqual(self.user.email, data["email"])
self.assertTrue(data["is_active"]) self.assertTrue(data["is_active"])
self.assertIsNotNone(data["date_joined"]) self.assertIsNotNone(data["date_joined"])
self.assertEqual("Tired mother of twins", data["bio"])
def test_anonymous_access(self): def test_anonymous_access(self):
""" """
...@@ -243,7 +245,7 @@ class TestAccountAPI(UserAPITestCase): ...@@ -243,7 +245,7 @@ class TestAccountAPI(UserAPITestCase):
self.assertEqual(12, len(data)) self.assertEqual(12, len(data))
self.assertEqual(self.user.username, data["username"]) self.assertEqual(self.user.username, data["username"])
self.assertEqual(self.user.first_name + " " + self.user.last_name, data["name"]) self.assertEqual(self.user.first_name + " " + self.user.last_name, data["name"])
for empty_field in ("year_of_birth", "level_of_education", "mailing_address"): for empty_field in ("year_of_birth", "level_of_education", "mailing_address", "bio"):
self.assertIsNone(data[empty_field]) self.assertIsNone(data[empty_field])
self.assertIsNone(data["country"]) self.assertIsNone(data["country"])
# TODO: what should the format of this be? # TODO: what should the format of this be?
...@@ -316,6 +318,10 @@ class TestAccountAPI(UserAPITestCase): ...@@ -316,6 +318,10 @@ class TestAccountAPI(UserAPITestCase):
("language", "Creole"), ("language", "Creole"),
("goals", "Smell the roses"), ("goals", "Smell the roses"),
("mailing_address", "Sesame Street"), ("mailing_address", "Sesame Street"),
("bio", "Lacrosse-playing superhero"),
("bio", u"壓是進界推日不復女"),
# Note that we store the raw data, so it is up to client to escape the HTML.
("bio", "<html>fancy text</html>"),
# Note that email is tested below, as it is not immediately updated. # Note that email is tested below, as it is not immediately updated.
) )
@ddt.unpack @ddt.unpack
......
...@@ -38,12 +38,13 @@ class AccountView(APIView): ...@@ -38,12 +38,13 @@ class AccountView(APIView):
* name: The full name of the user. * name: The full name of the user.
* email: The confirmed email address for the user. The request * email: email for the user (the new email address must be
will not return an unconfirmed email address. confirmed via a confirmation email, so GET will not reflect
the change until the address has been confirmed).
* date_joined: The date the account was created, in * date_joined: The date the account was created, in the string
the string format provided by datetime (for example, format provided by datetime.
"2014-08-26T17:52:11Z"). For example, "2014-08-26T17:52:11Z".
* gender: One of the fullowing values: * gender: One of the fullowing values:
...@@ -77,6 +78,14 @@ class AccountView(APIView): ...@@ -77,6 +78,14 @@ class AccountView(APIView):
* goals: The textual representation of the user's goals, or null. * goals: The textual representation of the user's goals, or null.
* bio: null or textural representation of user biographical
information ("about me")
For all text fields, clients rendering the values should take care
to HTML escape them to avoid script injections, as the data is
stored exactly as specified. The intention is that plain text is
supported, not HTML.
If a user who does not have "is_staff" access requests account If a user who does not have "is_staff" access requests account
information for a different user, only a subset of these fields is information for a different user, only a subset of these fields is
returned. The fields returned depend on the configuration setting returned. The fields returned depend on the configuration setting
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment