зеркало из https://github.com/mozilla/batucada.git
There's really no excuse for a model to *not* have a created_on field. Also, created_on is a better name than timestamp.
This commit is contained in:
Родитель
444ef5855a
Коммит
cf9f2158a1
|
@ -37,7 +37,7 @@ def send(actor, verb, obj, target=None, timestamp=None):
|
|||
activity.target_id = target.pk
|
||||
activity.save()
|
||||
if timestamp:
|
||||
log.debug("Setting timestamp to %r" % (repr(timestamp),))
|
||||
activity.timestamp = timestamp
|
||||
log.debug("Setting created_on to %r" % (repr(timestamp),))
|
||||
activity.created_on = timestamp
|
||||
activity.save()
|
||||
return activity
|
||||
|
|
|
@ -100,7 +100,7 @@ class UserActivityAtomFeed(Feed):
|
|||
})
|
||||
|
||||
def item_pubdate(self, item):
|
||||
return item.timestamp
|
||||
return item.created_on
|
||||
|
||||
def item_extra_kwargs(self, item):
|
||||
obj_id = self.request.build_absolute_uri(
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Deleting field 'Activity.timestamp'
|
||||
db.delete_column('activity_activity', 'timestamp')
|
||||
|
||||
# Adding field 'Activity.created_on'
|
||||
db.add_column('activity_activity', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Adding field 'Activity.timestamp'
|
||||
db.add_column('activity_activity', 'timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.date(2010, 11, 29), blank=True), keep_default=False)
|
||||
|
||||
# Deleting field 'Activity.created_on'
|
||||
db.delete_column('activity_activity', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'activity.activity': {
|
||||
'Meta': {'ordering': "('-created_on', 'actor')", 'object_name': 'Activity'},
|
||||
'actor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
|
||||
'actor_string': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'obj_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'object'", 'to': "orm['contenttypes.ContentType']"}),
|
||||
'obj_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
|
||||
'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}),
|
||||
'target_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
|
||||
'verb': ('django.db.models.fields.CharField', [], {'max_length': '120'})
|
||||
},
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['activity']
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User
|
||||
|
@ -13,7 +15,7 @@ from activity.schema import verbs, UnknownActivityError
|
|||
class ActivityManager(models.Manager):
|
||||
|
||||
def __results(self, predicate, limit):
|
||||
return self.filter(**predicate).order_by('-timestamp')[:limit]
|
||||
return self.filter(**predicate).order_by('-created_on')[:limit]
|
||||
|
||||
def from_user(self, user, limit=None):
|
||||
"""
|
||||
|
@ -50,7 +52,7 @@ class ActivityManager(models.Manager):
|
|||
ids = [u.id for u in user.following() if not isinstance(u, User)]
|
||||
return self.filter(
|
||||
models.Q(actor__in=user_ids) | models.Q(target_id__in=ids),
|
||||
).order_by('-timestamp')[:limit]
|
||||
).order_by('-created_on')[:limit]
|
||||
|
||||
def public(self, limit=None):
|
||||
"""Return a chronological list of activities performed recently."""
|
||||
|
@ -71,13 +73,14 @@ class Activity(models.Model):
|
|||
target_id = models.PositiveIntegerField(null=True)
|
||||
target = generic.GenericForeignKey('target_content_type', 'target_id')
|
||||
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
objects = ActivityManager()
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'activities'
|
||||
ordering = ('-timestamp', 'actor')
|
||||
ordering = ('-created_on', 'actor')
|
||||
|
||||
@property
|
||||
def verb_object(self):
|
||||
|
@ -198,7 +201,7 @@ class Activity(models.Model):
|
|||
"""
|
||||
A slightly modified version of ```django.utils.timesince.timesince```.
|
||||
"""
|
||||
t = timesince(self.timestamp, now)
|
||||
t = timesince(self.created_on, now)
|
||||
c = lambda x: x == "0 minutes" and _("less than a minute") or x
|
||||
d = lambda x: ("hours," in x or "hour," in x) and x.split(',')[0] or x
|
||||
return d(c(t)) + _(" ago")
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Deleting field 'Entry.processed_on'
|
||||
db.delete_column('feeds_entry', 'processed_on')
|
||||
|
||||
# Adding field 'Entry.created_on'
|
||||
db.add_column('feeds_entry', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
# Adding field 'RemoteObject.created_on'
|
||||
db.add_column('feeds_remoteobject', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Adding field 'Entry.processed_on'
|
||||
db.add_column('feeds_entry', 'processed_on', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.date(2010, 11, 29), blank=True), keep_default=False)
|
||||
|
||||
# Deleting field 'Entry.created_on'
|
||||
db.delete_column('feeds_entry', 'created_on')
|
||||
|
||||
# Deleting field 'RemoteObject.created_on'
|
||||
db.delete_column('feeds_remoteobject', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'feeds.entry': {
|
||||
'Meta': {'object_name': 'Entry'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'link': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'feed_entries'", 'to': "orm['projects.Link']"}),
|
||||
'signature': ('django.db.models.fields.CharField', [], {'max_length': '32'})
|
||||
},
|
||||
'feeds.remoteobject': {
|
||||
'Meta': {'object_name': 'RemoteObject'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
|
||||
},
|
||||
'projects.link': {
|
||||
'Meta': {'unique_together': "(('project', 'url'),)", 'object_name': 'Link'},
|
||||
'feed_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['projects.Project']"}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
|
||||
'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
|
||||
},
|
||||
'projects.project': {
|
||||
'Meta': {'object_name': 'Project'},
|
||||
'call_to_action': ('django.db.models.fields.TextField', [], {}),
|
||||
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
|
||||
'css': ('django.db.models.fields.TextField', [], {}),
|
||||
'description': ('django.db.models.fields.TextField', [], {}),
|
||||
'featured': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
|
||||
'template': ('django.db.models.fields.TextField', [], {})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['feeds']
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
from projects.models import Link
|
||||
|
@ -6,12 +8,15 @@ from projects.models import Link
|
|||
class Entry(models.Model):
|
||||
link = models.ForeignKey(Link, related_name='feed_entries')
|
||||
signature = models.CharField(max_length=32)
|
||||
processed_on = models.DateTimeField(auto_now_add=True)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
|
||||
class RemoteObject(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
url = models.URLField()
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding field 'Interest.created_on'
|
||||
db.add_column('profiles_interest', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
# Adding field 'Profile.created_on'
|
||||
db.add_column('profiles_profile', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
# Adding field 'Skill.created_on'
|
||||
db.add_column('profiles_skill', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting field 'Interest.created_on'
|
||||
db.delete_column('profiles_interest', 'created_on')
|
||||
|
||||
# Deleting field 'Profile.created_on'
|
||||
db.delete_column('profiles_profile', 'created_on')
|
||||
|
||||
# Deleting field 'Skill.created_on'
|
||||
db.delete_column('profiles_skill', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'profiles.interest': {
|
||||
'Meta': {'object_name': 'Interest'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'profile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['profiles.Profile']"})
|
||||
},
|
||||
'profiles.profile': {
|
||||
'Meta': {'object_name': 'Profile'},
|
||||
'bio': ('django.db.models.fields.TextField', [], {}),
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'location': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
|
||||
},
|
||||
'profiles.skill': {
|
||||
'Meta': {'object_name': 'Skill'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
|
||||
'profile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['profiles.Profile']"})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['profiles']
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.contrib.auth.models import User
|
||||
|
@ -11,6 +13,8 @@ class Profile(models.Model):
|
|||
location = models.CharField(max_length=255)
|
||||
image = models.ImageField(upload_to='images/profiles/public')
|
||||
bio = models.TextField()
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
def get_full_name(self):
|
||||
return self.user.get_full_name()
|
||||
|
@ -47,12 +51,16 @@ class Skill(models.Model):
|
|||
"""A user profile can have zero or more skills."""
|
||||
profile = models.ForeignKey(Profile)
|
||||
name = models.CharField(max_length=30)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
|
||||
class Interest(models.Model):
|
||||
"""A user profile can have zero or more interests."""
|
||||
profile = models.ForeignKey(Profile)
|
||||
name = models.CharField(max_length=30)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
|
||||
def user_save_handler(sender, **kwargs):
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding field 'Link.created_on'
|
||||
db.add_column('projects_link', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
# Adding field 'Project.created_on'
|
||||
db.add_column('projects_project', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting field 'Link.created_on'
|
||||
db.delete_column('projects_link', 'created_on')
|
||||
|
||||
# Deleting field 'Project.created_on'
|
||||
db.delete_column('projects_project', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'projects.link': {
|
||||
'Meta': {'unique_together': "(('project', 'url'),)", 'object_name': 'Link'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'feed_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['projects.Project']"}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
|
||||
'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
|
||||
},
|
||||
'projects.project': {
|
||||
'Meta': {'object_name': 'Project'},
|
||||
'call_to_action': ('django.db.models.fields.TextField', [], {}),
|
||||
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'css': ('django.db.models.fields.TextField', [], {}),
|
||||
'description': ('django.db.models.fields.TextField', [], {}),
|
||||
'featured': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
|
||||
'template': ('django.db.models.fields.TextField', [], {})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['projects']
|
|
@ -1,4 +1,5 @@
|
|||
import urllib
|
||||
import datetime
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
@ -22,6 +23,8 @@ class Project(models.Model):
|
|||
featured = models.BooleanField()
|
||||
template = models.TextField()
|
||||
css = models.TextField()
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
@ -54,6 +57,8 @@ class Link(models.Model):
|
|||
url = models.URLField()
|
||||
project = models.ForeignKey(Project)
|
||||
feed_url = models.URLField(editable=False, default='')
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
class Meta:
|
||||
unique_together = ('project', 'url',)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding field 'Relationship.created_on'
|
||||
db.add_column('relationships_relationship', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting field 'Relationship.created_on'
|
||||
db.delete_column('relationships_relationship', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'relationships.relationship': {
|
||||
'Meta': {'unique_together': "(('source_content_type', 'target_content_type', 'source_object_id', 'target_object_id'),)", 'object_name': 'Relationship'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'source_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'source_relationships'", 'to': "orm['contenttypes.ContentType']"}),
|
||||
'source_object_id': ('django.db.models.fields.PositiveIntegerField', [], {}),
|
||||
'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'target_relationships'", 'to': "orm['contenttypes.ContentType']"}),
|
||||
'target_object_id': ('django.db.models.fields.PositiveIntegerField', [], {})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['relationships']
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
@ -20,6 +22,9 @@ class Relationship(models.Model):
|
|||
target = generic.GenericForeignKey(
|
||||
'target_content_type', 'target_object_id')
|
||||
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Check that the source and the target are not the same object."""
|
||||
if (self.source == self.target):
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Deleting field 'Status.timestamp'
|
||||
db.delete_column('statuses_status', 'timestamp')
|
||||
|
||||
# Adding field 'Status.created_on'
|
||||
db.add_column('statuses_status', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Adding field 'Status.timestamp'
|
||||
db.add_column('statuses_status', 'timestamp', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.date(2010, 11, 29), blank=True), keep_default=False)
|
||||
|
||||
# Deleting field 'Status.created_on'
|
||||
db.delete_column('statuses_status', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'projects.project': {
|
||||
'Meta': {'object_name': 'Project'},
|
||||
'call_to_action': ('django.db.models.fields.TextField', [], {}),
|
||||
'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'css': ('django.db.models.fields.TextField', [], {}),
|
||||
'description': ('django.db.models.fields.TextField', [], {}),
|
||||
'featured': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
|
||||
'template': ('django.db.models.fields.TextField', [], {})
|
||||
},
|
||||
'statuses.status': {
|
||||
'Meta': {'object_name': 'Status'},
|
||||
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['projects.Project']", 'null': 'True'}),
|
||||
'status': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['statuses']
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
@ -8,13 +10,13 @@ from projects.models import Project
|
|||
|
||||
|
||||
class Status(models.Model):
|
||||
author = models.ForeignKey(User)
|
||||
project = models.ForeignKey(Project, null=True)
|
||||
|
||||
object_type = 'http://activitystrea.ms/schema/1.0/status'
|
||||
|
||||
author = models.ForeignKey(User)
|
||||
project = models.ForeignKey(Project, null=True)
|
||||
status = models.CharField(max_length=1024)
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.status
|
||||
|
@ -26,7 +28,7 @@ class Status(models.Model):
|
|||
})
|
||||
|
||||
def timesince(self, now=None):
|
||||
return timesince(self.timestamp, now)
|
||||
return timesince(self.created_on, now)
|
||||
|
||||
admin.site.register(Status)
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# encoding: utf-8
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Adding field 'ConfirmationToken.created_on'
|
||||
db.add_column('users_confirmationtoken', 'created_on', self.gf('django.db.models.fields.DateTimeField')(default=datetime.date(2010, 11, 29), auto_now_add=True, blank=True), keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Deleting field 'ConfirmationToken.created_on'
|
||||
db.delete_column('users_confirmationtoken', 'created_on')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'users.confirmationtoken': {
|
||||
'Meta': {'object_name': 'ConfirmationToken'},
|
||||
'created_on': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.date(2010, 11, 29)', 'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'token': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['users']
|
|
@ -1,11 +1,16 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from users import auth
|
||||
|
||||
|
||||
class ConfirmationToken(models.Model):
|
||||
"""Store a unique token related to a user account."""
|
||||
user = models.ForeignKey(User, unique=True)
|
||||
token = models.CharField(max_length=128)
|
||||
created_on = models.DateTimeField(
|
||||
auto_now_add=True, default=datetime.date.today())
|
||||
plaintext = ""
|
||||
|
||||
def __unicode__(self):
|
||||
|
@ -27,13 +32,14 @@ class ConfirmationToken(models.Model):
|
|||
self.token = self._hash_token(self.token)
|
||||
super(ConfirmationToken, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
def unique_confirmation_token(user, length=32):
|
||||
"""Create a confirmation token for the given user, deleting existing."""
|
||||
ConfirmationToken.objects.filter(user__exact=user.id).delete()
|
||||
plaintext = User.objects.make_random_password(length=length)
|
||||
token = ConfirmationToken(
|
||||
user=user,
|
||||
token=plaintext
|
||||
token=plaintext,
|
||||
)
|
||||
token.plaintext = plaintext
|
||||
token.save()
|
||||
|
|
Загрузка…
Ссылка в новой задаче