Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PublicationDistribution from pulpcore.plugin #219

Merged
merged 1 commit into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions pulp_file/app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.2 on 2019-05-05 13:35
# Generated by Django 2.2.1 on 2019-05-09 16:50

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -13,16 +13,6 @@ class Migration(migrations.Migration):
]

operations = [
migrations.CreateModel(
name='FileDistribution',
fields=[
('distribution_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.Distribution')),
],
options={
'abstract': False,
},
bases=('core.distribution',),
),
migrations.CreateModel(
name='FilePublication',
fields=[
Expand Down Expand Up @@ -54,6 +44,18 @@ class Migration(migrations.Migration):
},
bases=('core.remote',),
),
migrations.CreateModel(
name='FileDistribution',
fields=[
('basedistribution_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='_distributions', serialize=False, to='core.BaseDistribution')),
('publication', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='_distributions', to='core.Publication')),
],
options={
'abstract': False,
'default_related_name': '_distributions',
},
bases=('core.basedistribution',),
),
migrations.CreateModel(
name='FileContent',
fields=[
Expand Down
4 changes: 2 additions & 2 deletions pulp_file/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import models

from pulpcore.plugin.models import Content, Distribution, Remote, Publication, Publisher
from pulpcore.plugin.models import Content, PublicationDistribution, Remote, Publication, Publisher


log = getLogger(__name__)
Expand Down Expand Up @@ -57,7 +57,7 @@ class FilePublication(Publication):
TYPE = 'file'


class FileDistribution(Distribution):
class FileDistribution(PublicationDistribution):
"""
Distribution for 'file' content.
"""
Expand Down
18 changes: 14 additions & 4 deletions pulp_file/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pulpcore.plugin.serializers import (
DetailRelatedField,
DistributionSerializer,
PublicationDistributionSerializer,
PublicationSerializer,
PublisherSerializer,
RemoteSerializer,
Expand Down Expand Up @@ -81,22 +81,32 @@ class FilePublicationSerializer(PublicationSerializer):
Serializer for File Publications.
"""

distributions = DetailRelatedField(
help_text=_('This publication is currently being served as '
'defined by these distributions.'),
source="filedistribution_set",
many=True,
read_only=True,
)
publisher = DetailRelatedField(
help_text=_('The publisher that created this publication.'),
queryset=FilePublisher.objects.all(),
required=False,
)

class Meta:
fields = PublicationSerializer.Meta.fields + ('publisher',)
model = FilePublication
fields = PublicationSerializer.Meta.fields + (
'distributions',
'publisher',
)


class FileDistributionSerializer(DistributionSerializer):
class FileDistributionSerializer(PublicationDistributionSerializer):
"""
Serializer for File Distributions.
"""

class Meta:
fields = DistributionSerializer.Meta.fields
fields = PublicationDistributionSerializer.Meta.fields
model = FileDistribution
4 changes: 2 additions & 2 deletions pulp_file/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
)
from pulpcore.plugin.tasking import enqueue_with_reservation
from pulpcore.plugin.viewsets import (
BaseDistributionViewSet,
ContentViewSet,
ContentFilter,
DistributionViewSet,
RemoteViewSet,
OperationPostponedResponse,
PublicationViewSet,
Expand Down Expand Up @@ -141,7 +141,7 @@ def create(self, request):
return OperationPostponedResponse(result, request)


class FileDistributionViewSet(DistributionViewSet):
class FileDistributionViewSet(BaseDistributionViewSet):
"""
ViewSet for File Distributions.
"""
Expand Down