Commit 3e3d5e89545c6d7e9d802f167b3b1346a606bd59
1 parent
c6feabda
Exists in
master
and in
39 other branches
Adding bio field on user profile
Showing
3 changed files
with
79 additions
and
1 deletions
Show diff stats
src/accounts/forms.py
| @@ -49,12 +49,19 @@ class UserCreationForm(UserForm): | @@ -49,12 +49,19 @@ class UserCreationForm(UserForm): | ||
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | class UserUpdateForm(UserForm): | 51 | class UserUpdateForm(UserForm): |
| 52 | + bio = forms.CharField( | ||
| 53 | + widget=forms.Textarea(attrs={'rows': '6', 'maxlength': '200'}), | ||
| 54 | + max_length=200, | ||
| 55 | + label=_(u'Biography'), | ||
| 56 | + help_text=_(u'Write something about you in 200 characters or less.'), | ||
| 57 | + required=False, | ||
| 58 | + ) | ||
| 52 | 59 | ||
| 53 | class Meta: | 60 | class Meta: |
| 54 | model = User | 61 | model = User |
| 55 | fields = ('first_name', 'last_name', | 62 | fields = ('first_name', 'last_name', |
| 56 | 'institution', 'role', 'twitter', 'facebook', | 63 | 'institution', 'role', 'twitter', 'facebook', |
| 57 | - 'google_talk', 'webpage') | 64 | + 'google_talk', 'webpage', 'bio') |
| 58 | 65 | ||
| 59 | twitter = SocialAccountField(url='https://twitter.com/', required=False) | 66 | twitter = SocialAccountField(url='https://twitter.com/', required=False) |
| 60 | facebook = SocialAccountField(url='https://graph.facebook.com/', required=False) | 67 | facebook = SocialAccountField(url='https://graph.facebook.com/', required=False) |
src/accounts/migrations/0008_auto__add_field_user_bio.py
0 → 100644
| @@ -0,0 +1,70 @@ | @@ -0,0 +1,70 @@ | ||
| 1 | +# -*- coding: utf-8 -*- | ||
| 2 | +import datetime | ||
| 3 | +from south.db import db | ||
| 4 | +from south.v2 import SchemaMigration | ||
| 5 | +from django.db import models | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +class Migration(SchemaMigration): | ||
| 9 | + | ||
| 10 | + def forwards(self, orm): | ||
| 11 | + # Adding field 'User.bio' | ||
| 12 | + db.add_column(u'accounts_user', 'bio', | ||
| 13 | + self.gf('django.db.models.fields.CharField')(max_length=200, null=True, blank=True), | ||
| 14 | + keep_default=False) | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + def backwards(self, orm): | ||
| 18 | + # Deleting field 'User.bio' | ||
| 19 | + db.delete_column(u'accounts_user', 'bio') | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + models = { | ||
| 23 | + u'accounts.user': { | ||
| 24 | + 'Meta': {'object_name': 'User'}, | ||
| 25 | + 'bio': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), | ||
| 26 | + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
| 27 | + 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75', 'blank': 'True'}), | ||
| 28 | + 'facebook': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
| 29 | + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
| 30 | + 'google_talk': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), | ||
| 31 | + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), | ||
| 32 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
| 33 | + 'institution': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
| 34 | + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), | ||
| 35 | + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
| 36 | + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | ||
| 37 | + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | ||
| 38 | + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | ||
| 39 | + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), | ||
| 40 | + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
| 41 | + 'role': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
| 42 | + 'twitter': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | ||
| 43 | + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), | ||
| 44 | + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), | ||
| 45 | + 'verification_hash': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}), | ||
| 46 | + 'webpage': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}) | ||
| 47 | + }, | ||
| 48 | + u'auth.group': { | ||
| 49 | + 'Meta': {'object_name': 'Group'}, | ||
| 50 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
| 51 | + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), | ||
| 52 | + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) | ||
| 53 | + }, | ||
| 54 | + u'auth.permission': { | ||
| 55 | + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, | ||
| 56 | + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
| 57 | + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), | ||
| 58 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
| 59 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | ||
| 60 | + }, | ||
| 61 | + u'contenttypes.contenttype': { | ||
| 62 | + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, | ||
| 63 | + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
| 64 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
| 65 | + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | ||
| 66 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + complete_apps = ['accounts'] | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |
src/accounts/models.py
| @@ -23,6 +23,7 @@ class User(AbstractUser): | @@ -23,6 +23,7 @@ class User(AbstractUser): | ||
| 23 | webpage = models.CharField(max_length=256, null=True, blank=True) | 23 | webpage = models.CharField(max_length=256, null=True, blank=True) |
| 24 | verification_hash = models.CharField(max_length=32, null=True, blank=True) | 24 | verification_hash = models.CharField(max_length=32, null=True, blank=True) |
| 25 | modified = models.DateTimeField(auto_now=True) | 25 | modified = models.DateTimeField(auto_now=True) |
| 26 | + bio = models.CharField(max_length=200, null=True, blank=True) | ||
| 26 | 27 | ||
| 27 | def check_password(self, raw_password): | 28 | def check_password(self, raw_password): |
| 28 | 29 |