annotate sat_website/social_contract.py @ 87:0377931f6278

add press release for Libervia 2015
author souliane <souliane@mailoo.org>
date Mon, 15 Jun 2015 21:03:25 +0200
parents bdd6ccffe149
children
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 SàT website: Salut à Toi's presentation website
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org)
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7 This file is part of SàT website.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
8
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
9 SàT website is free software: you can redistribute it and/or modify
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 it under the terms of the GNU Affero General Public License as published by
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12 (at your option) any later version.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
13
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
14 Foobar is distributed in the hope that it will be useful,
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17 GNU Affero General Public License for more details.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
18
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
19 You should have received a copy of the GNU Affero General Public License
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
20 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
21 """
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
22
8
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
23 from os.path import join, dirname, exists
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
24 from django.utils.translation import get_language
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
25 CONTRAT_SOCIAL = "CONTRAT_SOCIAL"
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
26
8
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
27 def get_social_contract():
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
28 """Return the localised social contract version"""
9
bdd6ccffe149 language code split
Goffi <goffi@goffi.org>
parents: 8
diff changeset
29 language_code = get_language().split("-")[0]
8
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
30 filename = CONTRAT_SOCIAL if language_code == "fr" else "CONTRAT_SOCIAL_%s" % (language_code,)
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
31 path = join(dirname(__file__), filename)
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
32 if not exists(path):
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
33 path = join(dirname(__file__), CONTRAT_SOCIAL) #we default to original version
c70038fb98dc Social Contract (Contrat Social) localisation
Goffi <goffi@goffi.org>
parents: 0
diff changeset
34
0
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
35 with open(path) as f:
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
36 text = f.read()
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
37 return text
9305c6458e2f initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
38