annotate sat_website/views.py @ 33:73c6333fd124

change overview.html, move the previous content to principles.html
author souliane <souliane@mailoo.org>
date Tue, 27 Jan 2015 08:07:15 +0100
parents b45621706d83
children 9d553570cc61
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
2
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
25 from django.core.context_processors import csrf
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
26 from django.utils.translation import ugettext_lazy as _
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from collections import OrderedDict
1
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
28 import screenshots, social_contract, utils
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
29
27
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
30 CATEGORIES = OrderedDict([('frontends', (_(u"Presentation"),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
31 OrderedDict([("features", _(u"Features")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
32 ("frontends", _(u"Frontends")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
33 ("screenshots", _(u"Screenshots & Videos")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
34 ]))),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
35 ('principles', (_(u"Technical area"),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
36 OrderedDict([("principles", _(u"Principles")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
37 ("specifications", _(u"Specifications")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
38 ("screenshots_tech", _(u"Screenshots & Videos")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
39 ("downloads", _(u"Downloads")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
40 ("developers", _(u"Developers corner")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
41 ]))),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
42 ('community', (_(u"Community"),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
43 OrderedDict([("community", _(u"Get in touch")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
44 ("association", _(u"Association")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
45 ("links", _(u"Links")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
46 ]))),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
47 ])
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
48
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
49 CATEGORIES_RIGHT = OrderedDict([("adhesion", _(u"Adhesion")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
50 ("social_contract", _(u"Social contract")),
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
51 ])
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
52
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
53
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
54 def overview(request):
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
55 return render_to_response('sat_website/overview.html')
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
56
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
57 def generic_cat(request, category):
2
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
58 context = {
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
59 "available_languages": ['fr', 'en'],
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
60 "categories": CATEGORIES,
27
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
61 "categories_right": CATEGORIES_RIGHT,
1
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
62 "category": category,
a49aa1b823f6 added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents: 0
diff changeset
63 }
33
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
64 "libervia_demo_url": utils.get_libervia_demo_url(),
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
65 "subscription_amounts": utils.get_asso_subscr_amounts(),
27
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
66
2
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
67 context.update(csrf(request))
0df46e87537d i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents: 1
diff changeset
68
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
69 if not category or category == "overview":
33
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
70 context.update(utils.get_asso_finance_status())
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
71 return render_to_response('sat_website/overview.html', context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
72 elif category == "screenshots":
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
73 context["screenshots"] = screenshots.screenshots
27
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
74 elif category == "screenshots_tech":
29
b45621706d83 use Bootstrap carousels to display images and videos galeries:
souliane <souliane@mailoo.org>
parents: 27
diff changeset
75 context["screenshots"] = screenshots.screenshots_tech
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
76 elif category == "social_contract":
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
77 context["SOCIAL_CONTRACT"] = social_contract.get_social_contract()
33
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
78 elif category == "downloads":
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
79 latest_dl_path, latest_version = utils.get_latest_sat()
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
80 context["latest_dl_path"] = latest_dl_path
73c6333fd124 change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents: 29
diff changeset
81 context["latest_version"] = latest_version
27
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
82
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
83 def all_keys(cats):
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
84 subcats = [value[1].keys() for value in cats.values() if isinstance(value, tuple)]
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
85 return sum(subcats, cats.keys())
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
86
eda4deefecd1 reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents: 4
diff changeset
87 if category in all_keys(CATEGORIES) or category in all_keys(CATEGORIES_RIGHT):
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
88 return render_to_response('sat_website/%s.html' % (category,), context)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
89 else:
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
90 raise Http404