def finalize_setup(is_upgrade=False, register_scmtools=True): """Internal function to upgrade internal state after installs/upgrades. This should only be called by Review Board install or upgrade code. Args: is_upgrade (bool, optional): Whether this is finalizing an upgrade, rather than a new install. register_scmtools (bool, optional): Whether to register SCMTools when finalizing. Version Added: 4.0: """ from reviewboard import signals from reviewboard.admin.management.sites import init_siteconfig from reviewboard.scmtools.models import Tool # Add/update any SCMTool registrations. if register_scmtools: Tool.objects.register_from_entrypoints() # Update the recorded product version. init_siteconfig() # Notify anything else that needs to listen. signals.finalized_setup.send(sender=None, is_upgrade=is_upgrade)
def _init_siteconfig(app_config=None, app=None, **kwargs): """Create/upgrade the SiteConfiguration after a database install/upgrade. Args: app_config (django.apps.AppConfig, optional): The app configuration that was migrated. This is only provided on Django 1.11. app (module, optional): The app that was synced. This is only provided on Django 1.6. **kwargs (dict): Additional keyword arguments passed in the signal. """ if ((app_config is not None and app_config.label == 'djblets_siteconfig') or (app is not None and app.__name__ == 'djblets.siteconfig.models')): init_siteconfig()
def django_db_setup(django_db_setup, django_db_blocker): """Set up the Django database. This is run at the start of the project-wide test session, setting up an initial siteconfig in the database. """ with django_db_blocker.unblock(): from reviewboard.admin.management.sites import init_siteconfig siteconfig = init_siteconfig() siteconfig.set('mail_from_spoofing', 'never') siteconfig.save(update_fields=('settings',))
def setup_databases(self): """Set up the database for the tests. Returns: object: The return result from Django's implementation. This value is considered opaque here. """ result = super(RBTestRunner, self).setup_databases() # Create an initial SiteConfiguration. # # Ideally, we'd call reviewboard.finalize_setup(), but this triggers # some early Django state setup that we want to avoid. from reviewboard.admin.management.sites import init_siteconfig siteconfig = init_siteconfig() siteconfig.set('mail_from_spoofing', 'never') siteconfig.save(update_fields=('settings', )) return result