forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelresource.py
More file actions
43 lines (33 loc) · 1.22 KB
/
modelresource.py
File metadata and controls
43 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from pulpcore.plugin.importexport import BaseContentResource
from pulpcore.plugin.modelresources import RepositoryResource
from pulpcore.plugin.util import get_domain
from pulp_python.app.models import (
PythonPackageContent,
PythonRepository,
)
class PythonPackageContentResource(BaseContentResource):
"""
Resource for import/export of python_pythonpackagecontent entities.
"""
def set_up_queryset(self):
"""
:return: PythonPackageContent specific to a specified repo-version.
"""
return PythonPackageContent.objects.filter(
pk__in=self.repo_version.content, _pulp_domain=get_domain()
)
class Meta:
model = PythonPackageContent
import_id_fields = model.natural_key_fields()
class PythonRepositoryResource(RepositoryResource):
"""
A resource for importing/exporting python repository entities
"""
def set_up_queryset(self):
"""
:return: A queryset containing one repository that will be exported.
"""
return PythonRepository.objects.filter(pk=self.repo_version.repository)
class Meta:
model = PythonRepository
IMPORT_ORDER = [PythonPackageContentResource, PythonRepositoryResource]