comparison sat_website/views.py @ 27:eda4deefecd1

reorganisation of the menu using submenus
author souliane <souliane@mailoo.org>
date Wed, 21 Jan 2015 20:07:20 +0100
parents d42dd630476f
children b45621706d83
comparison
equal deleted inserted replaced
26:3df49721008c 27:eda4deefecd1
25 from django.core.context_processors import csrf 25 from django.core.context_processors import csrf
26 from django.utils.translation import ugettext_lazy as _ 26 from django.utils.translation import ugettext_lazy as _
27 from collections import OrderedDict 27 from collections import OrderedDict
28 import screenshots, social_contract, utils 28 import screenshots, social_contract, utils
29 29
30 CATEGORIES = OrderedDict([("features", _(u"Features")), 30 CATEGORIES = OrderedDict([('frontends', (_(u"Presentation"),
31 ("frontends", _(u"Frontends")), 31 OrderedDict([("features", _(u"Features")),
32 ("screenshots", _(u"Screenshots & Videos")), 32 ("frontends", _(u"Frontends")),
33 ("community", _(u"Community")), 33 ("screenshots", _(u"Screenshots & Videos")),
34 ("developers", _(u"Developers corner")), 34 ]))),
35 ("social_contract", _(u"Social contract"))]) 35 ('principles', (_(u"Technical area"),
36 OrderedDict([("principles", _(u"Principles")),
37 ("specifications", _(u"Specifications")),
38 ("screenshots_tech", _(u"Screenshots & Videos")),
39 ("downloads", _(u"Downloads")),
40 ("developers", _(u"Developers corner")),
41 ]))),
42 ('community', (_(u"Community"),
43 OrderedDict([("community", _(u"Get in touch")),
44 ("association", _(u"Association")),
45 ("links", _(u"Links")),
46 ]))),
47 ])
48
49 CATEGORIES_RIGHT = OrderedDict([("adhesion", _(u"Adhesion")),
50 ("social_contract", _(u"Social contract")),
51 ])
52
36 53
37 def overview(request): 54 def overview(request):
38 return render_to_response('sat_website/overview.html') 55 return render_to_response('sat_website/overview.html')
39 56
40 def generic_cat(request, category): 57 def generic_cat(request, category):
41 latest_dl_path, latest_version = utils.get_latest_sat() 58 latest_dl_path, latest_version = utils.get_latest_sat()
42 context = { 59 context = {
43 "available_languages": ['fr', 'en'], 60 "available_languages": ['fr', 'en'],
44 "categories": CATEGORIES, 61 "categories": CATEGORIES,
62 "categories_right": CATEGORIES_RIGHT,
45 "category": category, 63 "category": category,
46 "latest_dl_path": latest_dl_path, 64 "latest_dl_path": latest_dl_path,
47 "latest_version": latest_version, 65 "latest_version": latest_version,
48 } 66 }
67
49 context.update(csrf(request)) 68 context.update(csrf(request))
50 69
51 if not category or category == "overview": 70 if not category or category == "overview":
52 return render_to_response('sat_website/overview.html', context) 71 return render_to_response('sat_website/overview.html', context)
53 elif category == "screenshots": 72 elif category == "screenshots":
54 context["screenshots"] = screenshots.screenshots 73 context["screenshots"] = screenshots.screenshots
55 context["screencasts"] = screenshots.screencasts 74 context["screencasts"] = screenshots.screencasts
56 return render_to_response('sat_website/screenshots.html', context) 75 elif category == "screenshots_tech":
76 context["screenshots"] = screenshots.screencasts
77 context["screencasts"] = screenshots.screencasts
57 elif category == "social_contract": 78 elif category == "social_contract":
58 context["SOCIAL_CONTRACT"] = social_contract.get_social_contract() 79 context["SOCIAL_CONTRACT"] = social_contract.get_social_contract()
59 return render_to_response('sat_website/social_contract.html', context) 80
60 elif category in CATEGORIES.keys(): 81 def all_keys(cats):
82 subcats = [value[1].keys() for value in cats.values() if isinstance(value, tuple)]
83 return sum(subcats, cats.keys())
84
85 if category in all_keys(CATEGORIES) or category in all_keys(CATEGORIES_RIGHT):
61 return render_to_response('sat_website/%s.html' % (category,), context) 86 return render_to_response('sat_website/%s.html' % (category,), context)
62 else: 87 else:
63 raise Http404 88 raise Http404