Commit 167694353094a5ac28ca2e7cc269d136dfe5f5f7
1 parent
893519a8
Exists in
master
and in
39 other branches
Adding modified field to user
Showing
3 changed files
with
71 additions
and
1 deletions
Show diff stats
src/accounts/migrations/0006_auto__add_field_user_modified.py
0 → 100644
... | ... | @@ -0,0 +1,69 @@ |
1 | +# -*- coding: utf-8 -*- | |
2 | +from south.db import db | |
3 | +from south.v2 import SchemaMigration | |
4 | +from django.db import models | |
5 | +from django.utils import timezone | |
6 | + | |
7 | + | |
8 | +class Migration(SchemaMigration): | |
9 | + | |
10 | + def forwards(self, orm): | |
11 | + # Adding field 'User.modified' | |
12 | + db.add_column(u'accounts_user', 'modified', | |
13 | + self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=timezone.now, blank=True), | |
14 | + keep_default=False) | |
15 | + | |
16 | + | |
17 | + def backwards(self, orm): | |
18 | + # Deleting field 'User.modified' | |
19 | + db.delete_column(u'accounts_user', 'modified') | |
20 | + | |
21 | + | |
22 | + models = { | |
23 | + u'accounts.user': { | |
24 | + 'Meta': {'object_name': 'User'}, | |
25 | + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | |
26 | + 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75', 'blank': 'True'}), | |
27 | + 'facebook': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | |
28 | + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | |
29 | + 'google_talk': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), | |
30 | + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), | |
31 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |
32 | + 'institution': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | |
33 | + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), | |
34 | + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | |
35 | + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), | |
36 | + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), | |
37 | + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), | |
38 | + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), | |
39 | + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | |
40 | + 'role': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | |
41 | + 'twitter': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), | |
42 | + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), | |
43 | + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}), | |
44 | + 'verification_hash': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}), | |
45 | + 'webpage': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}) | |
46 | + }, | |
47 | + u'auth.group': { | |
48 | + 'Meta': {'object_name': 'Group'}, | |
49 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |
50 | + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), | |
51 | + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) | |
52 | + }, | |
53 | + u'auth.permission': { | |
54 | + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, | |
55 | + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |
56 | + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), | |
57 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |
58 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |
59 | + }, | |
60 | + u'contenttypes.contenttype': { | |
61 | + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, | |
62 | + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |
63 | + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |
64 | + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |
65 | + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + complete_apps = ['accounts'] | ... | ... |
src/accounts/models.py
... | ... | @@ -16,6 +16,7 @@ class User(AbstractUser): |
16 | 16 | google_talk = models.EmailField(null=True, blank=True) |
17 | 17 | webpage = models.CharField(max_length=256, null=True, blank=True) |
18 | 18 | verification_hash = models.CharField(max_length=32, null=True, blank=True) |
19 | + modified = models.DateTimeField(auto_now=True) | |
19 | 20 | |
20 | 21 | def get_absolute_url(self): |
21 | 22 | return reverse('user_profile', kwargs={'username': self.username}) | ... | ... |
src/accounts/search_indexes.py
... | ... | @@ -42,7 +42,7 @@ class UserIndex(indexes.SearchIndex, indexes.Indexable): |
42 | 42 | return self._badge_counters |
43 | 43 | |
44 | 44 | def get_updated_field(self): |
45 | - return 'date_joined' | |
45 | + return 'modified' | |
46 | 46 | |
47 | 47 | def prepare(self, obj): |
48 | 48 | prepared_data = super(UserIndex, self).prepare(obj) | ... | ... |