def save(self, *args, **kwargs): """ Override the save method such that we use the non proxy cert during the save. """ with proxy_regression(get_certificates_models(), "GeneratedCertificate", GeneratedCertificate): super().save(*args, **kwargs)
import logging from itertools import chain import six from django.conf import settings from django.core.cache import cache from django.db import models from eox_tenant.edxapp_wrapper.certificates_module import get_certificates_models from eox_tenant.edxapp_wrapper.site_configuration_module import get_site_configuration_models from eox_tenant.models import Microsite, TenantConfig, TenantOrganization from eox_tenant.organizations import get_organizations from eox_tenant.tenant_wise.context_managers import proxy_regression SiteConfigurationModels = get_site_configuration_models() CertificatesModels = get_certificates_models() # The following line is necessary because we want to keep the previous Model GeneratedCertificate after the overrides. GeneratedCertificate = CertificatesModels.GeneratedCertificate TENANT_ALL_ORGS_CACHE_KEY = "tenant.all_orgs_list" EOX_TENANT_CACHE_KEY_TIMEOUT = getattr(settings, "EOX_TENANT_CACHE_KEY_TIMEOUT", 300) TENANT_MICROSITES_ITERATOR_KEY = "tenant-microsites-iterator" logger = logging.getLogger(__name__) class TenantSiteConfigProxy(SiteConfigurationModels.SiteConfiguration): """ This a is Proxy model for SiteConfiguration from <openedx.core.djangoapps.site_configuration.models>. This allows to add or override methods using as base the SiteConfiguration model. More information in https://docs.djangoproject.com/en/3.0/topics/db/models/#proxy-models """