diff --git a/src/objects/admin.py b/src/objects/admin.py index f57d6faf31..ffb62af803 100644 --- a/src/objects/admin.py +++ b/src/objects/admin.py @@ -12,13 +12,15 @@ from src.typeclasses.models import Tag, LiteAttribute class AttributeInline(admin.TabularInline): + # This class is currently not used, because PickleField objects are not editable. + # It's here for us to ponder making a way that allows them to be edited. model = Attribute fields = ('db_key', 'db_value') extra = 0 class TagInline(admin.TabularInline): - model = Tag - fields = ('db_key', 'db_category', 'db_data') + model = ObjectDB.db_tags.through + raw_id_fields = ('tag',) extra = 0 class LiteAttributeInline(admin.TabularInline): @@ -26,6 +28,9 @@ class LiteAttributeInline(admin.TabularInline): fields = ('db_key', 'db_category', 'db_data') extra = 0 +class TagAdmin(admin.ModelAdmin): + fields = ('db_key', 'db_category', 'db_data') + class ObjectCreateForm(forms.ModelForm): "This form details the look of the fields" class Meta: @@ -83,7 +88,7 @@ class ObjectDBAdmin(admin.ModelAdmin): ) #deactivated temporarily, they cause empty objects to be created in admin - #inlines = [AliasInline, AttributeInline] + inlines = [TagInline] # Custom modification to give two different forms wether adding or not. @@ -125,3 +130,4 @@ class ObjectDBAdmin(admin.ModelAdmin): admin.site.register(ObjectDB, ObjectDBAdmin) +admin.site.register(Tag, TagAdmin) \ No newline at end of file diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 1d3c1daa28..6bbd1b4150 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -97,7 +97,7 @@ class Attribute(SharedMemoryModel): # Attribute Database Model setup # # These database fields are all set using their corresponding properties, - # named same as the field, but withtout the db_* prefix. + # named same as the field, but without the db_* prefix. db_key = models.CharField('key', max_length=255, db_index=True) # access through the value property db_value = PickledObjectField('value', null=True) @@ -367,7 +367,7 @@ class TagHandler(object): "Add a new tag to the handler" for tag in make_iter(tag): tag = tag.strip().lower() if tag!=None else None - category = "%s%s" % (self.prefix, category.strip.lower()) if category!=None else None + category = "%s%s" % (self.prefix, category.strip().lower()) if category!=None else None data = str(data) if data!=None else None # this will only create tag if no matches existed beforehand (it will overload # data on an existing tag since that is not considered part of making the tag unique)