diff --git a/.gitignore b/.gitignore index b9f07bb..a4c7e1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc greav +omrs ~* *.orig *.db diff --git a/eav_ng/models.py b/eav_ng/models.py index 3525164..81b86f9 100644 --- a/eav_ng/models.py +++ b/eav_ng/models.py @@ -11,7 +11,7 @@ class EavEntity(object): def __init__(self, instance): self.model = instance - ''' + def get_current_eav_attributes(self): try: if self._attributes_cache is not None: @@ -29,7 +29,7 @@ class EavEntity(object): @classmethod def get_eav_attributes(cls): return EavAttribute.objects.all() - ''' + class EavAttribute(models.Model): diff --git a/eav_ng/tests/models.py b/eav_ng/tests/models.py index 56dc254..f6f726d 100644 --- a/eav_ng/tests/models.py +++ b/eav_ng/tests/models.py @@ -1,14 +1,11 @@ from django.db import models -from eav_ng.models import EavEntity, EavAttribute -from eav_ng.utils import EavRegistry +from ..utils import EavRegistry -# Create your models here. class Patient(models.Model): class Meta: app_label = 'eav_ng' - name = models.CharField(max_length=20) def __unicode__(self): diff --git a/eav_ng/tests/tests.py b/eav_ng/tests/tests.py index f551742..d20f149 100644 --- a/eav_ng/tests/tests.py +++ b/eav_ng/tests/tests.py @@ -1,16 +1,10 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - from datetime import datetime from django.test import TestCase from django.conf import settings + from ..models import * -from ..utils import EavRegistry, EavAdmin +from ..utils import EavRegistry, EavConfig from .models import Patient @@ -141,7 +135,7 @@ class EavBasicTests(TestCase): def test_eavregistry_accept_a_settings_class_with_get_queryset(self): EavRegistry.unregister(Patient) - class PatientEav(EavAdmin): + class PatientEav(EavConfig): def get_eav_attributes(self): return EavAttribute.objects.all() diff --git a/eav_ng/utils.py b/eav_ng/utils.py index fd7ccce..ecb08f1 100644 --- a/eav_ng/utils.py +++ b/eav_ng/utils.py @@ -1,9 +1,8 @@ from django.db.models.signals import post_init -from eav_ng.managers import EntityManager -from eav_ng.models import EavEntity, EavAttribute - -class EavAdmin(object): +from .managers import EntityManager +from .models import EavEntity, EavAttribute +class EavConfig(object): @classmethod def get_eav_attributes(cls): """ @@ -33,7 +32,7 @@ class EavRegistry(object): @staticmethod - def register(model_cls, admin_cls=EavAdmin, eav_proxy_field='eav', + def register(model_cls, admin_cls=EavConfig, eav_proxy_field='eav', eav_manager_field='objects'): """ Inject eav features into the given model and attach a signal diff --git a/settings.py b/settings.py index 08e3fd4..5079346 100644 --- a/settings.py +++ b/settings.py @@ -12,7 +12,7 @@ MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'myeav.db', # Or path to database file if using sqlite3. + 'NAME': 'eav_ng.db', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. @@ -100,6 +100,6 @@ INSTALLED_APPS = ( 'django_extensions', 'eav', 'eav_ng', - #'eav_usage', + 'omrs' )