Ejemplo n.º 1
0
def index(request):
    acs = Article.get_all_newest_contents_all_languages()
    now = timezone.now()

    acs_updated_in_the_last_24_hours = filter(
        lambda ac: ac.updated > now - timezone.timedelta(hours=24), acs)

    acs_updated_in_the_last_week = filter(
        lambda ac: ac.updated > now - timezone.timedelta(days=7), acs)

    acs_updated_in_the_last_month = filter(
        lambda ac: ac.updated > now - timezone.timedelta(days=30), acs)

    user_stats = _generate_user_statistics_for_one_day(
        year=now.year, month=now.month, day=now.day
    )

    article_length_stats = _generate_article_length_statistics(acs)

    return render(request, 'stats/index.html', {
        'number_of_acs_updated_in_the_last_24_hours':
            len(acs_updated_in_the_last_24_hours),
        'number_of_acs_updated_in_the_last_week':
            len(acs_updated_in_the_last_week),
        'number_of_acs_updated_in_the_last_month':
            len(acs_updated_in_the_last_month),
        'users': user_stats,
        'compendium_length_stats': article_length_stats,
    })
Ejemplo n.º 2
0
def home(request):

    all_newest_contents = Article.get_all_newest_contents_all_languages()

    compendiums = [
        {"label": ac.get_full_title(), "url": ac.get_absolute_url(), "lang": ac.lang, "updated": str(ac.updated)}
        for ac in all_newest_contents
    ]

    return render(request, "index.html", {"compendiums": json.dumps(compendiums)})
Ejemplo n.º 3
0
def tag(request, tag_slug):
    tag = get_object_or_404(Tag, slug=tag_slug)
    articles_with_tag = Article.objects.filter(tags=tag)
    all_newest_contents = Article.get_all_newest_contents_all_languages()
    filtered_contents = filter(lambda ac: ac.article in articles_with_tag, all_newest_contents)
    if len(filtered_contents) == 0:
        raise Http404
    compendiums = [
        {"label": ac.get_full_title(), "url": ac.get_absolute_url(), "lang": ac.lang, "updated": str(ac.updated)}
        for ac in filtered_contents
    ]

    return render(request, "index.html", {"compendiums": json.dumps(compendiums), "tag": tag})
Ejemplo n.º 4
0
def home(request):

    all_newest_contents = Article.get_all_newest_contents_all_languages()

    compendiums = [{
        'label': ac.get_full_title(),
        'url': ac.get_absolute_url(),
        'lang': ac.lang,
        'updated': str(ac.updated),
    } for ac in all_newest_contents]

    return render(request, 'index.html', {
        'compendiums': json.dumps(compendiums),
    })
Ejemplo n.º 5
0
def home(request):

    all_newest_contents = Article.get_all_newest_contents_all_languages()

    trie = [{
        "label": ac.get_full_title(),
        "url": ac.get_absolute_url(),
        "lang": ac.lang,
        "updated": str(ac.updated),
    } for ac in all_newest_contents]

    return render(request, 'index.html', {
        "trie": json.dumps(trie),
    })
Ejemplo n.º 6
0
def home(request):

    all_newest_contents = Article.get_all_newest_contents_all_languages()

    compendiums = [{
        'label': ac.get_full_title(),
        'url': ac.get_absolute_url(),
        'lang': ac.lang,
        'updated': str(ac.updated),
    } for ac in all_newest_contents]

    return render(request, 'index.html', {
        'compendiums': json.dumps(compendiums),
    })
Ejemplo n.º 7
0
def home(request):

    all_newest_contents = Article.get_all_newest_contents_all_languages()

    trie = [{
        "label": ac.get_full_title(),
        "url": ac.get_absolute_url(),
        "lang": ac.lang,
        "updated": str(ac.updated),
    } for ac in all_newest_contents]

    return render(request, 'index.html', {
        "trie": json.dumps(trie),
    })
Ejemplo n.º 8
0
def tag(request, tag_slug):
    tag = get_object_or_404(Tag, slug=tag_slug)
    articles_with_tag = Article.objects.filter(tags=tag)
    all_newest_contents = Article.get_all_newest_contents_all_languages()
    filtered_contents = filter(lambda ac: ac.article in articles_with_tag,
                               all_newest_contents)
    if len(filtered_contents) == 0:
        raise Http404
    compendiums = [{
        'label': ac.get_full_title(),
        'url': ac.get_absolute_url(),
        'lang': ac.lang,
        'updated': str(ac.updated),
    } for ac in filtered_contents]

    return render(request, 'index.html', {
        'compendiums': json.dumps(compendiums),
        'tag': tag,
    })
Ejemplo n.º 9
0
def tag(request, tag_slug):
    tag = get_object_or_404(Tag, slug=tag_slug)
    articles_with_tag = Article.objects.filter(tags=tag)
    all_newest_contents = Article.get_all_newest_contents_all_languages()
    filtered_contents = filter(lambda ac: ac.article in articles_with_tag,
                               all_newest_contents)
    if len(filtered_contents) == 0:
        raise Http404
    compendiums = [{
        'label': ac.get_full_title(),
        'url': ac.get_absolute_url(),
        'lang': ac.lang,
        'updated': str(ac.updated),
    } for ac in filtered_contents]

    return render(request, 'index.html', {
        'compendiums': json.dumps(compendiums),
        'tag': tag,
    })
Ejemplo n.º 10
0
 def test_get_all_newest_contents_all_languages(self):
     result = Article.get_all_newest_contents_all_languages()
     expected_result = [self.ac4, self.ac3, self.ac2]
     self.assertEquals(expected_result, result)
Ejemplo n.º 11
0
 def items(self):
     return Article.get_all_newest_contents_all_languages()
Ejemplo n.º 12
0
 def index_queryset(self, using=None):
     return ArticleContent.objects.filter(pk__in=[
         ac.pk for ac in Article.get_all_newest_contents_all_languages()
     ])
Ejemplo n.º 13
0
 def index_queryset(self, using=None):
     return ArticleContent.objects.filter(
         pk__in=[ac.pk
                 for ac in Article.get_all_newest_contents_all_languages()])