view sat_website/views.py @ 1:a49aa1b823f6

added SàT archive download link (detect the last version)
author Goffi <goffi@goffi.org>
date Sun, 29 Jul 2012 01:52:27 +0200
parents 9305c6458e2f
children 0df46e87537d
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
SàT website: Salut à Toi's presentation website
Copyright (C) 2012  Jérôme Poisson (goffi@goffi.org)

This file is part of SàT website.

SàT website is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Foobar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
"""
from django.http import Http404
from django.shortcuts import render_to_response
from collections import OrderedDict
import screenshots, social_contract, utils

CATEGORIES = OrderedDict([("features", "Features"),
              ("frontends", "Frontends"),
              ("screenshots", "Screenshots & Videos"),
              ("community", "Community"),
              ("developers", "Developers corner"),
              ("social_contract", "Social contract")])

def overview(request):
    return render_to_response('sat_website/overview.html')

def generic_cat(request, category):
    latest_dl_path, latest_version = utils.get_latest_sat()
    context = {"categories": CATEGORIES,
               "category": category,
               "latest_dl_path": latest_dl_path,
               "latest_version": latest_version,
              }
    for k,v in CATEGORIES.iteritems():
        print "category: %s:%s" % (k,v)
    if not category or category == "overview":
        return render_to_response('sat_website/overview.html', context)
    elif category == "screenshots":
        context["screenshots"] = screenshots.screenshots
        context["screencasts"] = screenshots.screencasts
        return render_to_response('sat_website/screenshots.html', context)
    elif category == "social_contract":
        context["SOCIAL_CONTRACT"] = social_contract.get_social_contract()
        return render_to_response('sat_website/social_contract.html', context)
    elif category in CATEGORIES.keys():
        return render_to_response('sat_website/%s.html' % (category,), context)
    else:
        raise Http404