diff --git a/apps/__pycache__/__init__.cpython-311.pyc b/apps/__pycache__/__init__.cpython-311.pyc index 34a9701..cda2f28 100644 Binary files a/apps/__pycache__/__init__.cpython-311.pyc and b/apps/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/core/__pycache__/__init__.cpython-311.pyc b/apps/core/__pycache__/__init__.cpython-311.pyc index bb18473..5f3f2bc 100644 Binary files a/apps/core/__pycache__/__init__.cpython-311.pyc and b/apps/core/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/core/__pycache__/admin.cpython-311.pyc b/apps/core/__pycache__/admin.cpython-311.pyc index e25d02e..25773f0 100644 Binary files a/apps/core/__pycache__/admin.cpython-311.pyc and b/apps/core/__pycache__/admin.cpython-311.pyc differ diff --git a/apps/core/__pycache__/apps.cpython-311.pyc b/apps/core/__pycache__/apps.cpython-311.pyc index 71a013b..065e505 100644 Binary files a/apps/core/__pycache__/apps.cpython-311.pyc and b/apps/core/__pycache__/apps.cpython-311.pyc differ diff --git a/apps/core/__pycache__/models.cpython-311.pyc b/apps/core/__pycache__/models.cpython-311.pyc index 83bb35d..ff2d3b4 100644 Binary files a/apps/core/__pycache__/models.cpython-311.pyc and b/apps/core/__pycache__/models.cpython-311.pyc differ diff --git a/apps/core/migrations/__pycache__/__init__.cpython-311.pyc b/apps/core/migrations/__pycache__/__init__.cpython-311.pyc index 6ec117e..a34994a 100644 Binary files a/apps/core/migrations/__pycache__/__init__.cpython-311.pyc and b/apps/core/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/__init__.cpython-311.pyc b/apps/participants/__pycache__/__init__.cpython-311.pyc index d851821..4add1d1 100644 Binary files a/apps/participants/__pycache__/__init__.cpython-311.pyc and b/apps/participants/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/admin.cpython-311.pyc b/apps/participants/__pycache__/admin.cpython-311.pyc index 18497d5..65190bb 100644 Binary files a/apps/participants/__pycache__/admin.cpython-311.pyc and b/apps/participants/__pycache__/admin.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/apps.cpython-311.pyc b/apps/participants/__pycache__/apps.cpython-311.pyc index 1dd00f3..20a798b 100644 Binary files a/apps/participants/__pycache__/apps.cpython-311.pyc and b/apps/participants/__pycache__/apps.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/forms.cpython-311.pyc b/apps/participants/__pycache__/forms.cpython-311.pyc index c882027..5b6a73a 100644 Binary files a/apps/participants/__pycache__/forms.cpython-311.pyc and b/apps/participants/__pycache__/forms.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/models.cpython-311.pyc b/apps/participants/__pycache__/models.cpython-311.pyc index 45cfc64..894c648 100644 Binary files a/apps/participants/__pycache__/models.cpython-311.pyc and b/apps/participants/__pycache__/models.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/services.cpython-311.pyc b/apps/participants/__pycache__/services.cpython-311.pyc index 38dc886..a9969e7 100644 Binary files a/apps/participants/__pycache__/services.cpython-311.pyc and b/apps/participants/__pycache__/services.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/urls.cpython-311.pyc b/apps/participants/__pycache__/urls.cpython-311.pyc index dfc0358..e97808c 100644 Binary files a/apps/participants/__pycache__/urls.cpython-311.pyc and b/apps/participants/__pycache__/urls.cpython-311.pyc differ diff --git a/apps/participants/__pycache__/views.cpython-311.pyc b/apps/participants/__pycache__/views.cpython-311.pyc index 84d91cb..6cb0f6b 100644 Binary files a/apps/participants/__pycache__/views.cpython-311.pyc and b/apps/participants/__pycache__/views.cpython-311.pyc differ diff --git a/apps/participants/forms.py b/apps/participants/forms.py index b748798..cc6cebe 100644 --- a/apps/participants/forms.py +++ b/apps/participants/forms.py @@ -1,10 +1,44 @@ +# forms.py from django import forms +from django.utils.safestring import mark_safe from .models import Participant +import re +from django.core.exceptions import ValidationError + +_DECIMAL_RE = re.compile(r"[^\d,\.]") class ParticipantForm(forms.ModelForm): class Meta: - model = Participant - fields = ["group_name","R_diff","L_diff","Ph_diff","Pcu_diff","s_vol_over_eta"] - widgets = {f: forms.NumberInput(attrs={"step": "0.1", "class": "input"}) - for f in fields if f!="group_name"} - widgets["group_name"]= forms.TextInput(attrs={"class":"input"}) + model = Participant + fields = [ + "group_name", + "R_diff", + "L_diff", + "Ph_diff", + "Pcu_diff", + "s_vol_over_eta", + ] + widgets = { + f: forms.NumberInput(attrs={"step": "0.1", "class": "input"}) + for f in fields if f != "group_name" + } + widgets["group_name"] = forms.TextInput(attrs={"class": "input"}) + labels = { + "group_name": "Nombre del grupo", + "R_diff": mark_safe("Rdiff"), + "L_diff": mark_safe("Ldiff"), + "Ph_diff": mark_safe("Ph, diff"), + "Pcu_diff": mark_safe("Pcu, diff"), + "s_vol_over_eta": mark_safe("S/Vol·η"), + } + def clean_s_vol_over_eta(self): + raw = self.data.get("s_vol_over_eta", "") + raw = _DECIMAL_RE.sub("", raw) # quita letras o espacios + raw = raw.replace(",", ".") # coma → punto + try: + value = float(raw) + except ValueError: + raise ValidationError("Introduce un número válido (ej. 12.3)") + if value <= 0: + raise ValidationError("Debe ser mayor que 0") + return value \ No newline at end of file diff --git a/apps/participants/migrations/__pycache__/0001_initial.cpython-311.pyc b/apps/participants/migrations/__pycache__/0001_initial.cpython-311.pyc index 748015f..2a5b1de 100644 Binary files a/apps/participants/migrations/__pycache__/0001_initial.cpython-311.pyc and b/apps/participants/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/apps/participants/migrations/__pycache__/__init__.cpython-311.pyc b/apps/participants/migrations/__pycache__/__init__.cpython-311.pyc index b861ceb..1151a54 100644 Binary files a/apps/participants/migrations/__pycache__/__init__.cpython-311.pyc and b/apps/participants/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/participants/models.py b/apps/participants/models.py index 11a3b34..a7fce0b 100644 --- a/apps/participants/models.py +++ b/apps/participants/models.py @@ -1,6 +1,8 @@ # apps/participants/models.py from django.db import models from apps.core.models import TimeStampedModel +import re +from django.core.exceptions import ValidationError class Participant(TimeStampedModel): group_name = models.CharField(max_length=80, unique=True) @@ -10,8 +12,7 @@ class Participant(TimeStampedModel): L_diff = models.FloatField() Ph_diff = models.FloatField() Pcu_diff= models.FloatField() - - s_vol_over_eta = models.FloatField(help_text="S*Vol/η") # métrica objetiva + s_vol_over_eta = models.FloatField() score = models.FloatField(default=0) class Meta: @@ -19,3 +20,8 @@ class Participant(TimeStampedModel): def __str__(self): return self.group_name + + def clean(self): + super().clean() + if self.s_vol_over_eta <= 0: + raise ValidationError({"s_vol_over_eta": "Debe ser mayor que 0"}) diff --git a/apps/participants/services.py b/apps/participants/services.py index 0a36c65..14210e7 100644 --- a/apps/participants/services.py +++ b/apps/participants/services.py @@ -29,7 +29,7 @@ def calculate_scores(): p.score += _factor(diff) * weight # 3) Objetivo (rank por métrica) - sorted_by_obj = sorted(participants, key=lambda x: x.s_vol_over_eta) + sorted_by_obj = sorted(participants, key=lambda x: x.s_vol_over_eta, reverse=True) for idx, p in enumerate(sorted_by_obj, start=1): p.score += max(settings.objective_weight - (idx - 1), 0) diff --git a/apps/settingsapp/__pycache__/__init__.cpython-311.pyc b/apps/settingsapp/__pycache__/__init__.cpython-311.pyc index 6d3b08c..bf2d43e 100644 Binary files a/apps/settingsapp/__pycache__/__init__.cpython-311.pyc and b/apps/settingsapp/__pycache__/__init__.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/admin.cpython-311.pyc b/apps/settingsapp/__pycache__/admin.cpython-311.pyc index 287d271..81d8660 100644 Binary files a/apps/settingsapp/__pycache__/admin.cpython-311.pyc and b/apps/settingsapp/__pycache__/admin.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/apps.cpython-311.pyc b/apps/settingsapp/__pycache__/apps.cpython-311.pyc index 9cfc1ef..cab9cc2 100644 Binary files a/apps/settingsapp/__pycache__/apps.cpython-311.pyc and b/apps/settingsapp/__pycache__/apps.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/forms.cpython-311.pyc b/apps/settingsapp/__pycache__/forms.cpython-311.pyc index b7e5764..020f062 100644 Binary files a/apps/settingsapp/__pycache__/forms.cpython-311.pyc and b/apps/settingsapp/__pycache__/forms.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/models.cpython-311.pyc b/apps/settingsapp/__pycache__/models.cpython-311.pyc index 68a8908..e7fdb4f 100644 Binary files a/apps/settingsapp/__pycache__/models.cpython-311.pyc and b/apps/settingsapp/__pycache__/models.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/urls.cpython-311.pyc b/apps/settingsapp/__pycache__/urls.cpython-311.pyc index c178d3a..93ea779 100644 Binary files a/apps/settingsapp/__pycache__/urls.cpython-311.pyc and b/apps/settingsapp/__pycache__/urls.cpython-311.pyc differ diff --git a/apps/settingsapp/__pycache__/views.cpython-311.pyc b/apps/settingsapp/__pycache__/views.cpython-311.pyc index cb9a9bf..e763214 100644 Binary files a/apps/settingsapp/__pycache__/views.cpython-311.pyc and b/apps/settingsapp/__pycache__/views.cpython-311.pyc differ diff --git a/apps/settingsapp/migrations/__pycache__/0001_initial.cpython-311.pyc b/apps/settingsapp/migrations/__pycache__/0001_initial.cpython-311.pyc index 4a79813..4936556 100644 Binary files a/apps/settingsapp/migrations/__pycache__/0001_initial.cpython-311.pyc and b/apps/settingsapp/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/apps/settingsapp/migrations/__pycache__/__init__.cpython-311.pyc b/apps/settingsapp/migrations/__pycache__/__init__.cpython-311.pyc index d094d70..7bef1a1 100644 Binary files a/apps/settingsapp/migrations/__pycache__/__init__.cpython-311.pyc and b/apps/settingsapp/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/db.sqlite3 b/db.sqlite3 index 5c5c742..04242e9 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/static/css/styles.css b/static/css/styles.css index af3fb09..ac41ed1 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -1,39 +1,103 @@ -/* static/css/styles.css */ -:root{ - --brand-blue:#002e5d; - --brand-yellow:#f4b400; - --brand-orange:#ffa94d; - } - - body{background:var(--brand-blue);color:#fff;font-family:Inter,system-ui,sans-serif} - - /*–– Botones ––*/ - .btn{ - @apply inline-block px-6 py-3 rounded-xl font-medium transition transform; - } - .btn-primary{ - background:var(--brand-orange);color:#222; - } - .btn-primary:hover{filter:brightness(1.1) scale(1.02)} - .btn-secondary{ - background:transparent;border:2px solid var(--brand-orange);color:var(--brand-orange); - } - .btn-secondary:hover{background:var(--brand-orange);color:#222} - - /*–– Animaciones hero ––*/ - @keyframes scaleFade{ - 0%{opacity:0;transform:scale(.7)} - 100%{opacity:1;transform:scale(1)} - } - .hero-appear{animation:scaleFade .6s ease-out both} - - /*–– Transición logo grande→pequeño ––*/ - .logo-big {width: 60%} - .logo-small {width:48px} - - /*–– Table ––*/ - table{border-collapse:collapse;width:100%;max-width:640px;margin-inline:auto} - th,td{padding:.6rem 1rem;border-bottom:1px solid #ffffff33} - thead{background:#ffffff11} - tbody tr:nth-child(even){background:#ffffff08} - \ No newline at end of file +:root { + --brand-blue: #002e5d; + --brand-orange: #ffa94d; +} + +/* Cuerpo */ +body { + background: var(--brand-blue); + color: #fff; + font-family: Inter, system-ui, sans-serif; +} + +/*–– Botones ––*/ +.btn { + display: inline-block; + padding: 0.75rem 1.25rem; + border-radius: 0.5rem; + font-weight: 600; + text-decoration: none; + transition: box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + cursor: pointer; +} +.btn:hover { + box-shadow: 0 4px 8px rgba(0,0,0,0.15); +} +.btn:focus { + outline: 2px solid rgba(255,255,255,0.6); + outline-offset: 2px; +} + +/* Botón principal */ +.btn-primary { + background-color: var(--brand-orange); + color: #222; + border: none; +} +.btn-primary:hover { + background-color: #ee993f; +} + +/* Botón secundario */ +.btn-secondary { + background-color: transparent; + border: 2px solid var(--brand-orange); + color: var(--brand-orange); +} +.btn-secondary:hover { + background-color: var(--brand-orange); + color: #222; +} + +/*–– Formularios ––*/ +form { + max-width: 360px; + margin: 0 auto; /* centra el bloque del formulario */ + width: 100%; +} +form label { + display: block; + margin-bottom: 0.5rem; + font-weight: 500; + color: #fff; +} +form input, +form select, +form textarea { + width: 100%; + padding: 0.5rem 1rem; + margin-bottom: 1rem; + border: none; + border-radius: 0.375rem; + background-color: #fff; + color: #333; + font-size: 1rem; + box-sizing: border-box; +} +form input:focus, +form select:focus, +form textarea:focus { + outline: 2px solid var(--brand-orange); + outline-offset: 2px; +} + +/*–– Animaciones hero ––*/ +@keyframes scaleFade { + 0% { opacity: 0; transform: scale(.7) } + 100% { opacity: 1; transform: scale(1) } +} +.hero-appear { animation: scaleFade .6s ease-out both } + +/*–– Logos ––*/ +.logo-big { width: 60% } +.logo-small { width: 100px } + +/*-- Texto matemático --*/ +label sub, +label sup { + font-size: 0.75em; + vertical-align: baseline; + position: relative; + top: 0.25em; +} diff --git a/templates/base.html b/templates/base.html index 339caa6..9d8874a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,6 +12,7 @@ + {% block navbar %}
@@ -22,6 +23,7 @@
+ {% endblock %}
diff --git a/templates/home.html b/templates/home.html index 8ca5143..fd457b3 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load static %} +{% block navbar %}{% endblock %} {% block title %}Trafoking{% endblock %} {% block content %}
diff --git a/templates/participants/form.html b/templates/participants/form.html index 7a9c368..1e36fd4 100644 --- a/templates/participants/form.html +++ b/templates/participants/form.html @@ -20,4 +20,4 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/trafoking/__pycache__/__init__.cpython-311.pyc b/trafoking/__pycache__/__init__.cpython-311.pyc index 1445471..16aad93 100644 Binary files a/trafoking/__pycache__/__init__.cpython-311.pyc and b/trafoking/__pycache__/__init__.cpython-311.pyc differ diff --git a/trafoking/__pycache__/settings.cpython-311.pyc b/trafoking/__pycache__/settings.cpython-311.pyc index c52de05..75a993b 100644 Binary files a/trafoking/__pycache__/settings.cpython-311.pyc and b/trafoking/__pycache__/settings.cpython-311.pyc differ diff --git a/trafoking/__pycache__/urls.cpython-311.pyc b/trafoking/__pycache__/urls.cpython-311.pyc index 9a0b5c7..a23a531 100644 Binary files a/trafoking/__pycache__/urls.cpython-311.pyc and b/trafoking/__pycache__/urls.cpython-311.pyc differ diff --git a/trafoking/__pycache__/wsgi.cpython-311.pyc b/trafoking/__pycache__/wsgi.cpython-311.pyc index 71418a1..6d491f5 100644 Binary files a/trafoking/__pycache__/wsgi.cpython-311.pyc and b/trafoking/__pycache__/wsgi.cpython-311.pyc differ