Skip to content

Commit

Permalink
add indexes, review model meta class inheritance for indexes, locale
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Dec 5, 2023
1 parent b8c2c71 commit 624cc40
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# Generated by Django 4.2.7 on 2023-12-03 00:22

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("edc_data_manager", "0034_issue"),
]

operations = [
migrations.AlterModelOptions(
name="datadictionary",
options={
"default_permissions": ("view", "export"),
"verbose_name": "Data Dictionary Item",
"verbose_name_plural": "Data Dictionary Items",
},
),
migrations.AlterModelOptions(
name="dataquery",
options={
"default_manager_name": "objects",
"default_permissions": (
"add",
"change",
"delete",
"view",
"export",
"import",
),
"verbose_name": "Data Query",
"verbose_name_plural": "Data Queries",
},
),
migrations.AlterModelOptions(
name="queryrule",
options={
"default_manager_name": "objects",
"default_permissions": (
"add",
"change",
"delete",
"view",
"export",
"import",
),
"verbose_name": "Query Rule",
"verbose_name_plural": "Query Rules",
},
),
migrations.AddField(
model_name="datadictionary",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="datadictionary",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="dataquery",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="dataquery",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="edcpermissions",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="edcpermissions",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="historicaldatadictionary",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="historicaldatadictionary",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="historicaldataquery",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="historicaldataquery",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="historicalqueryrule",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="historicalqueryrule",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AddField(
model_name="queryrule",
name="locale_created",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale created",
),
),
migrations.AddField(
model_name="queryrule",
name="locale_modified",
field=models.CharField(
blank=True,
help_text="Auto-updated by Modeladmin",
max_length=10,
null=True,
verbose_name="Locale modified",
),
),
migrations.AlterField(
model_name="datadictionary",
name="prompt",
field=models.CharField(max_length=500),
),
migrations.AlterField(
model_name="historicaldatadictionary",
name="prompt",
field=models.CharField(max_length=500),
),
migrations.AddIndex(
model_name="datadictionary",
index=models.Index(
fields=["model", "number", "prompt"],
name="edc_data_ma_model_92b469_idx",
),
),
]
9 changes: 5 additions & 4 deletions edc_data_manager/models/data_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.apps import apps as django_apps
from django.db import models
from django.db.models import Index
from edc_model.models import BaseUuidModel, HistoricalRecords


Expand All @@ -15,7 +16,7 @@ class DataDictionary(BaseUuidModel):

number = models.IntegerField()

prompt = models.TextField()
prompt = models.CharField(max_length=500)

field_name = models.CharField(max_length=250)

Expand Down Expand Up @@ -64,8 +65,8 @@ def model_cls(self):
return django_apps.get_model(self.model)

class Meta:
default_permissions = ("view", "export")
ordering = ("model", "number", "prompt")
unique_together = (("model", "field_name"),)
verbose_name = "Data Dictionary Item"
verbose_name_plural = "Data Dictionary Items"
default_permissions = ("view", "export")
unique_together = (("model", "field_name"),)
indexes = [Index(fields=["model", "number", "prompt"])]
1 change: 0 additions & 1 deletion edc_data_manager/models/query_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ def model_cls(self):
return django_apps.get_model(dct_models[0])

class Meta(BaseUuidModel.Meta):
ordering = ("title",)
verbose_name = "Query Rule"
verbose_name_plural = "Query Rules"
indexes = [models.Index(fields=["title", "active"])]
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"edc_device.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_listboard.apps.AppConfig",
Expand Down

0 comments on commit 624cc40

Please sign in to comment.