Skip to content

Commit

Permalink
rename pretty -> verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
tolomea committed Feb 3, 2024
1 parent 323214c commit 7706897
Show file tree
Hide file tree
Showing 24 changed files with 1,674 additions and 1,657 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Terminology
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| model | In Python the actual model class, in JavaScript the model name as above. |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| pretty... | User friendly field, and path values |
| verbose... | User friendly field, and path values |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| query | The information that changes with the query being done, in the JavaScript this also includes the results. |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
6 changes: 3 additions & 3 deletions data_browser/fe_build/asset-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion data_browser/fe_build/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion data_browser/fe_build/static/js/main.0ec3d805.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data_browser/fe_build/static/js/main.23c44e1a.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data_browser/format_csv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def head_cell(field):
return [" ".join(field.pretty_path)]
return [" ".join(field.verbose_path)]


def data_cell(value, span=1):
Expand Down
36 changes: 18 additions & 18 deletions data_browser/orm_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class OrmModel:
fields: dict
admin: BaseModelAdmin = None
pk: str = None
pretty_name: str = None
app_pretty_name: str = None
verbose_name: str = None
app_verbose_name: str = None

@property
def root(self):
Expand Down Expand Up @@ -92,11 +92,11 @@ def get_model_name(model, sep="."):
return f"{model._meta.app_label}{sep}{model.__name__}"


def get_model_pretty_name(model):
def get_model_verbose_name(model):
return title_case(model._meta.verbose_name)


def get_app_pretty_name(model):
def get_app_verbose_name(model):
app_config = apps.get_app_config(model._meta.app_label)
return title_case(app_config.verbose_name)

Expand Down Expand Up @@ -268,7 +268,7 @@ def get_common(admin, model):
return model_admins, all_model_fields


def _make_pretty(name):
def _make_verbose(name):
return (name[0].upper() + name[1:]).replace("_", " ")


Expand All @@ -285,7 +285,7 @@ def _get_calculated_field(request, field_name, model_name, model, admin, model_f
if getattr(field_func, "ddb_hide", False):
return None

pretty_name = _make_pretty(
verbose_name = _make_verbose(
getattr(field_func, "short_description", field_name.replace("_", " "))
)

Expand All @@ -309,7 +309,7 @@ def _get_calculated_field(request, field_name, model_name, model, admin, model_f
return OrmAnnotatedField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
type_=type_,
django_field=field,
admin=admin,
Expand All @@ -330,7 +330,7 @@ def field_func(obj):
return OrmCalculatedField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
func=field_func,
actions=actions,
)
Expand All @@ -345,7 +345,7 @@ def _make_json_sub_module(model_name, field_types):
fields[field_name] = OrmConcreteField(
model_name=model_name,
name=field_name,
pretty_name=field_name,
verbose_name=field_name,
type_=type_,
rel_name=type_.name,
choices=None,
Expand All @@ -363,21 +363,21 @@ def _get_fields_for_model(request, model, admin, admin_fields):

for field_name in admin_fields[model]:
field = model_fields.get(field_name)
pretty_name = (
_make_pretty(getattr(field, "verbose_name", field_name)) if field else None
verbose_name = (
_make_verbose(getattr(field, "verbose_name", field_name)) if field else None
)
# FK's etc
if isinstance(
field, (models.ForeignKey, ForeignObjectRel, models.ManyToManyField)
):
if isinstance(field, ForeignObjectRel):
pretty_name = _make_pretty(field.get_accessor_name())
verbose_name = _make_verbose(field.get_accessor_name())

if field.related_model in admin_fields:
fields[field_name] = OrmFkField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
rel_name=get_model_name(field.related_model),
to_many=field.one_to_many or field.many_to_many,
)
Expand All @@ -394,7 +394,7 @@ def _get_fields_for_model(request, model, admin, admin_fields):
fields[field_name] = OrmConcreteField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
type_=field_type,
rel_name=field_type.name,
choices=choices,
Expand All @@ -405,7 +405,7 @@ def _get_fields_for_model(request, model, admin, admin_fields):
fields[field_name] = OrmFileField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
django_field=field,
)

Expand Down Expand Up @@ -435,7 +435,7 @@ def _get_fields_for_model(request, model, admin, admin_fields):
fields[field_name] = OrmConcreteField(
model_name=model_name,
name=field_name,
pretty_name=pretty_name,
verbose_name=verbose_name,
type_=field_type,
rel_name=rel_name,
choices=choices,
Expand All @@ -447,8 +447,8 @@ def _get_fields_for_model(request, model, admin, admin_fields):
fields=fields,
admin=admin,
pk=model._meta.pk.name,
pretty_name=get_model_pretty_name(model),
app_pretty_name=get_app_pretty_name(model),
verbose_name=get_model_verbose_name(model),
app_verbose_name=get_app_verbose_name(model),
)

return orm_models
Expand Down
2 changes: 1 addition & 1 deletion data_browser/orm_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=full_path,
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=[annotation_path(full_path)],
aggregate_clause=self.func(previous.queryset_path_str),
having=True,
Expand Down
36 changes: 18 additions & 18 deletions data_browser/orm_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class OrmBoundField:
field: "OrmBaseField"
previous: "OrmBoundField"
full_path: Sequence[str]
pretty_path: Sequence[str]
verbose_path: Sequence[str]
queryset_path: Sequence[str]
aggregate_clause: Tuple[str, models.Func] = None
filter_: bool = False
Expand Down Expand Up @@ -72,7 +72,7 @@ def format_lookup(self, lookup, value):
@classmethod
def blank(cls):
return cls(
field=None, previous=None, full_path=[], pretty_path=[], queryset_path=[]
field=None, previous=None, full_path=[], verbose_path=[], queryset_path=[]
)

def get_format_hints(self, data):
Expand All @@ -84,7 +84,7 @@ def get_format_hints(self, data):
class OrmBaseField:
model_name: str
name: str
pretty_name: str
verbose_name: str
type_: BaseType = None
concrete: bool = False
rel_name: str = None
Expand Down Expand Up @@ -113,9 +113,9 @@ def get_formatter(self):


class OrmFkField(OrmBaseField):
def __init__(self, model_name, name, pretty_name, rel_name, to_many):
def __init__(self, model_name, name, verbose_name, rel_name, to_many):
super().__init__(
model_name, name, pretty_name, rel_name=rel_name, to_many=to_many
model_name, name, verbose_name, rel_name=rel_name, to_many=to_many
)

def bind(self, previous):
Expand All @@ -124,19 +124,19 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=previous.full_path + [self.name],
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=previous.queryset_path + [self.name],
)


class OrmConcreteField(OrmBaseField):
def __init__(
self, model_name, name, pretty_name, type_, rel_name, choices, actions=None
self, model_name, name, verbose_name, type_, rel_name, choices, actions=None
):
super().__init__(
model_name,
name,
pretty_name,
verbose_name,
concrete=True,
type_=type_,
rel_name=rel_name,
Expand All @@ -152,7 +152,7 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=previous.full_path + [self.name],
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=previous.queryset_path + [self.name],
filter_=True,
)
Expand All @@ -164,21 +164,21 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=previous.full_path + [self.name],
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=previous.queryset_path,
filter_=True,
)


