예제 #1
0
def prep_for_freeze(model):
    """
    Takes a model and returns the ready-to-serialise dict (all you need
    to do is just pretty-print it).
    """
    fields = modelsinspector.get_model_fields(model, m2m=True)
    # Remove useless attributes (like 'choices')
    for name, field in fields.items():
        fields[name] = remove_useless_attributes(field)
    # See if there's a Meta
    fields['Meta'] = remove_useless_meta(modelsinspector.get_model_meta(model))
    # Add in our own special items to track the object name and managed
    fields['Meta']['object_name'] = model._meta.object_name # Special: not eval'able.
    if not getattr(model._meta, "managed", True):
        fields['Meta']['managed'] = repr(model._meta.managed)
    return fields
예제 #2
0
def prep_for_freeze(model):
    """
    Takes a model and returns the ready-to-serialise dict (all you need
    to do is just pretty-print it).
    """
    fields = modelsinspector.get_model_fields(model, m2m=True)
    # Remove useless attributes (like 'choices')
    for name, field in fields.items():
        fields[name] = remove_useless_attributes(field)
    # See if there's a Meta
    fields['Meta'] = remove_useless_meta(modelsinspector.get_model_meta(model))
    # Add in our own special items to track the object name and managed
    fields['Meta']['object_name'] = model._meta.object_name # Special: not eval'able.
    if not getattr(model._meta, "managed", True):
        fields['Meta']['managed'] = repr(model._meta.managed)
    return fields
예제 #3
0
def prep_for_stub(model, last_models=None):
    if last_models:
        fields = last_models[model_key(model)]
    else:
        fields = modelsinspector.get_model_fields(model)
    # Now, take only the PK (and a 'we're a stub' field) and freeze 'em
    pk = model._meta.pk.name
    fields = {pk: ormise_triple(model._meta.pk, remove_useless_attributes(fields[pk])), "_stub": True}
    # Meta is important too.
    if last_models:
        meta = last_models[model_key(model)].get("Meta", {})
    else:
        meta = modelsinspector.get_model_meta(model)
    if meta:
        fields["Meta"] = remove_useless_meta(meta)
    return fields
예제 #4
0
def prep_for_freeze(model, last_models=None):
    # If we have a set of models to use, use them.
    if last_models:
        fields = last_models[model_key(model)]
    else:
        fields = modelsinspector.get_model_fields(model, m2m=True)
    # Remove useless attributes (like 'choices')
    for name, field in fields.items():
        real_field = model._meta.get_field_by_name(name)[0]
        fields[name] = ormise_triple(real_field, remove_useless_attributes(field))
    # See if there's a Meta
    if last_models:
        meta = last_models[model_key(model)].get("Meta", {})
    else:
        meta = modelsinspector.get_model_meta(model)
    if meta:
        fields["Meta"] = remove_useless_meta(meta)
    return fields
예제 #5
0
def prep_for_freeze(model, last_models=None):
    # If we have a set of models to use, use them.
    if last_models:
        fields = last_models[model_key(model)]
    else:
        fields = modelsinspector.get_model_fields(model, m2m=True)
    # Remove _stub if it stuck in
    if "_stub" in fields:
        del fields["_stub"]
    # Remove useless attributes (like 'choices')
    for name, field in fields.items():
        if name == "Meta":
            continue
        real_field = model._meta.get_field_by_name(name)[0]
        fields[name] = ormise_triple(real_field, remove_useless_attributes(field))
    # See if there's a Meta
    if last_models:
        meta = last_models[model_key(model)].get("Meta", {})
    else:
        meta = modelsinspector.get_model_meta(model)
    if meta:
        fields['Meta'] = remove_useless_meta(meta)
    return fields
예제 #6
0
class Migration(SchemaMigration):

    def forwards(self, orm):

        # Adding model 'DashboardPreferences'
        db.create_table('admin_tools_dashboard_preferences', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_model])),
            ('data', self.gf('django.db.models.fields.TextField')()),
        ))
        db.send_create_signal('dashboard', ['DashboardPreferences'])


    def backwards(self, orm):

        # Deleting model 'DashboardPreferences'
        db.delete_table('admin_tools_dashboard_preferences')


    models = {
        'auth.group': {
            'Meta': {'object_name': 'Group'},
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
        },
        'auth.permission': {
            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
        },
        user_model: {
            'Meta': modelsinspector.get_model_meta(UserModel),
            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
        },
        'contenttypes.contenttype': {
            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
        },
        'dashboard.dashboardpreferences': {
            'Meta': {'ordering': "('user',)", 'object_name': 'DashboardPreferences', 'db_table': "'admin_tools_dashboard_preferences'"},
            'data': ('django.db.models.fields.TextField', [], {}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['%s']" % user_model})
        }
    }

    complete_apps = ['dashboard']