mirror of
https://github.com/evennia/evennia.git
synced 2026-03-27 18:26:32 +01:00
Prevent editing of attributes which are not Python literals through the admin interface.
This commit is contained in:
parent
112e7c652d
commit
54bb593f5e
2 changed files with 11 additions and 1 deletions
|
|
@ -54,6 +54,15 @@ class AttributeAdmin(ModelAdmin):
|
|||
"""
|
||||
search_fields = ('db_key', 'db_strvalue', 'db_value')
|
||||
list_display = ('db_key', 'db_strvalue', 'db_value')
|
||||
permitted_types = ('str', 'int', 'float', 'NoneType', 'bool')
|
||||
|
||||
fields = ('db_key', 'db_value', 'db_strvalue', 'db_category',
|
||||
'db_lock_storage', 'db_model', 'db_attrtype')
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
if obj.db_value.__class__.__name__ not in self.permitted_types:
|
||||
return ['db_value']
|
||||
return []
|
||||
|
||||
admin.site.register(Attribute, AttributeAdmin)
|
||||
admin.site.register(Tag, TagAdmin)
|
||||
Loading…
Add table
Add a link
Reference in a new issue