Kevin Veroneau avatar Kevin Veroneau committed 0923027 Draft

Initial support for the model creator and exportor component.

Comments (0)

Files changed (2)

django_helper/migrations/0002_auto__add_model__add_fieldtype__add_field.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 'Model'
+        db.create_table('django_helper_model', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=40)),
+        ))
+        db.send_create_signal('django_helper', ['Model'])
+
+        # Adding model 'FieldType'
+        db.create_table('django_helper_fieldtype', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=40)),
+            ('backend_storage', self.gf('django.db.models.fields.PositiveSmallIntegerField')()),
+        ))
+        db.send_create_signal('django_helper', ['FieldType'])
+
+        # Adding model 'Field'
+        db.create_table('django_helper_field', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.CharField')(max_length=40)),
+            ('model', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['django_helper.Model'])),
+            ('field_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['django_helper.FieldType'])),
+            ('null', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('blank', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('db_column', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+            ('db_index', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('db_tablespace', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+            ('default', self.gf('django.db.models.fields.CharField')(max_length=80, null=True, blank=True)),
+            ('editable', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('help_text', self.gf('django.db.models.fields.CharField')(max_length=80, null=True, blank=True)),
+            ('primary_key', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('unique', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('unique_for_date', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='date_set', null=True, to=orm['django_helper.Field'])),
+            ('unique_for_month', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='month_set', null=True, to=orm['django_helper.Field'])),
+            ('unique_for_year', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='year_set', null=True, to=orm['django_helper.Field'])),
+            ('verbose_name', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+            ('max_length', self.gf('django.db.models.fields.IntegerField')(null=True, blank=True)),
+            ('auto_now', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('auto_now_add', self.gf('django.db.models.fields.BooleanField')(default=False)),
+            ('max_digits', self.gf('django.db.models.fields.IntegerField')()),
+            ('decimal_places', self.gf('django.db.models.fields.IntegerField')()),
+            ('upload_to', self.gf('django.db.models.fields.CharField')(max_length=80, null=True, blank=True)),
+            ('othermodel', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='othermodel_set', null=True, to=orm['django_helper.Model'])),
+            ('limit_choices_to', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+            ('related_name', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+            ('to_field', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='foreign_set', null=True, to=orm['django_helper.Field'])),
+            ('on_delete', self.gf('django.db.models.fields.PositiveSmallIntegerField')(null=True, blank=True)),
+            ('through', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='through_set', null=True, to=orm['django_helper.Model'])),
+            ('db_table', self.gf('django.db.models.fields.CharField')(max_length=40, null=True, blank=True)),
+        ))
+        db.send_create_signal('django_helper', ['Field'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'Model'
+        db.delete_table('django_helper_model')
+
+        # Deleting model 'FieldType'
+        db.delete_table('django_helper_fieldtype')
+
+        # Deleting model 'Field'
+        db.delete_table('django_helper_field')
+
+
+    models = {
+        'django_helper.contextprocessor': {
+            'Meta': {'object_name': 'ContextProcessor'},
+            'added_on': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'app_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+            'description': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+            'required_middleware': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['django_helper.Middleware']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'django_helper.field': {
+            'Meta': {'object_name': 'Field'},
+            'auto_now': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'auto_now_add': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'blank': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'db_column': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'db_index': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'db_table': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'db_tablespace': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'decimal_places': ('django.db.models.fields.IntegerField', [], {}),
+            'default': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
+            'editable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'field_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_helper.FieldType']"}),
+            'help_text': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'limit_choices_to': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'max_digits': ('django.db.models.fields.IntegerField', [], {}),
+            'max_length': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'model': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['django_helper.Model']"}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'null': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'on_delete': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'othermodel': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'othermodel_set'", 'null': 'True', 'to': "orm['django_helper.Model']"}),
+            'primary_key': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'related_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+            'through': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'through_set'", 'null': 'True', 'to': "orm['django_helper.Model']"}),
+            'to_field': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'foreign_set'", 'null': 'True', 'to': "orm['django_helper.Field']"}),
+            'unique': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'unique_for_date': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'date_set'", 'null': 'True', 'to': "orm['django_helper.Field']"}),
+            'unique_for_month': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'month_set'", 'null': 'True', 'to': "orm['django_helper.Field']"}),
+            'unique_for_year': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'year_set'", 'null': 'True', 'to': "orm['django_helper.Field']"}),
+            'upload_to': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True', 'blank': 'True'}),
+            'verbose_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'})
+        },
+        'django_helper.fieldtype': {
+            'Meta': {'object_name': 'FieldType'},
+            'backend_storage': ('django.db.models.fields.PositiveSmallIntegerField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'})
+        },
+        'django_helper.middleware': {
+            'Meta': {'object_name': 'Middleware'},
+            'added_on': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'app_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+            'description': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'process_exception': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'process_request': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'process_response': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'process_template_response': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'process_view': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+        },
+        'django_helper.model': {
+            'Meta': {'object_name': 'Model'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'})
+        },
+        'django_helper.templatetag': {
+            'Meta': {'object_name': 'TemplateTag'},
+            'added_on': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'app_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+            'description': ('django.db.models.fields.TextField', [], {}),
+            'examples': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'parameters': ('django.db.models.fields.CharField', [], {'max_length': '60', 'blank': 'True'}),
+            'required_context': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['django_helper.ContextProcessor']", 'symmetrical': 'False', 'blank': 'True'}),
+            'tag_name': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),
+            'tag_type': ('django.db.models.fields.PositiveSmallIntegerField', [], {}),
+            'takes_context': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'template': ('django.db.models.fields.CharField', [], {'max_length': '80', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['django_helper']

django_helper/models.py

     added_on = models.DateField(auto_now_add=True)
     def __unicode__(self):
         return u"%s" % self.tag_name
+
+# Model designer components
+
+class Model(models.Model):
+    name = models.CharField(max_length=40)
+    def __unicode__(self):
+        return u"%s" % self.name
+
+class FieldType(models.Model):
+    STORAGE_TYPES = (
+        (0, 'Custom'),
+        (1, 'String'),
+        (2, 'Integer'),
+        (3, 'Boolean'),
+        (4, 'DateTime'),
+    )
+    name = models.CharField(max_length=40, help_text='Case-sensitive, used during model generation.')
+    backend_storage = models.PositiveSmallIntegerField(choices=STORAGE_TYPES, help_text='Used to determine how the field parameters are generated.')
+    def __unicode__(self):
+        return u"%s" % self.name
+
+class Field(models.Model):
+    DELETE_CHOICES = (
+        (0, 'CASCADE'),
+        (1, 'PROTECT'),
+        (2, 'SET_NULL'),
+        (3, 'SET_DEFAULT'),
+        (5, 'DO_NOTHING'),
+    )
+    name = models.CharField(max_length=40)
+    model = models.ForeignKey(Model)
+    field_type = models.ForeignKey(FieldType)
+    null = models.BooleanField()
+    blank = models.BooleanField()
+    db_column = models.CharField(max_length=40, blank=True, null=True)
+    db_index = models.BooleanField()
+    db_tablespace = models.CharField(max_length=40, blank=True, null=True)
+    default = models.CharField(max_length=80, blank=True, null=True)
+    editable = models.BooleanField()
+    help_text = models.CharField(max_length=80, blank=True, null=True)
+    primary_key = models.BooleanField()
+    unique = models.BooleanField()
+    unique_for_date = models.ForeignKey('self', blank=True, null=True, related_name='date_set')
+    unique_for_month = models.ForeignKey('self', blank=True, null=True, related_name='month_set')
+    unique_for_year = models.ForeignKey('self', blank=True, null=True, related_name='year_set')
+    verbose_name = models.CharField(max_length=40, blank=True, null=True)
+    max_length = models.IntegerField(blank=True, null=True)
+    auto_now = models.BooleanField()
+    auto_now_add = models.BooleanField()
+    max_digits = models.IntegerField()
+    decimal_places = models.IntegerField()
+    upload_to = models.CharField(max_length=80, blank=True, null=True)
+    othermodel = models.ForeignKey(Model, blank=True, null=True, related_name='othermodel_set')
+    limit_choices_to = models.CharField(max_length=40, blank=True, null=True)
+    related_name = models.CharField(max_length=40, blank=True, null=True)
+    to_field = models.ForeignKey('self', blank=True, null=True, related_name='foreign_set')
+    on_delete = models.PositiveSmallIntegerField(choices=DELETE_CHOICES, blank=True, null=True)
+    through = models.ForeignKey(Model, blank=True, null=True, related_name='through_set')
+    db_table = models.CharField(max_length=40, blank=True, null=True)
+    def __unicode__(self):
+        return u"%s" % self.name
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.