Esempio n. 1
0
def comments_pdf(request, article_slug=None):
    user = None

    login(request)

    if request.user.is_authenticated() and request.user.is_staff:
      user = request.user
    else:
        return HttpResponseRedirect(reverse('index'))

    if article_slug:
        article = get_object_or_404( ArticleDetails, slug=article_slug )

    inactive_users = User.get_inactive

    comments = Feedback.objects.filter(articledetails_id = article.id, parent_id = None).order_by('-id').exclude(user__in=inactive_users)

    dt_obj = datetime.now()
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({'article':article, 'comments':comments, 'date_display': date_display})

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/comments_template.html', context ,RequestContext(request))

    else:
        return render_to_pdf('reports/comments_template.html', 'comments_template_', context, 'article_' + article.slug)
Esempio n. 2
0
def topics_pdf(request):

    return HttpResponseRedirect("http://bit.ly/dostor-masr")

    user = None

    login(request)

    if request.user.is_authenticated():
      user = request.user

    topics = Topic.objects.all().order_by('order')

    dt_obj = datetime.now()
    date_str = dt_obj.strftime("%Y%m%d_%H%M%S")
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({'topics':topics, 'date_display': date_display})

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/topics_template.html', context ,RequestContext(request))

    else:
        return render_to_pdf('reports/topics_template.html', 'topics_template_', context, 'dostor_masr')
Esempio n. 3
0
def topics_pdf(request):

    return HttpResponseRedirect("http://bit.ly/dostor-masr")

    user = None

    login(request)

    if request.user.is_authenticated():
        user = request.user

    topics = Topic.objects.all().order_by('order')

    dt_obj = datetime.now()
    date_str = dt_obj.strftime("%Y%m%d_%H%M%S")
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({'topics': topics, 'date_display': date_display})

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/topics_template.html', context,
                                  RequestContext(request))

    else:
        return render_to_pdf('reports/topics_template.html',
                             'topics_template_', context, 'dostor_masr')
Esempio n. 4
0
def topic_pdf(request, topic_slug=None):
    user = None

    login(request)

    if request.user.is_authenticated():
      user = request.user

    if topic_slug:
        topic = mc.get('topic_' + str(topic_slug))
        if not topic:
             topic = get_object_or_404( Topic, slug=topic_slug )
             mc.set('topic_' + str(topic_slug), topic, settings.MEMCACHED_TIMEOUT)
    
        articles = mc.get(str(topic_slug) + '_articles')
        if not articles:
             articles = topic.get_articles()
             mc.set(str(topic_slug) + '_articles', articles, settings.MEMCACHED_TIMEOUT)

    dt_obj = datetime.now()
    date_str = dt_obj.strftime("%Y%m%d_%H%M%S")
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({'topic':topic, 'articles':articles, 'date_display': date_display})

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/topic_template.html', context ,RequestContext(request))

    else:
        return render_to_pdf('reports/topic_template.html', 'topic_template_', context, 'topic_' + topic.slug)
Esempio n. 5
0
def topic_pdf(request, topic_slug=None):
    user = None

    login(request)

    if request.user.is_authenticated():
        user = request.user

    if topic_slug:
        topic = get_object_or_404(Topic, slug=topic_slug)
        articles = topic.get_articles()

    dt_obj = datetime.now()
    date_str = dt_obj.strftime("%Y%m%d_%H%M%S")
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({
        'topic': topic,
        'articles': articles,
        'date_display': date_display
    })

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/topic_template.html', context,
                                  RequestContext(request))

    else:
        return render_to_pdf('reports/topic_template.html', 'topic_template_',
                             context, 'topic_' + topic.slug)
Esempio n. 6
0
def infographic(request, type=''):
    user = None

    login(request)

    if request.user.is_authenticated():
      user = request.user

    template_context = {'type': type, 'settings': settings, 'user':user,}

    return render_to_response('charts/infographic.html', template_context ,RequestContext(request))
