Permalink
Browse files

Play around with migrations some more to get them to work

  • Loading branch information...
1 parent 7157510 commit d4d4ad10b7776dac831602260a4de57891b5c7f4 @cnorthwood cnorthwood committed May 26, 2011
@@ -46,25 +46,12 @@ def forwards(self, orm):
verbose_name=et.verbose_name,
verbose_name_plural=et.verbose_name_plural,
)
-
- # Deleting field 'EntityType.verbose_name_plural'
- db.delete_column('places_entitytype', 'verbose_name_plural')
-
- # Deleting field 'EntityType.article'
- db.delete_column('places_entitytype', 'article')
-
- # Deleting field 'EntityType.verbose_name'
- db.delete_column('places_entitytype', 'verbose_name')
- for eg in EntityGroup.objects.all():
+ for eg in orm.EntityGroup.objects.all():
eg.names.create(language_code=settings.LANGUAGE_CODE,
title=eg.title)
-
- # Deleting field 'EntityGroup.title'
- db.delete_column('places_entitygroup', 'title')
-
- for e in Entity.objects.all():
+ for e in orm.Entity.objects.all():
e.names.create(language_code=settings.LANGUAGE_CODE,
title=e.title)
@@ -73,32 +60,6 @@ def forwards(self, orm):
def backwards(self, orm):
-
- # Adding field 'EntityGroup.title'
- db.add_column('places_entitygroup', 'title', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
-
- for eg in orm.EntityGroup.objects.all():
- eg.title = name_in_category(eg, 'title')
-
- # Adding field 'Entity.title'
- db.add_column('places_entity', 'title', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
-
- for e in orm.Entity.objects.all():
- e.title = name_in_category(eg, 'title')
-
- # Adding field 'EntityType.verbose_name_plural'
- db.add_column('places_entitytype', 'verbose_name_plural', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
-
- # Adding field 'EntityType.article'
- db.add_column('places_entitytype', 'article', self.gf('django.db.models.fields.TextField')(default='', blank=True, max_length=2), keep_default=False)
-
- # Adding field 'EntityType.verbose_name'
- db.add_column('places_entitytype', 'verbose_name', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
-
- for e in orm.Entity.objects.all():
- e.article = name_in_category(eg, 'verbose_name_singular').split()[0]
- e.verbose_name = name_in_category(eg, 'verbose_name')
- e.verbose_name_plural = name_in_category(eg, 'verbose_name_plural')
# Deleting model 'EntityName'
db.delete_table('places_entityname')
@@ -128,13 +89,15 @@ def backwards(self, orm):
'location': ('django.contrib.gis.db.models.fields.PointField', [], {'null': 'True'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Entity']", 'null': 'True'}),
'primary_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.EntityType']", 'null': 'True'}),
- 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Source']"})
+ 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Source']"}),
+ 'title': ('django.db.models.fields.TextField', [], {}),
},
'places.entitygroup': {
'Meta': {'object_name': 'EntityGroup'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ref_code': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
- 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Source']"})
+ 'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Source']"}),
+ 'title': ('django.db.models.fields.TextField', [], {})
},
'places.entitygroupname': {
'Meta': {'object_name': 'EntityGroupName'},
@@ -159,7 +122,10 @@ def backwards(self, orm):
'show_in_nearby_list': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
'subtype_of': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subtypes'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
- 'subtype_of_completion': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subtypes_completion'", 'blank': 'True', 'to': "orm['places.EntityType']"})
+ 'subtype_of_completion': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subtypes_completion'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
+ 'article': ('django.db.models.fields.CharField', [], {'max_length': 2}),
+ 'verbose_name': ('django.db.models.fields.TextField', [], {}),
+ 'verbose_name_plural': ('django.db.models.fields.TextField', [], {})
},
'places.entitytypecategory': {
'Meta': {'object_name': 'EntityTypeCategory'},
@@ -7,6 +7,17 @@
class Migration(SchemaMigration):
def forwards(self, orm):
+ # Deleting field 'EntityType.verbose_name_plural'
+ db.delete_column('places_entitytype', 'verbose_name_plural')
+
+ # Deleting field 'EntityType.article'
+ db.delete_column('places_entitytype', 'article')
+
+ # Deleting field 'EntityType.verbose_name'
+ db.delete_column('places_entitytype', 'verbose_name')
+
+ # Deleting field 'EntityGroup.title'
+ db.delete_column('places_entitygroup', 'title')
# Adding unique constraint on 'EntityName', fields ['language_code', 'entity']
db.create_unique('places_entityname', ['language_code', 'entity_id'])
@@ -28,6 +39,32 @@ def backwards(self, orm):
# Removing unique constraint on 'EntityName', fields ['language_code', 'entity']
db.delete_unique('places_entityname', ['language_code', 'entity_id'])
+
+ # Adding field 'EntityGroup.title'
+ db.add_column('places_entitygroup', 'title', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ for eg in orm.EntityGroup.objects.all():
+ eg.title = name_in_category(eg, 'title')
+
+ # Adding field 'Entity.title'
+ db.add_column('places_entity', 'title', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ for e in orm.Entity.objects.all():
+ e.title = name_in_category(eg, 'title')
+
+ # Adding field 'EntityType.verbose_name_plural'
+ db.add_column('places_entitytype', 'verbose_name_plural', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ # Adding field 'EntityType.article'
+ db.add_column('places_entitytype', 'article', self.gf('django.db.models.fields.CharField')(default='', blank=True, max_length=2), keep_default=False)
+
+ # Adding field 'EntityType.verbose_name'
+ db.add_column('places_entitytype', 'verbose_name', self.gf('django.db.models.fields.TextField')(default='', blank=True), keep_default=False)
+
+ for e in orm.Entity.objects.all():
+ e.article = name_in_category(eg, 'verbose_name_singular').split()[0]
+ e.verbose_name = name_in_category(eg, 'verbose_name')
+ e.verbose_name_plural = name_in_category(eg, 'verbose_name_plural')
models = {
@@ -91,7 +91,7 @@ def save(self, *args, **kwargs):
class EntityTypeName(models.Model):
entity_type = models.ForeignKey(EntityType, related_name='names')
- language_code = models.CharField(max_length=10)
+ language_code = models.CharField(max_length=10, choices=settings.LANGUAGES)
verbose_name = models.TextField()
verbose_name_singular = models.TextField()
verbose_name_plural = models.TextField()
@@ -132,7 +132,7 @@ def __unicode__(self):
class EntityGroupName(models.Model):
entity_group = models.ForeignKey(EntityGroup, related_name='names')
title = models.TextField(blank=False)
- language_code = models.CharField(max_length=10)
+ language_code = models.CharField(max_length=10, choices=settings.LANGUAGES)
class Meta:
unique_together = ('entity_group', 'language_code')
@@ -344,7 +344,7 @@ def simplify_for_render(self, simplify_value, simplify_model):
class EntityName(models.Model):
entity = models.ForeignKey(Entity, related_name='names')
title = models.TextField(blank=False)
- language_code = models.CharField(max_length=10)
+ language_code = models.CharField(max_length=10, choices=settings.LANGUAGES)
class Meta:
unique_together = ('entity', 'language_code')
@@ -14,6 +14,8 @@ def forwards(self, orm):
('webcam', self.gf('django.db.models.fields.related.ForeignKey')(related_name='names', to=orm['webcams.Webcam'])),
('language_code', self.gf('django.db.models.fields.CharField')(max_length=10)),
('title', self.gf('django.db.models.fields.TextField')()),
+ ('description', self.gf('django.db.models.fields.TextField')()),
+ ('credit', self.gf('django.db.models.fields.TextField')()),
))
db.send_create_signal('webcams', ['WebcamName'])
@@ -40,6 +42,8 @@ def backwards(self, orm):
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'title': ('django.db.models.fields.TextField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'credit': ('django.db.models.fields.TextField', [], {}),
'webcam': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'names'", 'to': "orm['webcams.Webcam']"})
}
}
@@ -14,7 +14,9 @@ def forwards(self, orm):
"""
for webcam in orm.Webcam.objects.all():
webcam.names.create(language_code=settings.LANGUAGE_CODE,
- title=webcam.title)
+ title=webcam.title,
+ credit=webcam.credit,
+ description=webcam.description)
def backwards(self, orm):
@@ -23,7 +25,8 @@ def backwards(self, orm):
"""
for webcam in orm.Webcam.objects.all():
webcam.title = name_in_language(webcam, 'title')
-
+ webcam.description = name_in_language(webcam, 'description')
+ webcam.credit = name_in_language(webcam, 'credit')
models = {
'webcams.webcam': {
@@ -41,6 +44,8 @@ def backwards(self, orm):
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'title': ('django.db.models.fields.TextField', [], {}),
+ 'credit': ('django.db.models.fields.TextField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {}),
'webcam': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'names'", 'to': "orm['webcams.Webcam']"})
}
}
@@ -10,19 +10,21 @@ def forwards(self, orm):
# Deleting field 'Webcam.title'
db.delete_column('webcams_webcam', 'title')
+ db.delete_column('webcams_webcam', 'credit')
+ db.delete_column('webcams_webcam', 'description')
def backwards(self, orm):
# Adding field 'Webcam.title'
db.add_column('webcams_webcam', 'title', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False)
+ db.add_column('webcams_webcam', 'credit', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False)
+ db.add_column('webcams_webcam', 'description', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False)
models = {
'webcams.webcam': {
'Meta': {'object_name': 'Webcam'},
- 'credit': ('django.db.models.fields.TextField', [], {'null': 'True'}),
- 'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'fetch_period': ('django.db.models.fields.PositiveIntegerField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
@@ -33,6 +35,8 @@ def backwards(self, orm):
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language_code': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
'title': ('django.db.models.fields.TextField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'credit': ('django.db.models.fields.TextField', [], {}),
'webcam': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'names'", 'to': "orm['webcams.Webcam']"})
}
}
@@ -1,4 +1,5 @@
from django.db import models
+from django.conf import settings
from molly.utils.i18n import name_in_language
@@ -8,15 +9,23 @@ class Webcam(models.Model):
slug = models.SlugField()
url = models.URLField()
fetch_period = models.PositiveIntegerField()
- description = models.TextField(null=True)
- credit = models.TextField(null=True)
@property
def title(self):
return name_in_language(self, 'title')
+
+ @property
+ def description(self):
+ return name_in_language(self, 'description')
+
+ @property
+ def credit(self):
+ return name_in_language(self, 'credit')
class WebcamName(models.Model):
webcam = models.ForeignKey(Webcam, related_name='names')
- language_code = models.CharField(max_length=10)
- title = models.TextField()
+ language_code = models.CharField(max_length=10, choices=settings.LANGUAGES)
+ title = models.TextField()
+ description = models.TextField()
+ credit = models.TextField()

0 comments on commit d4d4ad1

Please sign in to comment.