Skip to content

Commit

Permalink
Add complete field to Publication
Browse files Browse the repository at this point in the history
Only complete Publications can be distributed.

closes: #3184
https://pulp.plan.io/issues/3184
  • Loading branch information
dparalen committed Feb 1, 2018
1 parent f90c29e commit 025991f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions pulpcore/pulpcore/app/models/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class Publication(Model):
"""
Fields:
complete (models.BooleanField): State tracking; for internal use. Indexed.
created (models.DatetimeField): When the publication was created UTC.
Relations:
Expand All @@ -14,12 +15,18 @@ class Publication(Model):
create this Publication.
"""

complete = models.BooleanField(default=False)
created = models.DateTimeField(auto_now_add=True)

publisher = models.ForeignKey('Publisher', on_delete=models.CASCADE)

repository_version = models.ForeignKey('RepositoryVersion', on_delete=models.CASCADE)

class Meta:
indexes = [
models.Index(fields=['complete']),
]


class PublishedFile(Model):
"""
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/pulpcore/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class DistributionSerializer(ModelSerializer):
publication = serializers.HyperlinkedRelatedField(
allow_null=True,
help_text=_('The publication being served as defined by this distribution'),
queryset=models.Publication.objects.all(),
queryset=models.Publication.objects.exclude(complete=False),
view_name='publications-detail'
)
base_url = BaseURLField(
Expand Down
2 changes: 1 addition & 1 deletion pulpcore/pulpcore/app/viewsets/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class PublicationViewSet(GenericNamedModelViewSet,
mixins.ListModelMixin,
mixins.DestroyModelMixin):
endpoint_name = 'publications'
queryset = Publication.objects.all()
queryset = Publication.objects.exclude(complete=False)
serializer_class = PublicationSerializer


Expand Down

0 comments on commit 025991f

Please sign in to comment.