-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from turicas/feature/organize-fields-metadata
[WIP] Organiza metadados de campos
- Loading branch information
Showing
11 changed files
with
158 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Django 3.1.1 on 2020-10-06 17:35 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0022_auto_20200918_1805"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField(model_name="table", old_name="filtering", new_name="filtering_fields",), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 3.1.1 on 2020-10-06 17:39 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def ensure_filtering_fields_config(apps, schema_editor): | ||
Table = apps.get_model("core.Table") | ||
|
||
for table in Table.objects.all(): | ||
fields = table.field_set.all() | ||
|
||
fields_maps = {f.name: f for f in fields} | ||
for fieldname in table.filtering_fields or []: | ||
field = fields.get(name=fieldname) | ||
if not field.frontend_filter: | ||
field.frontend_filter = True | ||
field.save() | ||
print(f"{table.dataset.slug}.{table.name}.{fieldname} atualizado como frontend_filter") | ||
|
||
|
||
def rollback(*args, **kwargs): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0023_auto_20201006_1435"), | ||
] | ||
|
||
operations = [migrations.RunPython(ensure_filtering_fields_config, rollback)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 3.1.1 on 2020-10-07 20:02 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0024_auto_20201006_1439"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="field", name="searchable", field=models.BooleanField(blank=True, default=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Generated by Django 3.1.1 on 2020-10-07 20:04 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0025_auto_20201007_1702"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField(model_name="table", old_name="search", new_name="search_fields",), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.1.1 on 2020-10-07 20:07 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_searchable_fields_flags(apps, schema_editor): | ||
Table = apps.get_model("core", "Table") | ||
|
||
for table in Table.objects.exclude(search_fields__isnull=True): | ||
table.field_set.filter(name__in=table.search_fields).update(searchable=True) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0026_auto_20201007_1704"), | ||
] | ||
|
||
operations = [migrations.RunPython(update_searchable_fields_flags)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters