Skip to content

Commit

Permalink
Merge pull request #165 from rdmorganiser/uri_prefix_obligatory
Browse files Browse the repository at this point in the history
Make uri prefix obligatory
  • Loading branch information
triole committed Oct 30, 2019
2 parents 121ee31 + ec1bf33 commit c5fde73
Show file tree
Hide file tree
Showing 18 changed files with 373 additions and 181 deletions.
26 changes: 26 additions & 0 deletions rdmo/conditions/migrations/0020_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('conditions', 'Condition').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('conditions', '0019_django2'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='condition',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this condition.', max_length=256, verbose_name='URI Prefix'),
),
]
2 changes: 1 addition & 1 deletion rdmo/conditions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Condition(models.Model):
help_text=_('The Uniform Resource Identifier of this condition (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this condition.')
)
Expand Down
26 changes: 26 additions & 0 deletions rdmo/domain/migrations/0045_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('domain', 'Attribute').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('domain', '0044_mptt'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='attribute',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this attribute.', max_length=256, verbose_name='URI Prefix'),
),
]
2 changes: 1 addition & 1 deletion rdmo/domain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Attribute(MPTTModel):
help_text=_('The Uniform Resource Identifier of this attribute (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this attribute.')
)
Expand Down
35 changes: 35 additions & 0 deletions rdmo/options/migrations/0023_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('options', 'OptionSet').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()

for element in apps.get_model('options', 'Option').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('options', '0022_cascade_options'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='option',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this option.', max_length=256, verbose_name='URI Prefix'),
),
migrations.AlterField(
model_name='optionset',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this option set.', max_length=256, verbose_name='URI Prefix'),
),
]
4 changes: 2 additions & 2 deletions rdmo/options/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OptionSet(models.Model):
help_text=_('The Uniform Resource Identifier of this option set (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this option set.')
)
Expand Down Expand Up @@ -72,7 +72,7 @@ class Option(models.Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this option (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this option.')
)
Expand Down
53 changes: 53 additions & 0 deletions rdmo/questions/migrations/0044_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('questions', 'Catalog').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()

for element in apps.get_model('questions', 'Section').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()

for element in apps.get_model('questions', 'QuestionSet').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()

for element in apps.get_model('questions', 'Question').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('questions', '0043_django2'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='catalog',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this catalog.', max_length=256, verbose_name='URI Prefix'),
),
migrations.AlterField(
model_name='question',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this question.', max_length=256, verbose_name='URI Prefix'),
),
migrations.AlterField(
model_name='questionset',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this questionset.', max_length=256, verbose_name='URI Prefix'),
),
migrations.AlterField(
model_name='section',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this section.', max_length=256, verbose_name='URI Prefix'),
),
]
8 changes: 4 additions & 4 deletions rdmo/questions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Catalog(Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this catalog (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this catalog.')
)
Expand Down Expand Up @@ -101,7 +101,7 @@ class Section(Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this section (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this section.')
)
Expand Down Expand Up @@ -196,7 +196,7 @@ class QuestionSet(Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this questionset (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this questionset.')
)
Expand Down Expand Up @@ -410,7 +410,7 @@ class Question(Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this question (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True, null=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this question.')
)
Expand Down
26 changes: 26 additions & 0 deletions rdmo/tasks/migrations/0024_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('tasks', 'Task').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('tasks', '0023_django2'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='task',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this task.', max_length=256, verbose_name='URI Prefix'),
),
]
2 changes: 1 addition & 1 deletion rdmo/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Task(TranslationMixin, models.Model):
help_text=_('The Uniform Resource Identifier of this task (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this task.')
)
Expand Down
26 changes: 26 additions & 0 deletions rdmo/views/migrations/0017_require_uri_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.6 on 2019-10-29 12:08

from django.conf import settings
from django.db import migrations, models


def run_data_migration(apps, schema_editor):
for element in apps.get_model('views', 'View').objects.all():
element.uri_prefix = element.uri_prefix or settings.DEFAULT_URI_PREFIX
element.save()


class Migration(migrations.Migration):

dependencies = [
('views', '0016_django2'),
]

operations = [
migrations.RunPython(run_data_migration),
migrations.AlterField(
model_name='view',
name='uri_prefix',
field=models.URLField(help_text='The prefix for the URI of this view.', max_length=256, verbose_name='URI Prefix'),
),
]
2 changes: 1 addition & 1 deletion rdmo/views/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class View(models.Model, TranslationMixin):
help_text=_('The Uniform Resource Identifier of this view (auto-generated).')
)
uri_prefix = models.URLField(
max_length=256, blank=True,
max_length=256,
verbose_name=_('URI Prefix'),
help_text=_('The prefix for the URI of this view.')
)
Expand Down

0 comments on commit c5fde73

Please sign in to comment.