From 1d6fea38c431226f53c203bf6cc44bd5ffd8bbbb Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Thu, 15 Aug 2013 19:06:15 +0200 Subject: [PATCH] Cleaned up models. --- ...__del_field_snippet_content_highlighted.py | 39 +++++++++++++++++++ dpaste/models.py | 8 ++-- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py diff --git a/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py b/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py new file mode 100644 index 0000000..2cc1695 --- /dev/null +++ b/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py @@ -0,0 +1,39 @@ +# -*- coding: 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 'Snippet.content_highlighted' + db.delete_column(u'dpaste_snippet', 'content_highlighted') + + + def backwards(self, orm): + # Adding field 'Snippet.content_highlighted' + db.add_column(u'dpaste_snippet', 'content_highlighted', + self.gf('django.db.models.fields.TextField')(default='', blank=True), + keep_default=False) + + + models = { + u'dpaste.snippet': { + 'Meta': {'ordering': "('-published',)", 'object_name': 'Snippet'}, + 'content': ('django.db.models.fields.TextField', [], {}), + 'expires': ('django.db.models.fields.DateTimeField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'lexer': ('django.db.models.fields.CharField', [], {'default': "'Python'", 'max_length': '30'}), + 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': u"orm['dpaste.Snippet']"}), + 'published': ('django.db.models.fields.DateTimeField', [], {'blank': 'True'}), + 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'secret_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) + } + } + + complete_apps = ['dpaste'] \ No newline at end of file diff --git a/dpaste/models.py b/dpaste/models.py index a055101..1b670d1 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -13,10 +13,9 @@ def generate_secret_id(length=5): class Snippet(models.Model): secret_id = models.CharField(_(u'Secret ID'), max_length=255, blank=True) content = models.TextField(_(u'Content'), ) - content_highlighted = models.TextField(_(u'Highlighted Content'), blank=True) lexer = models.CharField(_(u'Lexer'), max_length=30, default=LEXER_DEFAULT) published = models.DateTimeField(_(u'Published'), blank=True) - expires = models.DateTimeField(_(u'Expires'), blank=True, help_text='asdf') + expires = models.DateTimeField(_(u'Expires'), blank=True) parent = models.ForeignKey('self', null=True, blank=True, related_name='children') class Meta: @@ -27,7 +26,7 @@ class Snippet(models.Model): return len(self.content.splitlines()) def content_splitted(self): - return self.content_highlighted.splitlines() + return self.content.splitlines() @property def is_single(self): @@ -37,13 +36,12 @@ class Snippet(models.Model): if not self.pk: self.published = datetime.datetime.now() self.secret_id = generate_secret_id() - self.content_highlighted = self.content super(Snippet, self).save(*args, **kwargs) def get_absolute_url(self): return reverse('snippet_details', kwargs={'snippet_id': self.secret_id}) def __unicode__(self): - return '%s' % self.secret_id + return self.secret_id mptt.register(Snippet, order_insertion_by=['content']) \ No newline at end of file