willhardy/django-dymo — pull request #2 by z4r (2011-11-13 13:55:31+00:00)
Title: Abstract Contrib

Hi will, thx for the previous fix.

Im sending you my "contrib" module to try to abstract your "previous" project with this new framework.

This is your survey example:

```python
#models.py
from django.db import models
from dymo.contrib import dymodels, registry

class Survey(dymodels.AbstractSchema):
pass

registry.register(schema = Survey)
```

```python
#admin.py
from dymo.contrib import admin
from .models import Survey

admin.register(Survey)
```

I need a "common" entities namespace:

```python
#models.py
from django.db import models
from django.utils.translation import ugettext_lazy as _
from dymo.contrib import dymodels, registry

class ServiceCode(dymodels.AbstractEntity):
name = models.CharField(max_length = 50, primary_key = True)
description = models.TextField(blank = True, null = True)

def __unicode__(self):
return self.name

class Meta:
ordering = ('name',)
verbose_name = _('Service Code')
verbose_name_plural = _('Service Codes')

class SchemaServiceCode(dymodels.AbstractSchema):
class Meta:
verbose_name = _('Service Code Category')
verbose_name_plural = _('Service Codes Category')

registry.register(schema = SchemaServiceCode, entity = ServiceCode)
```

```python
#admin.py
from dymo.contrib import admin
from .models import SchemaServiceCode

admin.register(SchemaServiceCode)
```

Now im studing your validation.py to apply more contraints to Entity.