Ejemplo n.º 1
0
def clear_caches_for_jobs(sender, instance, **kwargs):
    # clear cache for job list page
    expire_page_cache(reverse('job_list'))
    
    # clear caches for related organization
    if instance.organization:
        expire_page_cache(instance.organization.get_absolute_url())
Ejemplo n.º 2
0
def clear_caches_for_job(instance):
    '''
    Not triggering this via signal, as we seemed to have
    trouble getting consistent results with the double-save
    required for a unique slug. Called manually instead.
    '''
    # clear cache for job list page
    expire_page_cache(reverse('job_list'))

    # clear caches for related organization
    if instance.organization:
        expire_page_cache(instance.organization.get_absolute_url())
Ejemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        data = request.POST
        form_message = ''
        
        task = data['organization_task']
        organization = self.get_organization()

        if task == 'create':
            job = self.create_job(data, organization)
            form_message = 'Created'
        else:
            job = self.get_job(data['job'], organization, task)
            if task == 'update':
                form_message = self.process_form(job, data)
            elif task == 'remove':
                job.delete()
                expire_page_cache(reverse('job_list'))
                expire_page_cache(organization.get_absolute_url())
                form_message = 'Removed'

        if request.is_ajax():
            result = {
                'message': form_message,
                'job': {
                    'name': job.name,
                    'pk': job.pk,
                    'contact_name': job.contact_name,
                    'email': job.email,
                    'description': job.description,
                    'location': job.location,
                    'url': job.url,
                    'listing_end_date': job.listing_end_date
                }
            }
            return render_json_to_response(result)

        # if for some reason we're not hitting via ajax
        messages.success(request, form_message)
        return redirect(self.get_success_url())
Ejemplo n.º 4
0
def clear_caches_for_guide(sender, instance, **kwargs):
    # clear cache for guide detail page
    expire_page_cache(instance.get_absolute_url())

    # clear cache for guide list page
    expire_page_cache(reverse('guide_list'))

    # clear caches for related articles
    for article in instance.get_live_article_set():
        expire_page_cache(article.article.get_absolute_url())
Ejemplo n.º 5
0
def clear_caches_for_article(sender, instance, **kwargs):
    # clear cache for article detail page
    expire_page_cache(instance.get_absolute_url())
    
    # clear cache for article list pages
    if instance.section.slug:
        expire_page_cache(reverse(
            'article_list_by_section',
            kwargs = { 'section': instance.section.slug }
        ))
    if instance.category:
        expire_page_cache(reverse(
            'article_list_by_category',
            kwargs = { 'category': instance.category.slug }
        ))

    # clear caches for related organizations
    for organization in instance.get_live_organization_set():
        expire_page_cache(organization.get_absolute_url())
        
    # clear caches for related people
    for person in instance.get_live_people_set():
        expire_page_cache(person.get_absolute_url())

    # clear caches for related authors
    for author in instance.get_live_author_set():
        expire_page_cache(author.get_absolute_url())

    # clear caches for related code index entries
    for code in instance.get_live_code_set():
        expire_page_cache(code.get_absolute_url())
        
    # clear caches for tag pages. FWIW this will miss
    # tag intersection queries like /foo+bar+baz/, so if we
    # implement those, they may need to expire naturally
    for tag in instance.tags.all():
        expire_page_cache(reverse(
            'article_list_by_tag',
            kwargs = { 'tag_slugs': tag.slug }
        ))
Ejemplo n.º 6
0
def clear_caches_for_organization(sender, instance, **kwargs):
    # clear cache for organization detail page
    expire_page_cache(instance.get_absolute_url())

    # clear cache for organization list page
    expire_page_cache(reverse('organization_list'))

    # clear caches for related articles
    for article in instance.get_live_article_set():
        expire_page_cache(article.get_absolute_url())
        if article.section.slug:
            expire_page_cache(reverse(
                'article_list_by_section',
                kwargs = { 'section': article.section.slug }
            ))
        if article.category:
            expire_page_cache(reverse(
                'article_list_by_category',
                kwargs = { 'category': article.category.slug }
            ))

    # clear caches for related people
    for person in instance.get_live_person_set():
        expire_page_cache(person.get_absolute_url())

    # clear caches for related code index entries
    for code in instance.get_live_code_set():
        expire_page_cache(code.get_absolute_url())
