Cleaned up

This commit is contained in:
David Gelvin 2010-09-06 21:22:41 +00:00
parent debe356381
commit f6f61cda85
6 changed files with 13 additions and 22 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
*.pyc
greav
omrs
~*
*.orig
*.db

View file

@ -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):

View file

@ -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):

View file

@ -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()

View file

@ -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

View file

@ -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'
)