Esempio n. 7
0
def infographic(request, type=''):
    user = None

    login(request)

    if request.user.is_authenticated():
        user = request.user

    template_context = {
        'type': type,
        'settings': settings,
        'user': user,
    }

    return render_to_response('charts/infographic.html', template_context,
                              RequestContext(request))
Esempio n. 8
0
def comments_chart(request):
    user = None

    login(request)

    if request.user.is_authenticated() and request.user.is_staff:
      user = request.user
    else:
        return HttpResponseRedirect(reverse('index'))

    chart_data = mc.get('chart_data')
    if not chart_data:
         chart_data = Feedback.objects.feedback_charts()
         mc.set('chart_data', chart_data, settings.MEMCACHED_TIMEOUT)

    context = Context({'user': user, 'chart_data': chart_data})

    return render_to_response('charts/comments.html', context ,RequestContext(request))
Esempio n. 9
0
def export_feedback(request, article_slug):

    user = None
    login(request)

    if request.user.is_authenticated():  # and request.user.is_staff:
        user = request.user
    else:
        return HttpResponseRedirect(reverse("index"))

    # Retrieve data or whatever you need
    articles = ArticleDetails.objects.all()
    articles = sorted(articles, key=attrgetter("header.topic.id", "header.order", "id"))
    article = get_object_or_404(ArticleDetails, slug=article_slug)
    feedback = Feedback.objects.filter(articledetails_id=article.id)

    template_context = {"article": article, "articles": articles, "feedbacks": feedback}
    return render_to_response("reports/export_feedback.html", template_context, RequestContext(request))
Esempio n. 10
0
def comments_chart(request):
    user = None

    login(request)

    if request.user.is_authenticated() and request.user.is_staff:
        user = request.user
    else:
        return HttpResponseRedirect(reverse('index'))

    chart_data = mc.get('chart_data')
    if not chart_data:
        chart_data = Feedback.objects.feedback_charts()
        mc.set('chart_data', chart_data, settings.MEMCACHED_TIMEOUT)

    context = Context({'user': user, 'chart_data': chart_data})

    return render_to_response('charts/comments.html', context,
                              RequestContext(request))
Esempio n. 11
0
def comments_pdf(request, article_slug=None):
    user = None

    login(request)

    if request.user.is_authenticated() and request.user.is_staff:
        user = request.user
    else:
        return HttpResponseRedirect(reverse('index'))

    if article_slug:
        article = get_object_or_404(ArticleDetails, slug=article_slug)

    inactive_users = User.get_inactive

    comments = Feedback.objects.filter(
        articledetails_id=article.id,
        parent_id=None).order_by('-id').exclude(user__in=inactive_users)

    dt_obj = datetime.now()
    date_display = dt_obj.strftime("%Y-%m-%d")

    context = Context({
        'article': article,
        'comments': comments,
        'date_display': date_display
    })

    kwargs = {}

    if request.GET and request.GET.get('as', '') == 'html':
        return render_to_response('reports/comments_template.html', context,
                                  RequestContext(request))

    else:
        return render_to_pdf('reports/comments_template.html',
                             'comments_template_', context,
                             'article_' + article.slug)
Esempio n. 12
0
def export_feedback(request, article_slug):

    user = None
    login(request)

    if request.user.is_authenticated():  # and request.user.is_staff:
        user = request.user
    else:
        return HttpResponseRedirect(reverse('index'))

    #Retrieve data or whatever you need
    articles = ArticleDetails.objects.all()
    articles = sorted(articles,
                      key=attrgetter('header.topic.id', 'header.order', 'id'))
    article = get_object_or_404(ArticleDetails, slug=article_slug)
    feedback = Feedback.objects.filter(articledetails_id=article.id)

    template_context = {
        'article': article,
        'articles': articles,
        'feedbacks': feedback
    }
    return render_to_response('reports/export_feedback.html', template_context,
                              RequestContext(request))