Mercurial > sat_legacy_website
annotate sat_website/views/category.py @ 160:ff48d544bfdd default tip
gallery: replaced <video> tag by <img> for videos thumbnails
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 23 Sep 2018 16:41:30 +0200 |
parents | d9adc73fcd12 |
children |
rev | line source |
---|---|
0 | 1 # -*- coding: utf-8 -*- |
2 """ | |
3 SàT website: Salut à Toi's presentation website | |
4 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 This file is part of SàT website. | |
7 | |
8 SàT website is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 Foobar is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
19 along with SàT website. If not, see <http://www.gnu.org/licenses/>. |
0 | 20 """ |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
21 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
22 from collections import OrderedDict |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
23 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
24 from django.http import Http404 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
25 from django.views.generic.base import View |
0 | 26 from django.shortcuts import render_to_response |
149
b1c16cd53b62
update django to version 1.11, refactor project structure, better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
147
diff
changeset
|
27 from django.template.context_processors import csrf |
2
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
28 from django.utils.translation import ugettext_lazy as _ |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
29 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
30 from sat_website import utils, media, social_contract, forms |
0 | 31 |
149
b1c16cd53b62
update django to version 1.11, refactor project structure, better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
147
diff
changeset
|
32 |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
33 CATEGORIES = OrderedDict([('frontends', (_(u"Presentation"), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
34 OrderedDict([("features", _(u"Features")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
35 ("frontends", _(u"Frontends")), |
89
4b4a5d7602f8
rename screenshots to media, since not only screenshots but also videos are listed
souliane <souliane@mailoo.org>
parents:
78
diff
changeset
|
36 ("media", _(u"Screenshots & Videos")), |
136
c56b6ad62153
add section News with the official news feed
souliane <souliane@mailoo.org>
parents:
133
diff
changeset
|
37 ("news", _(u"News")), |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
38 ]))), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
39 ('principles', (_(u"Technical area"), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
40 OrderedDict([("principles", _(u"Principles")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
41 ("specifications", _(u"Specifications")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
42 ("downloads", _(u"Downloads")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
43 ("developers", _(u"Developers corner")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
44 ]))), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
45 ('community', (_(u"Community"), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
46 OrderedDict([("community", _(u"Get in touch")), |
55
a1e457ac6871
split adhesion.html between adhesion.html and association.html
souliane <souliane@mailoo.org>
parents:
52
diff
changeset
|
47 ("association", _(u"Association")), |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
48 ("links", _(u"Links")), |
56
01e9c646999f
add links to other projects and press files
souliane <souliane@mailoo.org>
parents:
55
diff
changeset
|
49 ("press", _(u"Press")), |
76
d2ea666fb1dd
add a FAQ section, now talking about HTTPS and CAcert
souliane <souliane@mailoo.org>
parents:
74
diff
changeset
|
50 ("faq", _(u"FAQ")), |
27
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 ]) |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
53 |
77
13ebb548f234
use membership instead of adhesion in English (also rename the files)
souliane <souliane@mailoo.org>
parents:
76
diff
changeset
|
54 CATEGORIES_RIGHT = OrderedDict([("membership", _(u"Membership")), |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
55 ("social_contract", _(u"Social contract")), |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
56 ]) |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
57 |
78
6250b65523c6
categories' aliases can be defined to be able to use "French" links like adhesion.html
souliane <souliane@mailoo.org>
parents:
77
diff
changeset
|
58 CATEGORIES_ALIASES = {"adhesion": "membership", |
6250b65523c6
categories' aliases can be defined to be able to use "French" links like adhesion.html
souliane <souliane@mailoo.org>
parents:
77
diff
changeset
|
59 "adhesion_form": "membership_form", |
89
4b4a5d7602f8
rename screenshots to media, since not only screenshots but also videos are listed
souliane <souliane@mailoo.org>
parents:
78
diff
changeset
|
60 "screenshots": "media", |
78
6250b65523c6
categories' aliases can be defined to be able to use "French" links like adhesion.html
souliane <souliane@mailoo.org>
parents:
77
diff
changeset
|
61 } |
6250b65523c6
categories' aliases can be defined to be able to use "French" links like adhesion.html
souliane <souliane@mailoo.org>
parents:
77
diff
changeset
|
62 |
77
13ebb548f234
use membership instead of adhesion in English (also rename the files)
souliane <souliane@mailoo.org>
parents:
76
diff
changeset
|
63 CATEGORIES_HIDDEN = ('membership_form', 'thank_you') |
34
9d553570cc61
add adhesion_form.html and thank_you.html
souliane <souliane@mailoo.org>
parents:
33
diff
changeset
|
64 |
39 | 65 PROJECTS_INFOS = {'sat': _(u'contains the backend, Primitivus and Jp'), |
66 'sat_media': _(u'Images and other media needed to launch SàT'), | |
67 'urwid_satext': _(u'console display library needed by Primitivus'), | |
68 'sat_pubsub': _(u'PubSub server component needed for SàT experimental blogging features'), | |
69 'libervia': _(u'Libervia frontend (web server and client)'), | |
70 } | |
0 | 71 |
138
2ec5653b190a
add url "whereami" to get the client IP address
souliane <souliane@mailoo.org>
parents:
136
diff
changeset
|
72 |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
73 class CategoryView(View): |
2
0df46e87537d
i18n: marked translatable texts + add change language form on pages footer
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
74 |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
75 @staticmethod |
27
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
76 def all_keys(cats): |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
77 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
|
78 return sum(subcats, cats.keys()) |
eda4deefecd1
reorganisation of the menu using submenus
souliane <souliane@mailoo.org>
parents:
4
diff
changeset
|
79 |
150
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
80 def get(self, request, category): |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
81 if category in CATEGORIES_ALIASES: |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
82 category = CATEGORIES_ALIASES[category] |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
83 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
84 context = { |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
85 "available_languages": ['fr', 'en'], |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
86 "categories": CATEGORIES, |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
87 "categories_right": CATEGORIES_RIGHT, |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
88 "category": category, |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
89 "libervia_demo_url": utils.get_libervia_demo_url(), |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
90 "subscription_amounts": utils.get_asso_subscr_amounts(), |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
91 } |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
92 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
93 context.update(csrf(request)) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
94 context.update(utils.get_asso_finance_status()) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
95 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
96 if not category or category == "overview": |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
97 context.update(utils.get_asso_finance_status()) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
98 return render_to_response('sat_website/overview.html', context) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
99 elif category == "media": |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
100 context["media"] = media.media |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
101 context["media_tech"] = media.media_tech |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
102 elif category == "social_contract": |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
103 context["SOCIAL_CONTRACT"] = social_contract.get_social_contract() |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
104 elif category == "downloads": |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
105 context["projects_infos"] = utils.get_projects_infos(PROJECTS_INFOS) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
106 elif category in ("association", "membership"): |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
107 context.update(utils.get_asso_urls()) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
108 elif category == "membership_form": |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
109 if request.method == 'POST': |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
110 form = forms.RegistrationForm(request.POST) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
111 form.process_submitted_data() |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
112 if form.is_valid(): |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
113 category = 'thank_you' |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
114 else: |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
115 form = forms.RegistrationForm(initial={'subscription_amount': 10, |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
116 'mailing': True}) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
117 context['form'] = form |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
118 context.update(utils.get_asso_urls()) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
119 |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
120 if ( |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
121 category in self.all_keys(CATEGORIES) or |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
122 category in self.all_keys(CATEGORIES_RIGHT) or |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
123 category in CATEGORIES_HIDDEN |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
124 ): |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
125 return render_to_response('sat_website/%s.html' % (category,), context) |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
126 else: |
b101828faa0e
split views.py in sub-modules
souliane <souliane@mailoo.org>
parents:
149
diff
changeset
|
127 raise Http404 |
153 | 128 |
129 # FIXME: dirty fix | |
130 def post(self, request, category): | |
131 return self.get(request, category) |