Project

Profile

Help

Story #6500

Add modelresource to plugin-template

Added by ggainey 6 months ago. Updated about 1 month ago.

Status:
NEW
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Platform Release:
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

It would be good for the plugin-template to include creating a /app/modelresource.py file to help plugin authors play the import/export game. Such a modelresource would have a class defined for everything in models.py or models/, using the following template:

from pulpcore.app.modelresource import QueryModelResource                                    
from PLUGIN.app.models import (                                                            
    <list models here>,                                                  
)                                                                                            
    

class MODELResource(QueryModelResource):                                          
    """                                                                                      
    Resource for import/export of plugin-type_modelname entities.                             
    """                                                                                      
                                                                                             
    def set_up_queryset(self):                                                               
        """                                                                                  
        :return: MODELs specific to a specified repo-version.                     
        """                                                                                  
        return MODEL.objects.filter(pk__in=self.repo_version.content)             
                                                                                             
    class Meta:                                                                              
        model = MODEL    

IMPORT_ORDER = [                                                                             
    MODEL-list-in-alfa-order,                                                                                                                                     
]     

History

#1 Updated by daviddavis about 1 month ago

  • Parent task deleted (#6134)

Detaching from epic.

Please register to edit this issue

Also available in: Atom PDF