view sat_website/utils.py @ 35:10ce34ab389a

dummy patch (just add some new lines to make space between the blocks)
author souliane <souliane@mailoo.org>
date Tue, 27 Jan 2015 08:16:27 +0100
parents 31d196cf3b34
children d2c45f4ba57e
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
SàT website: Salut à Toi's presentation website
Copyright (C) 2012  Jérôme Poisson (goffi@goffi.org)

This file is part of SàT website.

SàT website is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Foobar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
"""

from os.path import basename,realpath,join
from django.conf import settings

def get_latest_sat():
    """Return a tuple with download path of latest SàT version, and version number"""
    try:
        path = settings.SAT_LINK_PATH
        real_path = realpath(path)
        filename = basename(real_path)
        version = filename[4:-8] #filename must be in the form of sat-version.tar.bz2
        if hasattr(settings, "SAT_DL_PATH"):
            dl_path = settings.SAT_DL_PATH
        else:
            dl_path = join(settings.SAT_DL_PREFIX, filename)
    except AttributeError:
        return (None, None)
    
    return (dl_path, version)

def get_libervia_demo_url():
    """Return the URL to Libervia online demo"""
    return settings.LIBERVIA_DEMO_URL

def get_asso_finance_status():
    """Returns information about the financement of the association"""
    def get_items(actual, target, prefix):
        actual = int(actual)
        target = int(target)
        perc = actual * 100 / target
        return {prefix + 'actual': actual,
                prefix + 'target': target,
                prefix + 'left': target - actual,
                prefix + 'perc': perc,
                prefix + 'perc_left': 100 - perc,
                }

    items = get_items(settings.ASSO_FINANCE_ACTUAL, settings.ASSO_FINANCE_TARGET, 'asso_finance_')
    items.update(get_items(settings.ASSO_MEMBERS_ACTUAL, settings.ASSO_MEMBERS_TARGET, 'asso_members_'))
    return items

def get_asso_subscr_amounts():
    return settings.ASSO_SUBSCR_AMOUNTS