Skip to content

Commit

Permalink
Merge pull request #511 from uktrade/release/tequila
Browse files Browse the repository at this point in the history
Release/tequila
  • Loading branch information
marcofucci authored Oct 4, 2017
2 parents 0eb7ff1 + 7d7a6f0 commit 892ed88
Show file tree
Hide file tree
Showing 63 changed files with 1,480 additions and 173 deletions.
8 changes: 6 additions & 2 deletions datahub/core/management/commands/loadmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.core.management import call_command
from django.core.management.base import BaseCommand

from datahub.metadata.fixtures import Fixture


SOURCE_ROOT = PurePath(__file__).parents[4]
SHARED_METADATA_FIXTURE_DIR = SOURCE_ROOT / 'fixtures' / 'metadata'
Expand All @@ -12,7 +14,6 @@
SHARED_METADATA_FIXTURE_DIR / 'companies.yaml',
SHARED_METADATA_FIXTURE_DIR / 'contacts.yaml',
SHARED_METADATA_FIXTURE_DIR / 'countries.yaml',
SHARED_METADATA_FIXTURE_DIR / 'interactions.yaml',
SHARED_METADATA_FIXTURE_DIR / 'investment.yaml',
SHARED_METADATA_FIXTURE_DIR / 'referrals.yaml',
SHARED_METADATA_FIXTURE_DIR / 'sectors.yaml',
Expand Down Expand Up @@ -40,8 +41,11 @@ def handle(self, *args, **options):
folder but some could have dependencies so it's safer to specify the
list manually.
"""
registered_fixtures = Fixture.all()

call_command(
'loaddata',
*SHARED_FIXTURES,
*EVENTS_FIXTURES
*EVENTS_FIXTURES,
*registered_fixtures,
)
2 changes: 1 addition & 1 deletion datahub/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Meta: # noqa: D101
abstract = True


class BaseConstantModel(models.Model):
class BaseConstantModel(DisableableModel):
"""Constant tables for FKs."""

id = models.UUIDField(primary_key=True)
Expand Down
1 change: 1 addition & 0 deletions datahub/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ConstantModelSerializer(serializers.Serializer):

id = serializers.ReadOnlyField()
name = serializers.ReadOnlyField()
disabled_on = serializers.ReadOnlyField()

class Meta: # noqa: D101
fields = '__all__'
Expand Down
1 change: 0 additions & 1 deletion datahub/core/test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from .support.models import MyDisableableModel


pytestmark = pytest.mark.django_db


Expand Down
3 changes: 3 additions & 0 deletions datahub/event/fixtures/event_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
- model: event.eventtype
pk: 91dbf298-84b3-4aa9-af7d-540721e5127c
fields: {name: "UK region local service"}
- model: event.eventtype
pk: c100fb8c-8d44-4c40-b40a-3d8ae3e5de86
fields: {name: "Conference", disabled_on: !!timestamp '2017-10-02 10:51:46.671808'}
30 changes: 30 additions & 0 deletions datahub/event/migrations/0009_auto_20171002_0950.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-02 09:50
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('event', '0008_add_service'),
]

operations = [
migrations.AddField(
model_name='eventtype',
name='disabled_on',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='locationtype',
name='disabled_on',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='programme',
name='disabled_on',
field=models.DateTimeField(blank=True, null=True),
),
]
12 changes: 11 additions & 1 deletion datahub/interaction/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from django.contrib import admin

from datahub.core.admin import BaseModelVersionAdmin
from .models import Interaction, ServiceDelivery, ServiceOffer
from .models import CommunicationChannel, Interaction, ServiceDelivery, ServiceOffer


@admin.register(CommunicationChannel)
class MetadataAdmin(admin.ModelAdmin):
"""Communication channel admin."""

fields = ('name', )
list_display = ('name', )
readonly_fields = ('id',)
search_fields = ('name', 'pk')


@admin.register(Interaction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# Interaction type
- model: metadata.interactiontype
# Interaction communication channel
- model: interaction.communicationchannel
pk: 70c226d7-5d95-e211-a939-e4115bead28a
fields: {name: Email/Website}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: 72c226d7-5d95-e211-a939-e4115bead28a
fields: {name: Telephone}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: 74c226d7-5d95-e211-a939-e4115bead28a
fields: {name: Letter/Fax}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: a5d71fdd-5d95-e211-a939-e4115bead28a
fields: {name: Face to Face}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: a7d71fdd-5d95-e211-a939-e4115bead28a
fields: {name: Video/Teleconf.}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: a8d71fdd-5d95-e211-a939-e4115bead28a
fields: {name: Social Media}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: 71c226d7-5d95-e211-a939-e4115bead28a
fields: {name: Fax}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: 73c226d7-5d95-e211-a939-e4115bead28a
fields: {name: Telex}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: 75c226d7-5d95-e211-a939-e4115bead28a
fields: {name: UKTI Website}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: a4d71fdd-5d95-e211-a939-e4115bead28a
fields: {name: SMS}
- model: metadata.interactiontype
- model: interaction.communicationchannel
pk: a6d71fdd-5d95-e211-a939-e4115bead28a
fields: {name: Business Card}
23 changes: 23 additions & 0 deletions datahub/interaction/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from datahub.interaction import models
from datahub.metadata.fixtures import Fixture
from datahub.metadata.registry import registry


class InteractionFixtures(Fixture):
"""Metadata fixtures (for the loadmetadata command)."""

files = [
'fixtures/communication_channels.yaml'
]


registry.register(
metadata_id='communication-channel',
model=models.CommunicationChannel,
)

# For backwards compatibility. Will be removed once front end updated.
registry.register(
metadata_id='interaction-type',
model=models.CommunicationChannel,
)
21 changes: 21 additions & 0 deletions datahub/interaction/migrations/0008_add_interaction_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-29 14:27
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('interaction', '0007_add_date_index'),
]

operations = [
migrations.AddField(
model_name='interaction',
name='kind',
field=models.CharField(choices=[('interaction', 'Interaction'), ('service_delivery', 'Service delivery')], default='interaction', max_length=255),
preserve_default=False,
),
]
22 changes: 22 additions & 0 deletions datahub/interaction/migrations/0009_add_interaction_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-29 15:58
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('event', '0008_add_service'),
('interaction', '0008_add_interaction_kind'),
]

operations = [
migrations.AddField(
model_name='interaction',
name='event',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='interactions', to='event.Event'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-02 09:04
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('interaction', '0009_add_interaction_event'),
]

operations = [
migrations.RenameField(
model_name='interaction',
old_name='interaction_type',
new_name='communication_channel',
),
]
33 changes: 33 additions & 0 deletions datahub/interaction/migrations/0011_move_interaction_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-02 10:46
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('interaction', '0010_ren_interaction_type_comm_channel'),
('metadata', '0005_auto_20171002_0950'),
]

state_operations = [
migrations.CreateModel(
name='CommunicationChannel',
fields=[
('id', models.UUIDField(primary_key=True, serialize=False)),
('name', models.TextField(blank=True)),
('disabled_on', models.DateTimeField(blank=True, null=True)),
],
options={
'ordering': ('name',),
'abstract': False,
'db_table': 'metadata_interactiontype'
},
),
]

operations = [
migrations.SeparateDatabaseAndState(state_operations=state_operations)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-02 10:53
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('interaction', '0011_move_interaction_type'),
]

operations = [
migrations.AlterField(
model_name='interaction',
name='communication_channel',
field=models.ForeignKey(blank=True, null=True, on_delete=models.deletion.SET_NULL,
to='interaction.CommunicationChannel')
)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-02 13:17
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('interaction', '0012_update_interaction_type_fkeys'),
]

operations = [
migrations.AlterModelTable(
name='communicationchannel',
table=None,
),
]
Loading

0 comments on commit 892ed88

Please sign in to comment.