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
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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
@@ -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=[
@@ -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=[
@@ -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__)
@@ -57,7 +57,7 @@ class FilePublication(Publication):
TYPE = 'file'


class FileDistribution(Distribution):
class FileDistribution(PublicationDistribution):
"""
Distribution for 'file' content.
"""
@@ -4,7 +4,7 @@

from pulpcore.plugin.serializers import (
DetailRelatedField,
DistributionSerializer,
PublicationDistributionSerializer,
PublicationSerializer,
PublisherSerializer,
RemoteSerializer,
@@ -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
@@ -9,9 +9,9 @@
)
from pulpcore.plugin.tasking import enqueue_with_reservation
from pulpcore.plugin.viewsets import (
BaseDistributionViewSet,
ContentViewSet,
ContentFilter,
DistributionViewSet,
RemoteViewSet,
OperationPostponedResponse,
PublicationViewSet,
@@ -141,7 +141,7 @@ def create(self, request):
return OperationPostponedResponse(result, request)


class FileDistributionViewSet(DistributionViewSet):
class FileDistributionViewSet(BaseDistributionViewSet):
"""
ViewSet for File Distributions.
"""
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.