Commits

Doug Tyler committed 7ce0375

Fix typo in Priority model; Add defaults for ForeignKeys in UserStory model

  • Participants
  • Parent commits 0278c5e

Comments (0)

Files changed (2)

File user_stories/stories/migrations/0002_auto__add_priority__add_field_userstory_priority.py

+# -*- 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):
+        # Adding model 'Priority'
+        db.create_table(u'stories_priority', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=10)),
+            ('value', self.gf('django.db.models.fields.SmallIntegerField')()),
+        ))
+        db.send_create_signal(u'stories', ['Priority'])
+
+        # Adding field 'UserStory.priority'
+        db.add_column(u'stories_userstory', 'priority',
+                      self.gf('django.db.models.fields.related.ForeignKey')(default='Visitor', to=orm['stories.Priority']),
+                      keep_default=False)
+
+
+    def backwards(self, orm):
+        # Deleting model 'Priority'
+        db.delete_table(u'stories_priority')
+
+        # Deleting field 'UserStory.priority'
+        db.delete_column(u'stories_userstory', 'priority_id')
+
+
+    models = {
+        u'stories.priority': {
+            'Meta': {'object_name': 'Priority'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
+            'value': ('django.db.models.fields.SmallIntegerField', [], {})
+        },
+        u'stories.role': {
+            'Meta': {'object_name': 'Role'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '30'})
+        },
+        u'stories.userstory': {
+            'Meta': {'object_name': 'UserStory'},
+            'action': ('django.db.models.fields.CharField', [], {'max_length': '140'}),
+            'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'date_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'auto_now_add': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'priority': ('django.db.models.fields.related.ForeignKey', [], {'default': "'Visitor'", 'to': u"orm['stories.Priority']"}),
+            'reason': ('django.db.models.fields.CharField', [], {'max_length': '140'}),
+            'role': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['stories.Role']"})
+        }
+    }
+
+    complete_apps = ['stories']

File user_stories/stories/models.py

         return self.name
 
 
-class Priority:
+class Priority(models.Model):
     name = models.CharField(max_length=10)
     value = models.SmallIntegerField()
 
 
 
 class UserStory(models.Model):
-    role = models.ForeignKey('Role')
+    role = models.ForeignKey('Role', default='Visitor')
     action = models.CharField(max_length=140)
     reason = models.CharField(max_length=140)
-    priority = models.ForeignKey('Priority')
+    priority = models.ForeignKey('Priority', default='Low')
     date_added = models.DateTimeField(auto_now=False, auto_now_add=True)
     date_updated = models.DateTimeField(auto_now=True, auto_now_add=True)