migrate Seen to django models and whatnot
this also adds south and django_extensions stuff, because that is the natural thing to do. this is a pretty good start, i think
This commit is contained in:
0
seen/__init__.py
Normal file
0
seen/__init__.py
Normal file
12
seen/admin.py
Normal file
12
seen/admin.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from seen.models import SeenNick
|
||||
|
||||
|
||||
class SeenNickAdmin(admin.ModelAdmin):
|
||||
list_display = ('__unicode__', 'seen_time')
|
||||
|
||||
|
||||
admin.site.register(SeenNick, SeenNickAdmin)
|
||||
|
||||
# vi:tabstop=4:expandtab:autoindent
|
||||
46
seen/migrations/0001_seen_data.py
Normal file
46
seen/migrations/0001_seen_data.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from south.utils import datetime_utils as datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'SeenNick'
|
||||
db.create_table(u'seen_seennick', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('nick', self.gf('django.db.models.fields.CharField')(max_length=64)),
|
||||
('channel', self.gf('django.db.models.fields.CharField')(max_length=64)),
|
||||
('host', self.gf('django.db.models.fields.CharField')(max_length=255)),
|
||||
('seen_time', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True)),
|
||||
('what', self.gf('django.db.models.fields.TextField')()),
|
||||
))
|
||||
db.send_create_signal(u'seen', ['SeenNick'])
|
||||
|
||||
# Adding unique constraint on 'SeenNick', fields ['nick', 'channel']
|
||||
db.create_unique(u'seen_seennick', ['nick', 'channel'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Removing unique constraint on 'SeenNick', fields ['nick', 'channel']
|
||||
db.delete_unique(u'seen_seennick', ['nick', 'channel'])
|
||||
|
||||
# Deleting model 'SeenNick'
|
||||
db.delete_table(u'seen_seennick')
|
||||
|
||||
|
||||
models = {
|
||||
u'seen.seennick': {
|
||||
'Meta': {'ordering': "['-seen_time']", 'unique_together': "(('nick', 'channel'),)", 'object_name': 'SeenNick'},
|
||||
'channel': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
|
||||
'host': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'nick': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
|
||||
'seen_time': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}),
|
||||
'what': ('django.db.models.fields.TextField', [], {})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['seen']
|
||||
0
seen/migrations/__init__.py
Normal file
0
seen/migrations/__init__.py
Normal file
29
seen/models.py
Normal file
29
seen/models.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
from django_extensions.db.fields import ModificationDateTimeField
|
||||
|
||||
|
||||
class SeenNick(models.Model):
|
||||
|
||||
"""Track when a nick was seen in any channel."""
|
||||
|
||||
nick = models.CharField(max_length=64)
|
||||
channel = models.CharField(max_length=64)
|
||||
|
||||
host = models.CharField(max_length=255)
|
||||
seen_time = ModificationDateTimeField(editable=True)
|
||||
what = models.TextField()
|
||||
|
||||
class Meta:
|
||||
ordering = ['-seen_time',]
|
||||
unique_together = ('nick', 'channel')
|
||||
|
||||
def __unicode__(self):
|
||||
"""String representation of a seen nick."""
|
||||
|
||||
local_time = timezone.localtime(self.seen_time)
|
||||
return u"{0:s} seen in {1:s} at {2:s}".format(self.nick, self.channel,
|
||||
local_time.strftime('%Y-%m-%d %H:%M:%S %Z'))
|
||||
|
||||
# vi:tabstop=4:expandtab:autoindent
|
||||
Reference in New Issue
Block a user