Ejemplo n.º 7
0
def clear_caches_for_code(sender, instance, **kwargs):
    # clear cache for code detail page
    expire_page_cache(instance.get_absolute_url())

    # clear cache for code list page
    expire_page_cache(reverse('code_list'))

    # clear caches for related articles
    for article in instance.get_live_article_set():
        expire_page_cache(article.get_absolute_url())
        if article.section.slug:
            expire_page_cache(
                reverse('article_list_by_section',
                        kwargs={'section': article.section.slug}))
        if article.category:
            expire_page_cache(
                reverse('article_list_by_category',
                        kwargs={'category': article.category.slug}))

    # clear caches for related organizations
    for organization in instance.get_live_organization_set():
        expire_page_cache(organization.get_absolute_url())

    # clear caches for related people
    for person in instance.get_live_person_set():
        expire_page_cache(person.get_absolute_url())

    # clear caches for tag pages. FWIW this will miss
    # tag intersection queries like /foo+bar+baz/, so if we
    # implement those, they may need to expire naturally
    for tag in instance.tags.all():
        expire_page_cache(
            reverse('code_list_by_tag', kwargs={'tag_slugs': tag.slug}))
Ejemplo n.º 8
0
def clear_caches_for_organization(sender, instance, **kwargs):
    # clear cache for organization detail page
    expire_page_cache(instance.get_absolute_url())

    # clear cache for organization list page
    expire_page_cache(reverse('organization_list'))

    # clear cache for community page
    expire_page_cache(reverse('community_list'))

    # clear caches for related articles
    for article in instance.get_live_article_set():
        expire_page_cache(article.get_absolute_url())
        expire_page_cache(reverse('article_list'))

        #if article.section.slug:
        #    expire_page_cache(reverse(
        #        'article_list_by_section',
        #        kwargs = { 'section': article.section.slug }
        #    ))
        #if article.category:
        #    expire_page_cache(reverse(
        #        'article_list_by_category',
        #        kwargs = { 'category': article.category.slug }
        #    ))

    # clear caches for related people
    for person in instance.get_live_person_set():
        expire_page_cache(person.get_absolute_url())

    # clear caches for related code index entries
    for code in instance.get_live_code_set():
        expire_page_cache(code.get_absolute_url())
Ejemplo n.º 9
0
def clear_caches_for_person(sender, instance, **kwargs):
    # clear cache for person detail page
    expire_page_cache(instance.get_absolute_url())

    # clear cache for person list page
    expire_page_cache(reverse('person_list'))

    # clear caches for related articles
    for article in instance.get_live_article_set():
        expire_page_cache(article.get_absolute_url())
        if article.section.slug:
            expire_page_cache(
                reverse('article_list_by_section',
                        kwargs={'section': article.section.slug}))
        if article.category:
            expire_page_cache(
                reverse('article_list_by_category',
                        kwargs={'category': article.category.slug}))

    for article in instance.get_live_article_authored_set():
        expire_page_cache(article.get_absolute_url())
        if article.section.slug:
            expire_page_cache(
                reverse('article_list_by_section',
                        kwargs={'section': article.section.slug}))
        if article.category:
            expire_page_cache(
                reverse('article_list_by_category',
                        kwargs={'category': article.category.slug}))

    # clear caches for related organizations
    for organization in instance.get_live_organization_set():
        expire_page_cache(organization.get_absolute_url())

    # clear caches for related code index entries
    for code in instance.get_live_code_set():
        expire_page_cache(code.get_absolute_url())