Edited polymorphic/showfields.py via GitHub

fix_request_path_info
Jonas Obrist 2011-05-19 06:08:39 -07:00
parent 30f11a35d7
commit 10b8901088
1 changed files with 14 additions and 7 deletions

View File

@ -22,11 +22,15 @@ class ShowFieldBase(object):
def _showfields_get_content(self, field_name, field_type=type(None)): def _showfields_get_content(self, field_name, field_type=type(None)):
"helper for __unicode__" "helper for __unicode__"
content = getattr(self, field_name) content = getattr(self, field_name)
if self.polymorphic_showfield_old_format: out = ': ' if self.polymorphic_showfield_old_format:
else: out = ' ' out = ': '
else:
out = ' '
if issubclass(field_type, models.ForeignKey): if issubclass(field_type, models.ForeignKey):
if content is None: out += 'None' if content is None:
else: out += content.__class__.__name__ out += 'None'
else:
out += content.__class__.__name__
elif issubclass(field_type, models.ManyToManyField): elif issubclass(field_type, models.ManyToManyField):
out += '%d' % content.count() out += '%d' % content.count()
elif type(content) in (int,long): elif type(content) in (int,long):
@ -44,8 +48,10 @@ class ShowFieldBase(object):
"helper for __unicode__" "helper for __unicode__"
done_fields = set() done_fields = set()
for field in self._meta.fields + self._meta.many_to_many: for field in self._meta.fields + self._meta.many_to_many:
if field.name in self.polymorphic_internal_model_fields or '_ptr' in field.name: continue if field.name in self.polymorphic_internal_model_fields or '_ptr' in field.name:
if field.name in done_fields: continue # work around django diamond inheritance problem continue
if field.name in done_fields:
continue # work around django diamond inheritance problem
done_fields.add(field.name) done_fields.add(field.name)
out = field.name out = field.name
@ -58,7 +64,8 @@ class ShowFieldBase(object):
else: else:
if self.polymorphic_showfield_type: if self.polymorphic_showfield_type:
out += ' (' + type(field).__name__ out += ' (' + type(field).__name__
if field.primary_key: out += '/pk' if field.primary_key:
out += '/pk'
out += ')' out += ')'
if self.polymorphic_showfield_content: if self.polymorphic_showfield_content: