annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
5 SàT website: Salut à Toi's presentation website
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This file is part of SàT website.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
9
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 SàT website is free software: you can redistribute it and/or modify
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11 it under the terms of the GNU Affero General Public License as published by
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12 the Free Software Foundation, either version 3 of the License, or
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
13 (at your option) any later version.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
14
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
15 Foobar is distributed in the hope that it will be useful,
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
18 GNU Affero General Public License for more details.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
19
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
20 You should have received a copy of the GNU Affero General Public License
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
21 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
22 """
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from django.http import Http404
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from django.shortcuts import render_to_response
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from collections import OrderedDict
1
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
26 import screenshots, social_contract, utils
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
27
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
28 CATEGORIES = OrderedDict([("features", "Features"),
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
29 ("frontends", "Frontends"),
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
30 ("screenshots", "Screenshots & Videos"),
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
31 ("community", "Community"),
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
32 ("developers", "Developers corner"),
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
33 ("social_contract", "Social contract")])
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
34
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
35 def overview(request):
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
36 return render_to_response('sat_website/overview.html')
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
37
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
38 def generic_cat(request, category):
1
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
39 latest_dl_path, latest_version = utils.get_latest_sat()
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
40 context = {"categories": CATEGORIES,
1
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
41 "category": category,
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 "latest_dl_path": latest_dl_path,
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
43 "latest_version": latest_version,
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
44 }
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
45 for k,v in CATEGORIES.iteritems():
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 print "category: %s:%s" % (k,v)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 if not category or category == "overview":
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48 return render_to_response('sat_website/overview.html', context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
49 elif category == "screenshots":
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
50 context["screenshots"] = screenshots.screenshots
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
51 context["screencasts"] = screenshots.screencasts
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
52 return render_to_response('sat_website/screenshots.html', context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
53 elif category == "social_contract":
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
54 context["SOCIAL_CONTRACT"] = social_contract.get_social_contract()
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
55 return render_to_response('sat_website/social_contract.html', context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
56 elif category in CATEGORIES.keys():
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
57 return render_to_response('sat_website/%s.html' % (category,), context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
58 else:
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
59 raise Http404