Skip to content
2 changes: 1 addition & 1 deletion aula/apps/baixes/rpt_carpeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def reportBaixaCarpeta(request, dia, professors):
for professor in professors:
report = tools.classebuida()
report.professor = professor
report.data = date(dia, "l, d M \d\e Y")
report.data = date(dia, r"l, d M \d\e Y")

imparticions = Impartir.objects.filter(
dia_impartir=dia, horari__professor=professor
Expand Down
4 changes: 2 additions & 2 deletions aula/apps/sortides/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,11 +2015,11 @@ def passarella(request, pk):
+ reverse("sortides__sortides__retorn_transaccio", kwargs={"pk": pk}),
"Ds_Merchant_ProductDescription": titol,
"Ds_Merchant_ConsumerLanguage": "003",
"DS_MERCHANT_URLOK": URL_DJANGO_AULA.replace("/", "\/")
"DS_MERCHANT_URLOK": URL_DJANGO_AULA.replace("/", r"\/")
+ reverse("sortides__sortides__pago_on_line", kwargs={"pk": pk})
+ "?next="
+ request.GET.get("next"),
"DS_MERCHANT_URLKO": URL_DJANGO_AULA.replace("/", "\/")
"DS_MERCHANT_URLKO": URL_DJANGO_AULA.replace("/", r"\/")
+ reverse("sortides__sortides__pago_on_lineKO", kwargs={"pk": pk})
+ "?next="
+ request.GET.get("next"),
Expand Down
12 changes: 6 additions & 6 deletions aula/apps/usuaris/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def extractEmail(address):
for a in splitAddress:
# General Email Regex (RFC 5322 Official Standard)
regex = (
"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}"
'~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\['
'\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])'
"?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]"
"?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]"
"*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}"
r'~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\['
r'\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])'
r"?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]"
r"?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]"
r"*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"
)
match = re.match(regex, a)
if match:
Expand Down
100 changes: 57 additions & 43 deletions demo/helpers/carrega.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def fesCarrega():
nivell=nivell, grup=grup, curs=curs
)
grupAula = Grup.objects.get(descripcio_grup=lgrup)
SGrup2Aula.objects.create(grup_saga=lgrup, Grup2Aula=grupAula)
SGrup2Aula.objects.update_or_create(grup_saga=lgrup, Grup2Aula=grupAula)
# KGrup2Aula.objects.create( grup_kronowin = lgrup, Grup2Aula = grupAula ) #ho fa als crear els grups

print("#Importem Kronowin 1 ( Per crear professors )")
Expand Down Expand Up @@ -176,7 +176,9 @@ def fesCarrega():
for g in Grup.objects.all():
professors_del_grup = Professor.objects.filter(horari__grup=g).distinct()
if professors_del_grup:
Tutor.objects.create(professor=random.choice(professors_del_grup), grup=g)
Tutor.objects.filter(grup=g).delete() # Nova línia. Netegem tutors previs d'aquest grup
Tutor.objects.get_or_create(grup=g, defaults={'professor': random.choice(professors_del_grup)})
#Tutor.objects.create(professor=random.choice(professors_del_grup), grup=g)

