Skip to content

Commit

Permalink
Add feature to Graph model : disable_abstract_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Chehab committed Sep 9, 2018
1 parent 7d262c3 commit 30c1a80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django_extensions/management/commands/graph_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def __init__(self, *args, **kwargs):
'dest': 'disable_fields',
'help': 'Do not show the class member fields',
},
'--disable-abstract-fields': {
'action': 'store_true',
'default': False,
'dest': 'disable_abstract_fields',
'help': 'Do not show the class member fields that were inherited',
},
'--group-models -g': {
'action': 'store_true',
'default': False,
Expand Down
2 changes: 2 additions & 0 deletions django_extensions/management/modelviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, app_labels, **kwargs):
self.graphs = []
self.cli_options = kwargs.get('cli_options', None)
self.disable_fields = kwargs.get('disable_fields', False)
self.disable_abstract_fields = kwargs.get('disable_abstract_fields', False)
self.include_models = parse_file_or_list(
kwargs.get('include_models', "")
)
Expand Down Expand Up @@ -103,6 +104,7 @@ def get_graph_data(self, as_json=False):
'created_at': now.strftime("%Y-%m-%d %H:%M"),
'cli_options': self.cli_options,
'disable_fields': self.disable_fields,
'disable_abstract_fields': self.disable_abstract_fields,
'use_subgraph': self.use_subgraph,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
{{ model.label }}{% if model.abstracts %}<BR/>&lt;<FONT FACE="Helvetica Italic">{{ model.abstracts|join:"," }}</FONT>&gt;{% endif %}
</FONT></TD></TR>
{% if not disable_fields %}{% for field in model.fields %}
{% if not disable_abstract_fields or not field.abstract %}
<TR><TD ALIGN="LEFT" BORDER="0">
<FONT {% if not field.primary_key and field.blank %}COLOR="#7B7B7B" {% endif %}FACE="Helvetica {% if field.abstract %}Italic{% endif %}{% if field.relation or field.primary_key %}Bold{% endif %}">{{ field.label }}</FONT>
</TD><TD ALIGN="LEFT">
<FONT {% if not field.primary_key and field.blank %}COLOR="#7B7B7B" {% endif %}FACE="Helvetica {% if field.abstract %}Italic{% endif %}{% if field.relation or field.primary_key %}Bold{% endif %}">{{ field.type }}</FONT>
</TD></TR>
{% endif %}
{% endfor %}{% endif %}
</TABLE>
>]
Expand Down

0 comments on commit 30c1a80

Please sign in to comment.