Mercurial > sat_legacy_website
annotate sat_website/views.py @ 47:3e460ca969d2
delete screenshots_tech.html, display all screenshots in the same page using sections
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 03 May 2015 22:36:27 +0200 |
parents | dfe7139dae0a |
children | cc099372a9ac |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SàT website: Salut à Toi's presentation website | |
6 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org) | |
7 | |
8 This file is part of SàT website. | |
9 | |
10 SàT website is free software: you can redistribute it and/or modify | |
11 it under the terms of the GNU Affero General Public License as published by | |
12 the Free Software Foundation, either version 3 of the License, or | |
13 (at your option) any later version. | |
14 | |
15 Foobar is distributed in the hope that it will be useful, | |
16 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 GNU Affero General Public License for more details. | |
19 | |
20 You should have received a copy of the GNU Affero General Public License | |
21 along with Foobar. If not, see <http://www.gnu.org/licenses/>. | |
22 """ | |
23 from django.http import Http404 | |
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 _ |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
27 from django.template import RequestContext |
0 | 28 from collections import OrderedDict |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
29 import screenshots, social_contract, utils, forms |
0 | 30 |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
31 CATEGORIES = OrderedDict([('frontends', (_(u"Presentation"), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
32 OrderedDict([("features", _(u"Features")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
33 ("frontends", _(u"Frontends")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
34 ("screenshots", _(u"Screenshots & Videos")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
35 ]))), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
36 ('principles', (_(u"Technical area"), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
37 OrderedDict([("principles", _(u"Principles")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
38 ("specifications", _(u"Specifications")), |
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 |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
53 CATEGORIES_HIDDEN = ('adhesion_form', 'thank_you') |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
54 |
39 | 55 PROJECTS_INFOS = {'sat': _(u'contains the backend, Primitivus and Jp'), |
56 'sat_media': _(u'Images and other media needed to launch SàT'), | |
57 'urwid_satext': _(u'console display library needed by Primitivus'), | |
58 'sat_pubsub': _(u'PubSub server component needed for SàT experimental blogging features'), | |
59 'libervia': _(u'Libervia frontend (web server and client)'), | |
60 } | |
0 | 61 |
62 def overview(request): | |
63 return render_to_response('sat_website/overview.html') | |
64 | |
65 def generic_cat(request, category): | |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
66 context = RequestContext(request, { |
2
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
67 "available_languages": ['fr', 'en'], |
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
68 "categories": CATEGORIES, |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
69 "categories_right": CATEGORIES_RIGHT, |
1
a49aa1b823f6
added SàT archive download link (detect the last version)
Goffi <goffi@goffi.org>
parents:
0
diff
changeset
|
70 "category": category, |
33
73c6333fd124
change overview.html, move the previous content to principles.html
souliane <souliane@mailoo.org>
parents:
29
diff
changeset
|
71 "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
|
72 "subscription_amounts": utils.get_asso_subscr_amounts(), |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
73 }) |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
74 |
2
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
75 context.update(csrf(request)) |
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
76 |
0 | 77 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
|
78 context.update(utils.get_asso_finance_status()) |
0 | 79 return render_to_response('sat_website/overview.html', context) |
80 elif category == "screenshots": | |
81 context["screenshots"] = screenshots.screenshots | |
47
3e460ca969d2
delete screenshots_tech.html, display all screenshots in the same page using sections
souliane <souliane@mailoo.org>
parents:
40
diff
changeset
|
82 context["screenshots_tech"] = screenshots.screenshots_tech |
0 | 83 elif category == "social_contract": |
84 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
|
85 elif category == "downloads": |
39 | 86 context["projects_infos"] = utils.get_projects_infos(PROJECTS_INFOS) |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
87 elif category == "adhesion": |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
88 context.update(utils.get_asso_finance_status()) |
40
dfe7139dae0a
add links to the statutes and rules of the association in the adhesion form
souliane <souliane@mailoo.org>
parents:
39
diff
changeset
|
89 context.update(utils.get_asso_urls()) |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
90 elif category == "adhesion_form": |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
91 if request.method == 'POST': |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
92 form = forms.RegistrationForm(request.POST) |
40
dfe7139dae0a
add links to the statutes and rules of the association in the adhesion form
souliane <souliane@mailoo.org>
parents:
39
diff
changeset
|
93 form.process_submitted_data() |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
94 if form.is_valid(): |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
95 category = 'thank_you' |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
96 else: |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
97 form = forms.RegistrationForm(initial={'subscription_amount': 10, |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
98 'payment_method': 'card'}) |
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
99 context['form'] = form |
40
dfe7139dae0a
add links to the statutes and rules of the association in the adhesion form
souliane <souliane@mailoo.org>
parents:
39
diff
changeset
|
100 context.update(utils.get_asso_urls()) |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
101 |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
102 def all_keys(cats): |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
103 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
|
104 return sum(subcats, cats.keys()) |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
105 |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
106 if category in all_keys(CATEGORIES) or category in all_keys(CATEGORIES_RIGHT) or category in CATEGORIES_HIDDEN: |
0 | 107 return render_to_response('sat_website/%s.html' % (category,), context) |
108 else: | |
109 raise Http404 |