Statistics
| Branch: | Tag: | Revision:

root / cloudcmsfaq / views.py @ bd9ce789

History | View | Annotate | Download (2.4 kB)

1 916841de Kostas Papadimitriou
# Copyright 2012 GRNET S.A. All rights reserved.
2 916841de Kostas Papadimitriou
#
3 916841de Kostas Papadimitriou
# Redistribution and use in source and binary forms, with or
4 916841de Kostas Papadimitriou
# without modification, are permitted provided that the following
5 916841de Kostas Papadimitriou
# conditions are met:
6 916841de Kostas Papadimitriou
#
7 916841de Kostas Papadimitriou
#   1. Redistributions of source code must retain the above
8 916841de Kostas Papadimitriou
#      copyright notice, this list of conditions and the following
9 916841de Kostas Papadimitriou
#      disclaimer.
10 916841de Kostas Papadimitriou
#
11 916841de Kostas Papadimitriou
#   2. Redistributions in binary form must reproduce the above
12 916841de Kostas Papadimitriou
#      copyright notice, this list of conditions and the following
13 916841de Kostas Papadimitriou
#      disclaimer in the documentation and/or other materials
14 916841de Kostas Papadimitriou
#      provided with the distribution.
15 916841de Kostas Papadimitriou
#
16 916841de Kostas Papadimitriou
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 916841de Kostas Papadimitriou
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 916841de Kostas Papadimitriou
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 916841de Kostas Papadimitriou
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 916841de Kostas Papadimitriou
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 916841de Kostas Papadimitriou
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 916841de Kostas Papadimitriou
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 916841de Kostas Papadimitriou
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 916841de Kostas Papadimitriou
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 916841de Kostas Papadimitriou
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 916841de Kostas Papadimitriou
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 916841de Kostas Papadimitriou
# POSSIBILITY OF SUCH DAMAGE.
28 916841de Kostas Papadimitriou
#
29 916841de Kostas Papadimitriou
# The views and conclusions contained in the software and
30 916841de Kostas Papadimitriou
# documentation are those of the authors and should not be
31 916841de Kostas Papadimitriou
# interpreted as representing official policies, either expressed
32 916841de Kostas Papadimitriou
# or implied, of GRNET S.A.
33 916841de Kostas Papadimitriou
34 916841de Kostas Papadimitriou
35 916841de Kostas Papadimitriou
from django.conf import settings
36 916841de Kostas Papadimitriou
from django.views.generic.simple import direct_to_template
37 916841de Kostas Papadimitriou
from django.http import HttpResponseRedirect, Http404
38 bd9ce789 Kostas Papadimitriou
from django.shortcuts import get_object_or_404
39 916841de Kostas Papadimitriou
40 2a32f17b Kostas Papadimitriou
from cloudcms.models import Application, Service
41 916841de Kostas Papadimitriou
from cloudcmsfaq.models import Question, Category, CategoryTranslation
42 916841de Kostas Papadimitriou
43 916841de Kostas Papadimitriou
def index(request):
44 916841de Kostas Papadimitriou
    return archive(request)
45 916841de Kostas Papadimitriou
46 916841de Kostas Papadimitriou
def archive(request):
47 916841de Kostas Papadimitriou
    """
48 916841de Kostas Papadimitriou
    Display entries list
49 916841de Kostas Papadimitriou
    """
50 916841de Kostas Papadimitriou
    app = Application.current()
51 2a32f17b Kostas Papadimitriou
    services = Service.objects.all()
52 2a32f17b Kostas Papadimitriou
53 916841de Kostas Papadimitriou
    return direct_to_template(request,
54 2a32f17b Kostas Papadimitriou
            "cloudcmsfaq/archive.html", {'services': services})
55 916841de Kostas Papadimitriou
56 2a32f17b Kostas Papadimitriou
def detail(request, service, slug):
57 916841de Kostas Papadimitriou
    """
58 916841de Kostas Papadimitriou
    Display detailed question.
59 916841de Kostas Papadimitriou
    """
60 bd9ce789 Kostas Papadimitriou
    entry = get_object_or_404(Question, slug=slug)
61 36d49217 Olga Brani
    services = Service.objects.all()
62 bd9ce789 Kostas Papadimitriou
63 916841de Kostas Papadimitriou
    return direct_to_template(request,
64 2a32f17b Kostas Papadimitriou
            "cloudcmsfaq/detail.html", {'question': entry,
65 36d49217 Olga Brani
                                        'services': services })