예제 #1
0
def sync_site(site):
    domain = DomainCache(site.domain)
    domain_data = domain.get_data(refresh=True)

    for language in domain_data['languages']:
        domain_language = DomainLangageCache(site.domain, language)
        domain_language.get_data(refresh=True)
    DomainLangageCache.purge(site.domain, domain_data['languages'])

    urls = ContentFile.objects.filter(
        directory__ref=site.siteref.ref
    ).values_list('url', flat=True)
    for url in urls:
        domain_url = DomainUrlCache(site.domain, url)
        domain_url.get_data(refresh=True)
    DomainUrlCache.purge(site.domain, urls)
예제 #2
0
    def handle(self, *args, **options):
        Site.objects.filter(domain='example.com').delete()

        for repository in options.get('repository', []):
            Repository.objects.get_or_create(url=repository)

        if not options.get('domains'):
            for repository in Repository.objects.all():
                sync_repository(repository)

        refs = RepositoryRef.objects.all()
        if options['domains']:
            refs = refs.filter(siteref__site__domain__in=options['domains'])

        for ref in refs:
            sync_ref(ref)

            for siteref in ref.siteref_set.all():
                sync_site(siteref.site)

        if not Site.objects.filter(domain='localhost'):
            Site.objects.create(domain='localhost', name='localhost')

        DomainCache.purge(Site.objects.values_list('domain', flat=True))