mirror of
https://github.com/YunoHost-Apps/moncycle_ynh.git
synced 2024-09-03 19:46:16 +02:00
Merge branch 'v10' of https://github.com/Limezy/moncycle_ynh into v10
This commit is contained in:
commit
35a1c24630
6 changed files with 67 additions and 83 deletions
|
@ -20,8 +20,8 @@ define("SMTP_PORT", 25);
|
||||||
define("SMTP_MAIL", "__APP__@__DOMAIN__");
|
define("SMTP_MAIL", "__APP__@__DOMAIN__");
|
||||||
define("SMTP_PASSWORD", "");
|
define("SMTP_PASSWORD", "");
|
||||||
|
|
||||||
define("CREATION_COMPTE", true);
|
define("CREATION_COMPTE", __CREATION_COMPTE__);
|
||||||
define("CONNEXION_COMPTE", true);
|
define("CONNEXION_COMPTE", __CONNEXION_COMPTE__);
|
||||||
|
|
||||||
define("CSV_SEP", ";");
|
define("CSV_SEP", ";");
|
||||||
|
|
||||||
|
|
34
config_panel.toml
Normal file
34
config_panel.toml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
version = "1.0"
|
||||||
|
[main]
|
||||||
|
name = "Moncycle.app configuration"
|
||||||
|
|
||||||
|
# [main.comptes]
|
||||||
|
# name = "comptes"
|
||||||
|
|
||||||
|
# [main.comptes.creation_compte]
|
||||||
|
# ask.en = "Enable account creation"
|
||||||
|
# ask.fr = "Permettre la création de nouveaux comptes"
|
||||||
|
# type = "select"
|
||||||
|
# choices = ["true", "false"]
|
||||||
|
# default = "true"
|
||||||
|
# help = "Don't disable account creation before creating one for yourself !"
|
||||||
|
# bind = "CREATION_COMPTE:__INSTALL_DIR__/config.php"
|
||||||
|
#
|
||||||
|
# [main.comptes.connexion_compte]
|
||||||
|
# ask.en = "Enable account connexion"
|
||||||
|
# ask.fr = "Permettre la connexion aux comptes"
|
||||||
|
# type = "select"
|
||||||
|
# choices = ["true", "false"]
|
||||||
|
# default = "true"
|
||||||
|
# bind = "CONNEXION_COMPTE:__INSTALL_DIR__/config.php"
|
||||||
|
|
||||||
|
[main.export]
|
||||||
|
name = "export"
|
||||||
|
|
||||||
|
[main.export.csv_sep]
|
||||||
|
#ask.en = "Separator for data export in csv format"
|
||||||
|
#ask.fr = "Séparateur pour l'export des données au format csv"
|
||||||
|
bind = ":__INSTALL_DIR__/config.php"
|
||||||
|
type = "string"
|
||||||
|
#default = ";"
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
version = "1.0"
|
|
||||||
[main]
|
|
||||||
name = "Moncycle.app configuration"
|
|
||||||
[main.comptes]
|
|
||||||
name = "comptes"
|
|
||||||
[main.comptes.CREATION_COMPTE]
|
|
||||||
ask.en = "Enable account creation"
|
|
||||||
type = "boolean"
|
|
||||||
default = "true"
|
|
||||||
bind = ":__INSTALL_DIR__/config.php"
|
|
|
@ -24,77 +24,10 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
|
||||||
#=================================================
|
## import needed settings
|
||||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
#creation_compte=$(ynh_app_setting_get --app="$app" --key=creation_compte)
|
||||||
#=================================================
|
#connexion_compte=$(ynh_app_setting_get --app="$app" --key=connexion_compte)
|
||||||
|
#csv_sep=$(ynh_app_setting_get --app="$app" --key=csv_sep)
|
||||||
get__amount() {
|
|
||||||
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
|
|
||||||
local amount = 200
|
|
||||||
|
|
||||||
# It's possible to change some properties of the question by overriding it:
|
|
||||||
if [ $amount -gt 100 ]
|
|
||||||
then
|
|
||||||
cat << EOF
|
|
||||||
style: success
|
|
||||||
value: $amount
|
|
||||||
ask:
|
|
||||||
en: A lot of donation this month: **$amount €**
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
cat << EOF
|
|
||||||
style: danger
|
|
||||||
value: $amount
|
|
||||||
ask:
|
|
||||||
en: Not so much donation this month: $amount €
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
get__prices() {
|
|
||||||
local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
|
|
||||||
if [ "$prices" == "," ];
|
|
||||||
then
|
|
||||||
# Return YNH_NULL if you prefer to not return a value at all.
|
|
||||||
echo YNH_NULL
|
|
||||||
else
|
|
||||||
echo $prices
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
|
|
||||||
#=================================================
|
|
||||||
validate__publishable_key() {
|
|
||||||
|
|
||||||
# We can imagine here we test if the key is really a publisheable key
|
|
||||||
(is_secret_key $publishable_key) &&
|
|
||||||
echo 'This key seems to be a secret key'
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
|
||||||
#=================================================
|
|
||||||
set__prices() {
|
|
||||||
|
|
||||||
#---------------------------------------------
|
|
||||||
# IMPORTANT: setter are trigger only if a change is detected
|
|
||||||
#---------------------------------------------
|
|
||||||
for price in $(echo $prices | sed "s/,/ /"); do
|
|
||||||
frequency=$(echo $price | cut -d/ -f1)
|
|
||||||
currency=$(echo $price | cut -d/ -f2)
|
|
||||||
price_id=$(echo $price | cut -d/ -f3)
|
|
||||||
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
|
|
||||||
|
|
||||||
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
|
|
||||||
done
|
|
||||||
|
|
||||||
#---------------------------------------------
|
|
||||||
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
|
|
||||||
#---------------------------------------------
|
|
||||||
ynh_app_setting_set $app prices $prices
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -9,6 +9,14 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
creation_compte="true"
|
||||||
|
connexion_compte="true"
|
||||||
|
#csv_sep=";"
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=creation_compte --value=$creation_compte
|
||||||
|
ynh_app_setting_set --app=$app --key=connexion_compte --value=$connexion_compte
|
||||||
|
#ynh_app_setting_set --app=$app --key=csv_sep --value=$csv_sep
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -15,6 +15,25 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
# If creation_compte doesn't exist, create it
|
||||||
|
if [ -z "${creation_compte:-}" ]; then
|
||||||
|
creation_compte="true"
|
||||||
|
ynh_app_setting_set --app=$app --key=creation_compte --value=$creation_compte
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If connexion_compte doesn't exist, create it
|
||||||
|
if [ -z "${connexion_compte:-}" ]; then
|
||||||
|
connexion_compte="true"
|
||||||
|
ynh_app_setting_set --app=$app --key=connexion_compte --value=$connexion_compte
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If separateur_csv doesn't exist, create it
|
||||||
|
#if [ -z "${csv_sep:-}" ]; then
|
||||||
|
# csv_sep=";"
|
||||||
|
# ynh_app_setting_set --app=$app --key=csv_sep --value=$csv_sep
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue