prompt_creator_account. Route handler or application helper. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 16995 | now = now_z() |
| 16996 | cur = conn.cursor() |
| 16997 | cur.execute( |
| 16998 | "INSERT INTO profiler_entries(owner, first_enc, last_enc, info_enc, optional_enc, created_at, updated_at) VALUES(?,?,?,?,?,?,?)", |
| 16999 | (owner, aesgcm_encrypt_text(first), aesgcm_encrypt_text(last), aesgcm_encrypt_text(info), profiler_encrypt_optional(opt), now, now) |
| 17000 | ) |
| 17001 | entry_id = cur.lastrowid |
| 17002 | |
| 17003 | # Attachments |
| 17004 | for a in (p.get("attachments") or []): |
| 17005 | rel = a.get("path") or "" |
| 17006 | src = os.path.join(tmp_dir, "attachments", rel) |
| 17007 | if not os.path.isfile(src): |
| 17008 | continue |
| 17009 | fn = (a.get("filename") or os.path.basename(src) or "file").strip() |
| 17010 | mime = (a.get("mime") or guess_mime(fn)).strip() |
| 17011 | |
| 17012 | dst = os.path.join(PROF_ATT_DIR, owner, f"{entry_id}_{secrets.token_hex(8)}") |
| 17013 | os.makedirs(os.path.dirname(dst), exist_ok=True) |
| 17014 | |
| 17015 | # Encrypt at rest |
| 17016 | with open(src, "rb") as f: |
| 17017 | aesgcm_encrypt_stream(f, dst) |
| 17018 | |
| 17019 | cur.execute( |
| 17020 | "INSERT INTO profiler_attachments(entry_id, filename_enc, mime_enc, stored_path, created_at) VALUES(?,?,?,?,?)", |
| 17021 | (entry_id, aesgcm_encrypt_text(fn), aesgcm_encrypt_text(mime), dst, now) |
| 17022 | ) |
| 17023 | |
| 17024 | conn.commit() |
| 17025 | existing_fp.add(fp) |
| 17026 | imported += 1 |
| 17027 | |
| 17028 | conn.close() |
| 17029 | shutil.rmtree(tmp_dir, ignore_errors=True) |
| 17030 | flash(f"Combined {imported} new profile(s) from {os.path.basename(latest)}") |
| 17031 | except Exception as e: |
| 17032 | log.exception("Profiler combine failed: %s", e) |
| 17033 | flash("Combine failed.") |
| 17034 | return redirect(url_for("profiler")) |
| 17035 | |
| 17036 | |
| 17037 | @app.route("/profiler/create", methods=["POST"]) |
| 17038 | @login_required |
| 17039 | def profiler_create(): |
| 17040 | """profiler_create. |
| 17041 | |
| 17042 | Route handler or application helper. |
| 17043 |
no test coverage detected