def create_options(self, request): del request # unused options = dict() options['groups'] = [{ 'id': group.id, 'name': group.name, 'description': group.description } for group in ProductGroup.objects.filter(visible=True).all()] if not options['groups']: raise ObjectNotFound('No product groups exist') modules_queryset = ProductModule.objects.filter( plugin__enabled=True).exclude( plugin__staff_feature_name__in=staff_active_features. get_disabled_features()) options['modules'] = { module.id: { 'id': module.id, 'name': module.name, 'plugin': module.plugin_label if module.plugin_label and PluginUtils.has_staff_component( plugin_label=module.plugin_label, component_name='ProductSettings') else None, 'description': module.description } for module in modules_queryset } if not options['modules']: raise ObjectNotFound('No product modules exist') options['product_types'] = ProductType.choices options['statuses'] = PublicStatuses.choices options['price_models'] = PricingModel.choices options['auto_setups'] = ProductAutoSetup.choices return Response(options)
def get_has_settings_component(obj: Server): return PluginUtils.has_staff_component( plugin_label=obj.plugin.app_label, component_name=COMPONENT_NAME)