Fedgo29 commited on
Commit ·
0e45ab7
1
Parent(s): 8b7e99a
Adding changes by FedgoX
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- DockerfileAdded+24
- __pycache__/app.cpython-313.pycAdded
- __pycache__/config.cpython-313.pycAdded
- __pycache__/run.cpython-313.pycAdded
- __pycache__/seed.cpython-313.pycAdded
- app.pyAdded+36
- app/models/__init__.pyAdded+3
- app/models/__pycache__/__init__.cpython-313.pycAdded
- app/models/__pycache__/diploma.cpython-313.pycAdded
- app/models/__pycache__/entity.cpython-313.pycAdded
- app/models/__pycache__/user.cpython-313.pycAdded
- app/models/diploma.pyAdded+16
- app/models/entity.pyAdded+7
- app/models/user.pyAdded+13
- app/routes/__init__.pyAdded+10
- app/routes/__pycache__/__init__.cpython-313.pycAdded
- app/routes/__pycache__/admin.cpython-313.pycAdded
- app/routes/__pycache__/auth.cpython-313.pycAdded
- app/routes/__pycache__/diploma.cpython-313.pycAdded
- app/routes/__pycache__/verify.cpython-313.pycAdded
- app/routes/admin.pyAdded+42
- app/routes/auth.pyAdded+92
- app/routes/diploma.pyAdded+142
- app/routes/verify.pyAdded+34
- app/static/pdfs/3c915980cd4c4395aa4e271f41ce5186.pdfAdded
- app/static/pdfs/6fdb1e38b81a44d5b470664f139cce02.pdfAdded
- app/static/pdfs/c15ad4f351284657ba0ca61c80325efb.pdfAdded
- app/static/pdfs/e764025a5d2b4dec96054e446f7bbf85.pdfAdded
- app/static/pdfs/e8e5ee26b427415ea929f4f4c683f49d.pdfAdded
- app/static/pdfs/eff3e05edc8e4e60bcab13ea8edbc09d.pdfAdded
- app/static/qrs/3c915980cd4c4395aa4e271f41ce5186.pngAdded
- app/static/qrs/6fdb1e38b81a44d5b470664f139cce02.pngAdded
- app/static/qrs/c15ad4f351284657ba0ca61c80325efb.pngAdded
- app/static/qrs/e764025a5d2b4dec96054e446f7bbf85.pngAdded
- app/static/qrs/e8e5ee26b427415ea929f4f4c683f49d.pngAdded
- app/static/qrs/eff3e05edc8e4e60bcab13ea8edbc09d.pngAdded
- app/templates/admin_pending.htmlAdded+129
- app/templates/issue.htmlAdded+188
- app/templates/issue_success.htmlAdded+190
- app/templates/login.htmlAdded+106
- app/templates/register.htmlAdded+107
- app/templates/verify.htmlAdded+99
- app_pkg/models/__init__.pyAdded+3
- app_pkg/models/__pycache__/__init__.cpython-313.pycAdded
- app_pkg/models/__pycache__/diploma.cpython-313.pycAdded
- app_pkg/models/__pycache__/entity.cpython-313.pycAdded
- app_pkg/models/__pycache__/user.cpython-313.pycAdded
- app_pkg/models/diploma.pyAdded+16
- app_pkg/models/entity.pyAdded+7
- app_pkg/models/user.pyAdded+13
123456789101112131415161718192021222324## Dockerfile for Hugging Face Spaces (Flask app)# Based on the recommended pattern in the Spaces Docker guideFROM python:3.9-slim
# Create a non-root user for safetyRUN useradd -m -u 1000 userUSER userENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Use the existing requirements file (typo in repo is `requeriments.txt`).# Copy it and install as a non-root user.COPY --chown=user:root ./requeriments.txt ./requirements.txtRUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy project filesCOPY --chown=user:root . /app
# Expose the port expected by HF Spaces (7860). For Flask we'll run via uvicorn ASGI.EXPOSE 7860
# Command to start the app. `app.py` at repo root provides `app`.CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]123456789101112131415161718192021222324252627282930313233343536from flask import Flask, render_templatefrom flask_login import LoginManagerfrom app_pkg.models import dbfrom app_pkg.routes import register_blueprints
def create_app(): app = Flask(__name__, template_folder="app_pkg/templates", static_folder="app_pkg/static") app.config.from_object("config.Config")
db.init_app(app)
login = LoginManager() login.login_view = "auth.login" login.init_app(app)
from app_pkg.models.user import User
@login.user_loader def load_user(user_id): return User.query.get(int(user_id))
@app.route("/") def index(): return render_template("login.html")
register_blueprints(app)
with app.app_context(): db.create_all()
return app
app = create_app()
if __name__ == "__main__": app.run(debug=True)123from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()12345678910111213141516from . import dbimport uuidfrom datetime import date
class Diploma(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
certification_title = db.Column(db.String(200)) director = db.Column(db.String(150)) professor = db.Column(db.String(150)) issue_date = db.Column(db.Date, default=date.today)
entity_id = db.Column(db.Integer, db.ForeignKey("entity.id"))
hash_code = db.Column(db.String(100), unique=True, default=lambda: uuid.uuid4().hex)1234567from . import db
class Entity(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(150), unique=True, nullable=False)
users = db.relationship("User", backref="entity", lazy=True)12345678910111213from . import dbfrom flask_login import UserMixin
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(120), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(200), nullable=False)
role = db.Column(db.String(20), default="user") # admin / user status = db.Column(db.String(20), default="pending") # pending / active / rejected
entity_id = db.Column(db.Integer, db.ForeignKey('entity.id'))12345678910from .auth import auth_bpfrom .admin import admin_bpfrom .diploma import diploma_bpfrom .verify import verify_bp
def register_blueprints(app): app.register_blueprint(auth_bp) app.register_blueprint(admin_bp) app.register_blueprint(diploma_bp) app.register_blueprint(verify_bp)123456789101112131415161718192021222324252627282930313233343536373839404142from flask import Blueprint, render_template, request, redirect, url_forfrom flask_login import login_required, current_userfrom app.models import dbfrom app.models.user import User
admin_bp = Blueprint("admin", __name__, url_prefix="/admin")
@admin_bp.route("/pending", methods=["GET"])@login_requireddef list_pending(): if current_user.role != "admin": return {"error": "No autorizado"}, 403
users = User.query.filter_by(status="pending").all()
# If the client accepts HTML, render a simple admin page if request.accept_mimetypes.accept_html: return render_template("admin_pending.html", users=users)
return {"pending_users": [ {"id": u.id, "name": u.name, "email": u.email} for u in users ]}
@admin_bp.route("/approve/<int:user_id>", methods=["POST"])@login_requireddef approve(user_id): if current_user.role != "admin": return {"error": "No autorizado"}, 403
user = User.query.get(user_id) if not user: return {"error": "Usuario no encontrado"}
user.status = "active" db.session.commit()
# If request came from a browser form, redirect back to pending list if not request.is_json and request.accept_mimetypes.accept_html: return redirect(url_for("admin.list_pending"))
return {"message": "Usuario aprobado"}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192from flask import Blueprint, request, render_template, redirect, url_forfrom werkzeug.security import generate_password_hash, check_password_hashfrom flask_login import login_user, logout_user, login_required, current_user
from app.models import dbfrom app.models.user import Userfrom app.models.entity import Entity
auth_bp = Blueprint("auth", __name__, url_prefix="/auth")
@auth_bp.route("/register", methods=["GET", "POST"])def register(): if request.method == "GET": return render_template("register.html") if request.is_json: data = request.get_json() else: data = request.form
# basic validation name = data.get("name") email = data.get("email") password = data.get("password") entity_id = data.get("entity_id")
if not (name and email and password and entity_id): return {"error": "Faltan campos"}, 400
try: entity_id = int(entity_id) except Exception: return {"error": "entity_id inválido"}, 400
entity = Entity.query.filter_by(id=entity_id).first() if not entity: return {"error": "Entidad no existe"}, 404
user = User( name=name, email=email, password=generate_password_hash(password), entity_id=entity.id, status="pending" )
db.session.add(user) db.session.commit()
return {"message": "Tu registro está pendiente de aprobación."}
@auth_bp.route("/login", methods=["GET", "POST"])def login(): if request.method == "GET": return render_template("login.html") if request.is_json: data = request.get_json() else: data = request.form
email = data.get("email") password = data.get("password")
if not (email and password): return {"error": "Faltan credenciales"}, 400
user = User.query.filter_by(email=email).first()
if not user or not check_password_hash(user.password, password): return {"error": "Credenciales inválidas"}, 401
if user.status != "active": return {"error": "Cuenta no aprobada"}, 403
login_user(user)
# If client expects JSON (API), return JSON. If it's a browser form, redirect. if request.is_json: return {"message": "Login exitoso"}
# browser POST: redirect based on role if getattr(user, "role", "user") == "admin": return redirect(url_for("admin.list_pending")) return redirect(url_for("diploma.create_diploma"))
@auth_bp.route("/logout", methods=["GET", "POST"])@login_requireddef logout(): logout_user() if request.is_json: return {"message": "Logout exitoso"} return redirect(url_for("auth.login"))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142from flask import Blueprint, request, render_template, current_appfrom flask_login import login_required, current_userfrom app.models import dbfrom app.models.diploma import Diplomaimport qrcodeimport os
diploma_bp = Blueprint("diploma", __name__, url_prefix="/diploma")
@diploma_bp.route("/create", methods=["GET", "POST"])@login_requireddef create_diploma(): if request.method == "GET": return render_template("issue.html")
if current_user.status != "active": return {"error": "Cuenta no aprobada"}, 403
# Accept JSON (API) or form-encoded (browser) submissions if request.is_json: data = request.get_json() else: data = request.form
title = data.get("title") director = data.get("director") provincial_director = data.get("provincial_director") professor = data.get("professor") student_name = data.get("student_name") student_id = data.get("student_id") center_name = data.get("center_name") graduation_year = data.get("graduation_year") registration_number = data.get("registration_number")
# Basic required validation if not title: return {"error": "Falta el campo 'title'"}, 400
# Build diploma with guaranteed/core columns only to avoid TypeError diploma = Diploma( user_id=current_user.id, certification_title=title, director=director, professor=professor, entity_id=current_user.entity_id )
# Set optional fields only if the model actually defines them optional_fields = { "student_name": student_name, "student_id": student_id, "center_name": center_name, "registration_number": registration_number, "provincial_director": provincial_director, "professor": professor, }
for field, value in optional_fields.items(): if value is None: continue # check if the model has this attribute/column if hasattr(Diploma, field): try: # graduation_year handled separately below setattr(diploma, field, value) except Exception: # ignore setting if it fails; will surface on commit pass
# graduation_year conversion and assignment if graduation_year: try: gy = int(graduation_year) except Exception: return {"error": "Campo 'graduation_year' inválido"}, 400 if hasattr(Diploma, "graduation_year"): setattr(diploma, "graduation_year", gy)
try: db.session.add(diploma) db.session.commit() except TypeError as e: # likely caused by unexpected kwargs earlier or model mismatch db.session.rollback() return { "error": "TypeError al crear Diploma", "detail": str(e), "hint": "El modelo Diploma no tiene algunas de las columnas que intentas guardar. Ejecuta `python reset_db.py` si esperas columnas nuevas." }, 400 except Exception as e: db.session.rollback() return {"error": "Error al crear Diploma", "detail": str(e)}, 500
url = f"https://tu-dominio.com/api/verify/{diploma.hash_code}"
qr = qrcode.make(url) qrs_dir = os.path.join(current_app.static_folder, "qrs") os.makedirs(qrs_dir, exist_ok=True) qr_path = os.path.join(qrs_dir, f"{diploma.hash_code}.png") qr.save(qr_path)
# save uploaded pdf if present if not request.is_json and "pdf" in request.files: pdf = request.files["pdf"] pdfs_dir = os.path.join(current_app.static_folder, "pdfs") os.makedirs(pdfs_dir, exist_ok=True) pdf.save(os.path.join(pdfs_dir, f"{diploma.hash_code}.pdf"))
# If the request came from a browser form, redirect to a success page if not request.is_json and request.accept_mimetypes.accept_html: return render_template( "issue_success.html", qr_url=f"/static/qrs/{diploma.hash_code}.png", pdf_url=(f"/static/pdfs/{diploma.hash_code}.pdf" if os.path.exists(os.path.join(current_app.static_folder, "pdfs", f"{diploma.hash_code}.pdf")) else None), hash_code=diploma.hash_code )
return { "message": "Diploma creado", "qr": f"/static/qrs/{diploma.hash_code}.png", "hash": diploma.hash_code }
@diploma_bp.route('/view/<hash_code>')def view_diploma(hash_code): diploma = Diploma.query.filter_by(hash_code=hash_code).first() if not diploma: return ("Diploma no encontrado", 404)
qr_path = f"/static/qrs/{hash_code}.png" pdf_path = None pdf_full = os.path.join(current_app.static_folder, "pdfs", f"{hash_code}.pdf") if os.path.exists(pdf_full): pdf_path = f"/static/pdfs/{hash_code}.pdf"
return render_template( "issue_success.html", qr_url=qr_path, pdf_url=pdf_path, hash_code=hash_code )12345678910111213141516171819202122232425262728293031323334from flask import Blueprint, request, render_templatefrom app.models.diploma import Diploma
verify_bp = Blueprint("verify", __name__, url_prefix="/api")
@verify_bp.route("/verify/<hash_code>")def verify(hash_code): diploma = Diploma.query.filter_by(hash_code=hash_code).first()
if not diploma: if request.accept_mimetypes.accept_html: return render_template("verify.html", student_name="Not found", course="", issued_at="", diploma_id="", sha256=hash_code, issuer="", download_url="#"), 404 return {"error": "Código inválido"}, 404
if request.accept_mimetypes.accept_html: return render_template( "verify.html", student_name="", course=diploma.certification_title, issued_at=str(diploma.issue_date), diploma_id=diploma.id, sha256=diploma.hash_code, issuer=diploma.entity_id, download_url=f"/static/qrs/{diploma.hash_code}.png", )
return { "title": diploma.certification_title, "date": str(diploma.issue_date), "director": diploma.director, "professor": diploma.professor, "entity": diploma.entity_id }123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Usuarios Pendientes</title>
<style> body { margin: 0; padding: 2rem; font-family: "Segoe UI", sans-serif; background: linear-gradient(135deg, #0d1117, #1f2937); color: #e5e7eb; }
/* Barra superior con logout */ .top-bar { display: flex; justify-content: space-between; align-items: center; background: #111827; padding: 1rem 1.5rem; border-radius: 10px; border: 1px solid #374151; box-shadow: 0 0 15px rgba(0,0,0,0.3); margin-bottom: 2rem; }
h2 { margin: 0; color: #f3f4f6; letter-spacing: 1px; }
.btn { padding: 10px 18px; background: #3b82f6; color: white; border: none; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s ease-in-out; }
.btn:hover { background: #2563eb; transform: translateY(-2px); }
.card { background: #111827; padding: 1.5rem 2rem; border-radius: 12px; border: 1px solid #374151; box-shadow: 0 0 25px rgba(0,0,0,0.4); animation: fadeIn 0.5s ease; }
ul { list-style: none; padding: 0; }
li { background: #1f2937; padding: 1rem; margin-bottom: 10px; border-radius: 8px; border: 1px solid #374151; display: flex; justify-content: space-between; align-items: center; }
a { color: #60a5fa; text-decoration: none; font-weight: 600; margin-top: 20px; display: inline-block; }
a:hover { text-decoration: underline; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
</style></head>
<body>
<div class="top-bar"> <h2>Usuarios Pendientes (Admin)</h2>
<form method="post" action="/auth/logout"> <button type="submit" class="btn">Logout</button> </form></div>
<div class="card">
{% if users %} <ul> {% for u in users %} <li> <span><b>{{ u.name }}</b> ({{ u.email }})</span>
<form method="post" action="/admin/approve/{{ u.id }}"> <button type="submit" class="btn">Aprobar</button> </form> </li> {% endfor %} </ul>{% else %} <p>No hay usuarios pendientes.</p>{% endif %}
<a href="/">Volver</a></div>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Emitir Diploma (Admin)</title> <style> body { margin: 0; font-family: "Segoe UI", sans-serif; background: linear-gradient(135deg, #111827, #1e293b); color: #e5e7eb; min-height: 100vh; padding: 30px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #374151; }
h2 { margin: 0; color: #93c5fd; font-size: 24px; }
.logout-btn { padding: 10px 18px; background: #ef4444; border: none; border-radius: 8px; color: white; font-weight: 600; cursor: pointer; transition: 0.2s; }
.logout-btn:hover { background: #dc2626; transform: translateY(-2px); } .cert-form { background: #0f172a; padding: 2rem; border-radius: 14px; max-width: 650px; margin: 0 auto; box-shadow: 0 0 25px rgba(0,0,0,0.45); animation: fadeIn 0.5s ease; } form { background: #0f172a; }
.field { margin-bottom: 15px; }
label { display: block; font-size: 14px; margin-bottom: 6px; color: #93c5fd; font-weight: 600; }
input { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #374151; background: #1e293b; color: #e5e7eb; font-size: 14px; outline: none; transition: border 0.2s; }
input:focus { border-color: #3b82f6; }
button[type="submit"] { width: 100%; padding: 14px; margin-top: 10px; background: #3b82f6; border: none; border-radius: 8px; color: white; font-size: 16px; font-weight: 600; cursor: pointer; transition: 0.2s; }
button[type="submit"]:hover { background: #2563eb; transform: translateY(-2px); }
p { text-align: center; font-size: 13px; opacity: 0.7; margin-top: 15px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } </style></head>
<body>
<div class="topbar"> <h2>Issue Diploma (Admin)</h2>
<form method="post" action="/auth/logout"> <button class="logout-btn" type="submit">Logout</button> </form></div>
<form class="cert-form" method="post" enctype="multipart/form-data" action="/diploma/create">
<div class="field"> <label>Nombre del Estudiante:</label> <input name="student_name" required> </div>
<div class="field"> <label>Cédula:</label> <input name="student_id" required> </div>
<div class="field"> <label>Centro de Enseñanza Superior:</label> <input name="center_name" required> </div>
<div class="field"> <label>Nombre del Título Obtenido:</label> <input name="title" required> </div>
<div class="field"> <label>Año de la Graduación:</label> <input type="number" name="graduation_year" required> </div>
<div class="field"> <label>Número de Registro:</label> <input name="registration_number" required> </div>
<div class="field"> <label>Director del Centro Educativo:</label> <input name="director" required> </div>
<div class="field"> <label>Directora Provincial:</label> <input name="provincial_director" required> </div>
<div class="field"> <label>Profesor (opcional):</label> <input name="professor"> </div>
<div class="field"> <label>Adjuntar PDF del diploma (opcional):</label> <input type="file" name="pdf" accept="application/pdf"> </div>
<button type="submit">Emitir & Generar QR</button>
<p>El navegador debe estar autenticado como administrador.</p></form>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Diploma Creado</title> <style> body { margin: 0; font-family: "Segoe UI", sans-serif; background: linear-gradient(135deg, #0d1117, #1f2937); height: 100vh; color: #e5e7eb; display: flex; flex-direction: column; }
/* BARRA SUPERIOR */ .topbar { width: 100%; background: #111827; padding: 14px 22px; box-shadow: 0 2px 8px rgba(0,0,0,0.4); display: flex; justify-content: flex-end; align-items: center; }
.topbar form { margin: 0; }
.logout-btn { background: #ef4444; color: white; border: none; padding: 8px 18px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.logout-btn:hover { background: #dc2626; transform: translateY(-2px); }
/* GRID PRINCIPAL */ .grid-wrapper { flex: 1; display: flex; justify-content: center; align-items: center; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; width: 80%; max-width: 1200px; padding: 2rem; animation: fadeIn 0.6s ease; }
.card { background: #111827; padding: 2rem; border-radius: 12px; text-align: center; box-shadow: 0 0 25px rgba(0,0,0,0.4); }
h2 { margin-top: 0; color: #f3f4f6; letter-spacing: 1px; margin-bottom: 10px; }
p { font-size: 14px; margin: 10px 0; line-height: 1.5; }
img { max-width: 260px; margin-top: 10px; border-radius: 6px; }
a { color: #60a5fa; text-decoration: none; font-weight: 600; font-size: 14px; }
a:hover { text-decoration: underline; }
.section { margin: 18px 0; padding: 12px; background: #1f2937; border-radius: 8px; border: 1px solid #374151; }
.button-like { display: block; width: 100%; padding: 12px; background: #3b82f6; color: white; border-radius: 8px; cursor: pointer; margin-top: 14px; font-size: 15px; font-weight: 600; text-decoration: none; transition: 0.2s; }
.button-like:hover { background: #2563eb; transform: translateY(-2px); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } </style></head><body>
<!-- BARRA SUPERIOR --><div class="topbar"> <form method="post" action="/auth/logout"> <button class="logout-btn" type="submit">Logout</button> </form></div>
<div class="grid-wrapper"> <div class="grid">
<!-- COLUMNA IZQUIERDA --> <div class="card"> <h2>Diploma creado ✔️</h2>
{% if qr_url %} <div class="section"> <p><strong>QR generado:</strong></p> <img src="{{ qr_url }}" alt="QR"> <p><a href="{{ qr_url }}" download class="button-like">Descargar QR</a></p> </div> {% endif %}
{% if pdf_url %} <div class="section"> <p><strong>PDF cargado:</strong></p> <a href="{{ pdf_url }}" download class="button-like">Descargar PDF</a> </div> {% else %} <div class="section"> <p>No se subió PDF.</p> </div> {% endif %} </div>
<!-- COLUMNA DERECHA --> <div class="card"> <h2>Datos del Diploma</h2>
<div class="section"> <p><strong>Hash:</strong> {{ hash_code }}</p> </div>
<a href="/diploma/create" class="button-like">Crear otro diploma</a> <a href="/" class="button-like" style="margin-top:10px;">Volver al inicio</a> </div>
</div></div>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Login</title> <style> body { margin: 0; font-family: "Segoe UI", sans-serif; background: linear-gradient(135deg, #0d1117, #1f2937); display: flex; justify-content: center; align-items: center; height: 100vh; color: #e5e7eb; }
form { background: #111827; padding: 2rem; border-radius: 12px; width: 320px; box-shadow: 0 0 25px rgba(0,0,0,0.4); animation: fadeIn 0.6s ease; }
h2 { margin-top: 0; text-align: center; color: #f3f4f6; letter-spacing: 1px; }
input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 8px; border: 1px solid #374151; background: #1f2937; color: #e5e7eb; font-size: 14px; outline: none; transition: border 0.2s; }
input:focus { border-color: #3b82f6; }
button { width: 100%; padding: 12px; background: #3b82f6; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 600; transition: 0.2s; }
button:hover { background: #2563eb; transform: translateY(-2px); }
p { font-size: 13px; margin-top: 12px; text-align: center; line-height: 1.4; }
a { color: #60a5fa; text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } </style></head><body>
<form method="post" action="/auth/login"> <h2>Login</h2>
<input name="email" placeholder="Email" required> <input name="password" placeholder="Password" type="password" required>
<button type="submit">Ingresar</button>
<p>¿No tienes cuenta? <a href="/auth/register">Regístrate</a></p></form>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Registro</title> <style> body { margin: 0; font-family: "Segoe UI", sans-serif; background: linear-gradient(135deg, #0d1117, #1f2937); display: flex; justify-content: center; align-items: center; height: 100vh; color: #e5e7eb; }
form { background: #111827; padding: 2rem; border-radius: 12px; width: 320px; box-shadow: 0 0 25px rgba(0,0,0,0.4); animation: fadeIn 0.6s ease; }
h2 { margin-top: 0; text-align: center; color: #f3f4f6; letter-spacing: 1px; }
input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 8px; border: 1px solid #374151; background: #1f2937; color: #e5e7eb; font-size: 14px; outline: none; transition: border 0.2s; }
input:focus { border-color: #3b82f6; }
button { width: 100%; padding: 12px; background: #10b981; /* verde agradable para diferenciar */ color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 600; transition: 0.2s; }
button:hover { background: #059669; transform: translateY(-2px); }
p { font-size: 13px; text-align: center; margin-top: 12px; }
a { color: #60a5fa; text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } </style></head><body>
<form method="post" action="/auth/register"> <h2>Registro</h2>
<input name="name" placeholder="Nombre completo" required> <input name="email" placeholder="Email" required> <input name="password" type="password" placeholder="Password" required> <input name="entity_id" type="number" placeholder="Entidad ID" required>
<button type="submit">Registrarme</button>
<p>¿Ya tienes cuenta? <a href="/">Inicia sesión</a></p></form>
</body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899<!doctype html><html lang="es"><head> <meta charset="UTF-8"> <title>Diploma Verificado</title> <style> body { margin: 0; font-family: "Segoe UI", sans-serif; background: linear-gradient(120deg, #0f172a, #1e293b); color: #e2e8f0; display: flex; justify-content: center; align-items: flex-start; padding-top: 40px; min-height: 100vh; }
.card { background: #0f172a; border-radius: 14px; width: 90%; max-width: 600px; padding: 2rem 2.5rem; box-shadow: 0 0 35px rgba(0,0,0,0.45); animation: fadeIn 0.5s ease-out; }
h2 { text-align: center; font-size: 26px; margin-top: 0; margin-bottom: 18px; color: #34d399; }
.field { margin: 10px 0; font-size: 15px; }
.label { font-weight: 600; color: #93c5fd; }
.value { color: #f1f5f9; }
a.download { display: inline-block; margin-top: 25px; background: #3b82f6; padding: 12px 18px; color: #fff; text-decoration: none; border-radius: 8px; font-weight: 600; transition: 0.2s; text-align: center; }
a.download:hover { background: #2563eb; transform: translateY(-2px); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } </style></head><body>
<div class="card">
<h2>Diploma verificado ✔️</h2>
<p class="field"><span class="label">Nombre:</span> <span class="value">{{ student_name }}</span></p> <p class="field"><span class="label">Cédula:</span> <span class="value">{{ student_id }}</span></p> <p class="field"><span class="label">Centro:</span> <span class="value">{{ center_name }}</span></p> <p class="field"><span class="label">Título:</span> <span class="value">{{ course }}</span></p> <p class="field"><span class="label">Año:</span> <span class="value">{{ issued_at }}</span></p> <p class="field"><span class="label">Número de registro:</span> <span class="value">{{ registration_number }}</span></p> <p class="field"><span class="label">Director:</span> <span class="value">{{ director }}</span></p> <p class="field"><span class="label">Directora provincial:</span> <span class="value">{{ provincial_director }}</span></p> <p class="field"><span class="label">Profesor:</span> <span class="value">{{ professor }}</span></p> <p class="field"><span class="label">ID:</span> <span class="value">{{ diploma_id }}</span></p> <p class="field"><span class="label">SHA256:</span> <span class="value">{{ sha256 }}</span></p> <p class="field"><span class="label">Issuer:</span> <span class="value">{{ issuer }}</span></p>
<a class="download" href="{{ download_url }}">Descargar PDF (seguro)</a>
</div>
</body></html>123from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()12345678910111213141516from . import dbimport uuidfrom datetime import date
class Diploma(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
certification_title = db.Column(db.String(200)) director = db.Column(db.String(150)) professor = db.Column(db.String(150)) issue_date = db.Column(db.Date, default=date.today)
entity_id = db.Column(db.Integer, db.ForeignKey("entity.id"))
hash_code = db.Column(db.String(100), unique=True, default=lambda: uuid.uuid4().hex)1234567from . import db
class Entity(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(150), unique=True, nullable=False)
users = db.relationship("User", backref="entity", lazy=True)12345678910111213from . import dbfrom flask_login import UserMixin
class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(120), nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) password = db.Column(db.String(200), nullable=False)
role = db.Column(db.String(20), default="user") # admin / user status = db.Column(db.String(20), default="pending") # pending / active / rejected
entity_id = db.Column(db.Integer, db.ForeignKey('entity.id'))DockerfileAdded+24
__pycache__/app.cpython-313.pycAdded
__pycache__/config.cpython-313.pycAdded
__pycache__/run.cpython-313.pycAdded
__pycache__/seed.cpython-313.pycAdded
app.pyAdded+36
app/models/__init__.pyAdded+3
app/models/__pycache__/__init__.cpython-313.pycAdded
app/models/__pycache__/diploma.cpython-313.pycAdded
app/models/__pycache__/entity.cpython-313.pycAdded
app/models/__pycache__/user.cpython-313.pycAdded
app/models/diploma.pyAdded+16
app/models/entity.pyAdded+7
app/models/user.pyAdded+13
app/routes/__init__.pyAdded+10
app/routes/__pycache__/__init__.cpython-313.pycAdded
app/routes/__pycache__/admin.cpython-313.pycAdded
app/routes/__pycache__/auth.cpython-313.pycAdded
app/routes/__pycache__/diploma.cpython-313.pycAdded
app/routes/__pycache__/verify.cpython-313.pycAdded
app/routes/admin.pyAdded+42
app/routes/auth.pyAdded+92
app/routes/diploma.pyAdded+142
app/routes/verify.pyAdded+34
app/static/pdfs/3c915980cd4c4395aa4e271f41ce5186.pdfAdded
app/static/pdfs/6fdb1e38b81a44d5b470664f139cce02.pdfAdded
app/static/pdfs/c15ad4f351284657ba0ca61c80325efb.pdfAdded
app/static/pdfs/e764025a5d2b4dec96054e446f7bbf85.pdfAdded
app/static/pdfs/e8e5ee26b427415ea929f4f4c683f49d.pdfAdded
app/static/pdfs/eff3e05edc8e4e60bcab13ea8edbc09d.pdfAdded
app/static/qrs/3c915980cd4c4395aa4e271f41ce5186.pngAdded

app/static/qrs/6fdb1e38b81a44d5b470664f139cce02.pngAdded

app/static/qrs/c15ad4f351284657ba0ca61c80325efb.pngAdded

app/static/qrs/e764025a5d2b4dec96054e446f7bbf85.pngAdded

app/static/qrs/e8e5ee26b427415ea929f4f4c683f49d.pngAdded

app/static/qrs/eff3e05edc8e4e60bcab13ea8edbc09d.pngAdded

app/templates/admin_pending.htmlAdded+129
app/templates/issue.htmlAdded+188
app/templates/issue_success.htmlAdded+190
app/templates/login.htmlAdded+106
app/templates/register.htmlAdded+107
app/templates/verify.htmlAdded+99
app_pkg/models/__init__.pyAdded+3
app_pkg/models/__pycache__/__init__.cpython-313.pycAdded
app_pkg/models/__pycache__/diploma.cpython-313.pycAdded
app_pkg/models/__pycache__/entity.cpython-313.pycAdded
app_pkg/models/__pycache__/user.cpython-313.pycAdded
app_pkg/models/diploma.pyAdded+16
app_pkg/models/entity.pyAdded+7
app_pkg/models/user.pyAdded+13