msg += "\nProfessors: " + " ,".join(
sorted(set([unicode(t.username) for t in Professor.objects.all()]))
Expand Down Expand Up @@ -260,51 +262,63 @@ def fesCarrega():
ca.impartir.save()

print("preparant configuració de matrícula")
tpv = TPV(
None,
"centre",
settings.CUSTOM_CODI_COMERÇ,
settings.CUSTOM_KEY_COMERÇ,
"Pagaments al centre",
False,
# 1. TPV
tpv, _ = TPV.objects.get_or_create(
nom="centre",
defaults={
'codi': settings.CUSTOM_CODI_COMERÇ,
'key': settings.CUSTOM_KEY_COMERÇ,
'descripcio': "Pagaments al centre",
'entornReal': False,
}
)
tpv.save()
for tipus in [settings.CUSTOM_TIPUS_QUOTA_MATRICULA, "taxes", "taxcurs", "uf"]:
tq = TipusQuota(None, tipus)
tq.save()
q = Quota(
None,
10,
date.today() + relativedelta(days=30),
inici_curs.year,
"Material escolar",
None,
tpv.id,
TipusQuota.objects.get(nom=settings.CUSTOM_TIPUS_QUOTA_MATRICULA).id,

# 2. Tipus de Quota
for tipus_nom in [settings.CUSTOM_TIPUS_QUOTA_MATRICULA, "taxes", "taxcurs", "uf"]:
TipusQuota.objects.get_or_create(nom=tipus_nom)

# 3. Quotes
# Quota: Material escolar
tipo_mat = TipusQuota.objects.get(nom=settings.CUSTOM_TIPUS_QUOTA_MATRICULA)
Quota.objects.get_or_create(
descripcio="Material escolar",
tipus=tipo_mat,
any=inici_curs.year,
defaults={
'importQuota': 10,
'dataLimit': date.today() + relativedelta(days=30),
'tpv': tpv,
'curs': None,
}
)
q.save()
q = Quota(
None,
360,
None,
inici_curs.year,
"Taxes cicles FP",
None,
tpv.id,
TipusQuota.objects.get(nom="taxcurs").id,

# Quota: Taxes cicles FP
tipo_tax = TipusQuota.objects.get(nom="taxcurs")
Quota.objects.get_or_create(
descripcio="Taxes cicles FP",
tipus=tipo_tax,
any=inici_curs.year,
defaults={
'importQuota': 360,
'dataLimit': None,
'tpv': tpv,
'curs': None,
}
)
q.save()
q = Quota(
None,
25,
None,
inici_curs.year,
"Taxa UF",
None,
tpv.id,
TipusQuota.objects.get(nom="uf").id,

# Quota: Taxa UF
tipo_uf = TipusQuota.objects.get(nom="uf")
Quota.objects.get_or_create(
descripcio="Taxa UF",
tipus=tipo_uf,
any=inici_curs.year,
defaults={
'importQuota': 25,
'dataLimit': None,
'tpv': tpv,
'curs': None,
}
)
q.save()

print("canviant dades dels professors")
for p in Professor.objects.all():
Expand Down
8 changes: 8 additions & 0 deletions docker/install_demo_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ sleep 1

# --- 1. Clonació del repositori

# Comprovar si l'usuari pot parlar amb Docker

if ! docker ps >/dev/null 2>&1; then
echo "❌ ERROR: L'usuari actual sembla no tenir permisos per usar Docker."
echo "Pot provar, o bé tancar la sessió SSH i tornar a entrar, o bé reiniciar la màquina."
exit 1
fi

# Instal·lar git, si cal.

echo "🔧 Comprovant que 'git' estigui instal·lat..."
Expand Down
43 changes: 32 additions & 11 deletions docker/install_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ echo "---------------------------------------------------------"

# Definició de variables
# Repositori i branca per la clonació
REPO_USER="ctrl-alt.d"
REPO_NAME="django-aula"
REPO_BRANCA="master"

REPO_URL="https://github.com/ctrl-alt-d/django-aula.git" # repositori del projecte
GIT_BRANCH="master" # Si es vol instal·lar una branca concreta. Exemple: "feat/upgrade-bootstrap"
# URLs
REPO_URL="https://github.com/${REPO_USER}/${REPO_NAME}.git" # Repositori del projecte

# Definició de l'URL remota de la llibreria de funcions
REPO_BASE_CLEAN="${REPO_URL%.git}"
RAW_BASE="${REPO_BASE_CLEAN/https:\/\/github.com/https:\/\/raw.githubusercontent.com}"
FUNCTIONS_URL="${RAW_BASE}/${GIT_BRANCH}/setup_djau/functions.sh"
FUNCTIONS_URL="${RAW_BASE}/${REPO_BRANCA}/setup_djau/functions.sh"
FUNCTIONS_FILE="./functions.sh"

echo -e "\n"
Expand Down Expand Up @@ -84,7 +87,7 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

USUARI_SUDO=$(logname)
USUARI_SUDO="${SUDO_USER:-$(whoami)}"

# Comprovar si el fitxer d'identificació del sistema (os-release) existeix
if [ ! -f /etc/os-release ]; then
Expand Down Expand Up @@ -122,11 +125,20 @@ case "$OS_ID" in
;;
esac

# Update i instal·lció de Curl
echo -e "${C_SUBTITULO}-> Preparant el sistema i instal·lant eines de xarxa...${RESET}"
echo -e "${C_SUBTITULO}-> Eliminant rastres de versions antigues de Docker...${RESET}"
# Llista oficial de paquets a eliminar
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
apt-get remove -y $pkg > /dev/null 2>&1
done

# Netegem fitxers de llistes antics que podrien causar conflictes amb el nou repositori
rm -f /etc/apt/sources.list.d/docker.sources /etc/apt/sources.list.d/docker.list

# Esperar el bloqueig de l'APT
esperar_apt

# Update i instal·lció de Curl
echo -e "${C_SUBTITULO}-> Preparant el sistema i instal·lant eines de xarxa...${RESET}"
if ! apt-get update -qq; then
finalitzar_amb_error "L'actualització de la llista de paquets (apt update) ha informat d'un error. Verifiqui si hi ha altres repositoris trencats al sistema."
fi
Expand Down Expand Up @@ -220,14 +232,16 @@ fi
sleep 2
echo -e "\n"

APT_DESC="Paquets de Docker: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
APT_DESC="Paquets de Docker: docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin make git"
echo -e "${C_INFO}ℹ️ $APT_DESC${RESET}"
apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
docker-compose-plugin \
make \
git

check_install "$APT_DESC"

Expand Down Expand Up @@ -256,14 +270,21 @@ sleep 2
echo -e "\n"
echo -e "${C_SUBTITULO}-> Afegint l'usuari ${USUARI_SUDO} al grup 'docker'...${RESET}"

groupadd -f docker

# Comprovem si l'usuari ja pertany al grup per no repetir l'acció
if id -nG "$USUARI_SUDO" | grep -qw "docker"; then
echo -e "${C_INFO}ℹ️ L'usuari ${USUARI_SUDO} ja forma part del grup 'docker'.${RESET}"
else
if ! usermod -aG docker "${USUARI_SUDO}"; then
finalitzar_amb_error "No s'ha pogut afegir l'usuari al grup 'docker'."
# Si l'usuari és root, no cal afegir-lo
if [ "$USUARI_SUDO" != "root" ]; then
if ! usermod -aG docker "${USUARI_SUDO}"; then
finalitzar_amb_error "No s'ha pogut afegir l'usuari al grup 'docker'."
fi
echo -e "${C_EXITO}✅ Usuari ${USUARI_SUDO} afegit al grup 'docker' correctament.${RESET}"
else
echo -e "${C_INFO}ℹ️ Usuari root detectat. No cal afegir-lo al grup docker.${RESET}"
fi
echo -e "${C_EXITO}✅ Usuari afegit al grup 'docker' correctament.${RESET}"
fi

sleep 1
Expand Down
20 changes: 13 additions & 7 deletions install_djau.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ clear

# 1. Definició de variables
# Repositori i branca per la clonació
REPO_URL="https://github.com/ctrl-alt-d/django-aula.git" # repositori del projecte
GIT_BRANCH="master" # Si es vol instal·lar una branca concreta. Exemple: "feat/upgrade-bootstrap"
REPO_USER="ctrl-alt-d" # "ctr-alt-d"
REPO_NAME="django-aula"
REPO_BRANCA="master" # "master"

REPO_URL="https://github.com/${REPO_USER}/${REPO_NAME}.git" # repositori del projecte

# Definició de sistema d'inicialització de processos del Sistema Operatiu (SysVinit vs Systemd)
IS_SYSTEMD=0 # Per defecte, assumim que no és systemd (Devuan, etc.)
Expand All @@ -32,7 +35,7 @@ echo "--------------------------------------------------------------------------
# 1. Definició de l'URL remota de la llibreria de funcions
REPO_BASE_CLEAN="${REPO_URL%.git}"
RAW_BASE="${REPO_BASE_CLEAN/https:\/\/github.com/https:\/\/raw.githubusercontent.com}"
FUNCTIONS_URL="${RAW_BASE}/${GIT_BRANCH}/setup_djau/functions.sh"
FUNCTIONS_URL="${RAW_BASE}/${REPO_BRANCA}/setup_djau/functions.sh"
FUNCTIONS_FILE="./functions.sh"


Expand Down Expand Up @@ -232,6 +235,9 @@ echo -e "\n"
echo -e "${C_SUBTITULO}--- 3.1 Instal·lant dependèncias del sistema (Python, Git, PostgreSQL, etc). Ara no s'instal·lará el servidor web ---${RESET}"
echo -e "${C_SUBTITULO}---------------------------------------------------------------------------------------------------------------------${RESET}"

# 0. Esperar per si hi ha un bloqueig de l'APT
esperar_apt

# 1. Actualitzar la llista de paquets
echo -e "${C_INFO}ℹ️ Actualiztzant la llista de paquets (apt-get update)...${RESET}"
apt-get update
Expand Down Expand Up @@ -527,18 +533,18 @@ if [ -d "$FULL_PATH" ] && [ "$(ls -A "$FULL_PATH")" ]; then
echo -e "\n"
exit 1
else
echo -e "${C_INFO}Clonant $REPO_URL, branca '$GIT_BRANCH' en $FULL_PATH.${RESET}"
echo -e "${C_INFO}Clonant $REPO_URL, branca '$REPO_BRANCA' en $FULL_PATH.${RESET}"

# Clonar el repositori com l'usuari de l'aplicació, forçant la branca especificada
sudo -u "$APP_USER" git clone -b "$GIT_BRANCH" "$REPO_URL" "$FULL_PATH"
sudo -u "$APP_USER" git clone -b "$REPO_BRANCA" "$REPO_URL" "$FULL_PATH"

if [ $? -ne 0 ]; then
echo -e "${C_ERROR}❌ ERROR: Fallda en clonar la branca '$GIT_BRANCH' del repositori '$REPO_URL'.${RESET}"
echo -e "${C_ERROR}❌ ERROR: Fallda en clonar la branca '$REPO_BRANCA' del repositori '$REPO_URL'.${RESET}"
echo "Comprovi la URL, conexió a internet o permisos de l'usuari '$APP_USER'."
echo -e "\n"
exit 1
fi
echo -e "${C_EXITO}✅ Repositori clonat (Branca: $GIT_BRANCH) a '$FULL_PATH'.${RESET}"
echo -e "${C_EXITO}✅ Repositori clonat (Branca: $REPO_BRANCA) a '$FULL_PATH'.${RESET}"
fi

echo -e "\n"
Expand Down
26 changes: 26 additions & 0 deletions setup_djau/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ C_SUBTITULO="${NEGRITA}${MAGENTA}" # Títuls de Subcapítul (1.1, 1.2)
C_INFO="${NEGRITA}${AMARILLO}" # Informació important (INFO, ATENCIÓ)



# =========================================================================
# Funció: esperar_apt
# Espera que el gestor de paquets (APT) estigui lliure
# que la deixa en blanc, si hi ha una resposta per defecte.
#
# Exemple: read_prompt "De quin color tens el cabell?" COLOR_CABELL "Blau"
# =========================================================================
esperar_apt() {
local LOCK_FILE="/var/lib/dpkg/lock-frontend"

if [ -f "$LOCK_FILE" ]; then
# Comprovem si realment hi ha un procés bloquejant el fitxer
if fuser "$LOCK_FILE" >/dev/null 2>&1; then
echo -e "${C_INFO}⏳ El sistema està realitzant tasques de manteniment (APT).${RESET}"
echo -e "${C_INFO} Esperant que finalitzin per poder continuar...${RESET}"

# flock espera fins que el lock s'allibera
sudo flock "$LOCK_FILE" true

echo -e "${C_EXITO}✅ Gestor de paquets lliure. Continuem amb la instal·lació.${RESET}"
fi
fi
}


# ===========================================================================
# Funció: finalitzar_amb_error
# Serveix per mostrar un text d'error concret greu i sortir de l'instal·lador
Expand Down
3 changes: 3 additions & 0 deletions setup_djau/setup_apache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ echo -e "\n"
echo -e "${C_SUBTITULO}--- 1.1 Instal·lació de Servidor Apache, WSGI, UFW y Certbot ---${RESET}"
echo -e "${C_SUBTITULO}----------------------------------------------------------------${RESET}"

# Esperar per si hi ha un bloqueig de l'APT
esperar_apt

echo -e "${C_INFO}ℹ️ Actualitzant la llista de paquets (apt-get update)...${RESET}"
apt-get update > /dev/null

Expand Down
Loading