class OrmCalculatedField(OrmBaseField):
def __init__(self, model_name, name, pretty_name, func, actions=None):
def __init__(self, model_name, name, verbose_name, func, actions=None):
if getattr(func, "boolean", False):
type_ = BooleanType
else:
type_ = HTMLType

super().__init__(
model_name, name, pretty_name, type_=type_, can_pivot=True, actions=actions
model_name, name, verbose_name, type_=type_, can_pivot=True, actions=actions
)
self.func = func

Expand All @@ -188,7 +188,7 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=previous.full_path + [self.name],
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=previous.queryset_path + ["pk"],
model_name=self.model_name,
)
Expand Down Expand Up @@ -236,12 +236,12 @@ def _annotate(self, qs, debug=False):

class OrmAnnotatedField(OrmBaseField):
def __init__(
self, model_name, name, pretty_name, type_, django_field, admin, choices
self, model_name, name, verbose_name, type_, django_field, admin, choices
):
super().__init__(
model_name,
name,
pretty_name,
verbose_name,
type_=type_,
rel_name=type_.name,
can_pivot=True,
Expand All @@ -259,18 +259,18 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=full_path,
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=[annotation_path(full_path)],
filter_=True,
)


class OrmFileField(OrmConcreteField):
def __init__(self, model_name, name, pretty_name, django_field):
def __init__(self, model_name, name, verbose_name, django_field):
super().__init__(
model_name,
name,
pretty_name,
verbose_name,
type_=URLType,
rel_name=URLType.name,
choices=None,
Expand Down
2 changes: 1 addition & 1 deletion data_browser/orm_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def bind(self, previous):
field=self,
previous=previous,
full_path=full_path,
pretty_path=previous.pretty_path + [self.pretty_name],
verbose_path=previous.verbose_path + [self.verbose_name],
queryset_path=[annotation_path(full_path)],
filter_=True,
func=self.func,
Expand Down
4 changes: 2 additions & 2 deletions data_browser/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def path(self):
return self.query_field.path

@cached_property
def pretty_path(self):
return self.orm_bound_field.pretty_path if self.orm_bound_field else None
def verbose_path(self):
return self.orm_bound_field.verbose_path if self.orm_bound_field else None

@cached_property
def path_str(self):
Expand Down
Loading

0 comments on commit 7706897

Please sign in to comment.