-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3100 from jortel/issue-2893
Add publication models.
- Loading branch information
Showing
10 changed files
with
363 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
from django.db import models | ||
from django.core.files.storage import DefaultStorage | ||
|
||
from pulpcore.app.models import Model | ||
|
||
|
||
class Publication(Model): | ||
""" | ||
Fields: | ||
created (models.DatetimeField): When the publication was created UTC. | ||
Relations: | ||
publisher (models.ForeignKey): The publisher that created the publication. | ||
""" | ||
|
||
created = models.DateTimeField(auto_now_add=True) | ||
|
||
publisher = models.ForeignKey('Publisher', on_delete=models.CASCADE) | ||
|
||
|
||
class PublishedFile(Model): | ||
""" | ||
A file included in Publication. | ||
Fields: | ||
relative_path (models.CharField): The (relative) path component of the published url. | ||
Relations: | ||
publication (models.ForeignKey): The publication in which the artifact is included. | ||
""" | ||
relative_path = models.CharField(max_length=255) | ||
|
||
publication = models.ForeignKey(Publication, on_delete=models.CASCADE) | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
|
||
class PublishedArtifact(PublishedFile): | ||
""" | ||
An artifact that is part of a publication. | ||
Relations: | ||
content_artifact (models.ForeignKey): The referenced content artifact. | ||
""" | ||
content_artifact = models.ForeignKey('ContentArtifact', on_delete=models.CASCADE) | ||
|
||
class Meta: | ||
unique_together = ('publication', 'content_artifact') | ||
default_related_name = 'published_artifact' | ||
|
||
|
||
class PublishedMetadata(PublishedFile): | ||
""" | ||
Metadata file that is part of a publication. | ||
Fields: | ||
file (models.FileField): The stored file. | ||
""" | ||
|
||
def _storage_path(self, name): | ||
return DefaultStorage().published_metadata_path(self, name) | ||
|
||
file = models.FileField(upload_to=_storage_path, max_length=255) | ||
|
||
class Meta: | ||
unique_together = ('publication', 'file') | ||
default_related_name = 'published_metadata' | ||
|
||
|
||
class Distribution(Model): | ||
""" | ||
A distribution defines how a publication is distributed by pulp. | ||
Fields: | ||
name (models.CharField): The name of the distribution. | ||
Examples: "rawhide" and "stable". | ||
base_path (models.CharField): The base (relative) path component of the published url. | ||
auto_updated (models.BooleanField): The publication is updated automatically | ||
whenever the publisher has created a new publication. | ||
http (models.BooleanField): The publication is distributed using HTTP. | ||
https (models.BooleanField): The publication is distributed using HTTPS. | ||
Relations: | ||
publisher (models.ForeignKey): The associated publisher. | ||
publication (models.ForeignKey): The current publication associated with | ||
the distribution. This is the publication being served by Pulp through | ||
this relative URL path and settings. | ||
""" | ||
|
||
name = models.CharField(max_length=255) | ||
base_path = models.CharField(max_length=255, unique=True) | ||
auto_updated = models.BooleanField(default=True) | ||
http = models.BooleanField(default=True) | ||
https = models.BooleanField(default=True) | ||
|
||
publication = models.ForeignKey(Publication, null=True, on_delete=models.SET_NULL) | ||
publisher = models.ForeignKey('Publisher', on_delete=models.CASCADE) | ||
|
||
class Meta: | ||
unique_together = ('publisher', 'name') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from pulpcore.app.views.status import StatusView # noqa | ||
from .content import ContentView # noqa | ||
from .status import StatusView # noqa |
Oops, something went wrong.