Skip to content

Commit

Permalink
Fixing f strings
Browse files Browse the repository at this point in the history
  • Loading branch information
imakecodes committed Sep 26, 2024
1 parent b0bb861 commit 68a2e7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions django_dbml/management/commands/dbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def handle(self, *app_labels, **kwargs): # noqa: D102, PLR0912, PLR0914, PLR091
elif '_' in table_name:
schema_name, model_name = table_name.split('_')

enum_name = f'{schema_name}.{tables[table_name]["fields"][field_name]['type']}_{model_name}_{field_name}'.lower()
enum_name = f'{schema_name}.{tables[table_name]["fields"][field_name]["type"]}_{model_name}_{field_name}'.lower()

tables[table_name]["fields"][field_name]['type'] = enum_name
enums[enum_name] = '\n '.join([f"\"{c[0]}\" [note: '''{c[1]}''']" for c in self.get_enum_choices(field)])
Expand Down Expand Up @@ -386,7 +386,8 @@ def handle(self, *app_labels, **kwargs): # noqa: D102, PLR0912, PLR0914, PLR091
tables[table_name]["note"] += f"\n{app_table.__doc__}"

if app_table._meta.db_table_comment:
tables[table_name]["note"] += f'\n\n*DB comment: {app_table._meta.db_table_comment.replace('"', '\\"')}*'
comment = app_table._meta.db_table_comment.replace('"', '\"')
tables[table_name]["note"] += f'\n\n*DB comment: {comment}*'

if not self.options["table_names"]:
tables[table_name]["note"] += f"\n\n*DB table: {app_table._meta.db_table}*"
Expand All @@ -395,8 +396,9 @@ def handle(self, *app_labels, **kwargs): # noqa: D102, PLR0912, PLR0914, PLR091
output_blocks = []

if not self.options.get('disable_update_timestamp'):
ts = datetime.now(UTC).strftime('%m-%d-%Y %I:%M%p UTC')
output_blocks += [
f'Project "{project_name}" {{\n database_type: \'{self.get_db_type()}\'\n Note: \'\'\'{project_notes}\n Last Updated At {datetime.now(UTC).strftime('%m-%d-%Y %I:%M%p UTC')}\'\'\'\n}}\n'
f'Project "{project_name}" {{\n database_type: \'{self.get_db_type()}\'\n Note: \'\'\'{project_notes}\n Last Updated At {ts}\'\'\'\n}}\n'
]
else:
output_blocks += [f'Project "{project_name}" {{\n database_type: \'{self.get_db_type()}\'\n Note: \'\'\'{project_notes}\'\'\'\n}}\n']
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = django-dbml
version = 0.10.0
version = 0.10.1
description = Django extension aimed to generate DBML from all models
long_description_content_type = text/markdown
long_description = file: README.md
Expand Down

0 comments on commit 68a2e7f

Please sign in to comment.