68 lines
1.4 KiB
Rust
68 lines
1.4 KiB
Rust
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||
|
//
|
||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||
|
use std::cell::RefCell;
|
||
|
|
||
|
use derive_builder::*;
|
||
|
use derive_more::*;
|
||
|
use serde::*;
|
||
|
use tera::Context;
|
||
|
use url::Url;
|
||
|
|
||
|
pub use super::*;
|
||
|
use crate::utils::*;
|
||
|
|
||
|
pub const ONWER_UPDATE_EMAIL_PAGE: TemplateFile = TemplateFile::new(
|
||
|
"identity.owner_update_email",
|
||
|
"identity/owner_update_email.html",
|
||
|
);
|
||
|
|
||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||
|
ONWER_UPDATE_EMAIL_PAGE
|
||
|
.register(t)
|
||
|
.expect(ONWER_UPDATE_EMAIL_PAGE.name);
|
||
|
}
|
||
|
|
||
|
pub struct OwnerUpdateEmailPage {
|
||
|
ctx: RefCell<Context>,
|
||
|
}
|
||
|
|
||
|
impl OwnerUpdateEmailPage {
|
||
|
pub fn new() -> Self {
|
||
|
let mut ctx = context();
|
||
|
|
||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||
|
|
||
|
let ctx = RefCell::new(ctx);
|
||
|
Self { ctx }
|
||
|
}
|
||
|
|
||
|
pub fn render(&self) -> String {
|
||
|
TEMPLATES
|
||
|
.render(ONWER_UPDATE_EMAIL_PAGE.name, &self.ctx.borrow())
|
||
|
.unwrap()
|
||
|
}
|
||
|
|
||
|
pub fn page() -> String {
|
||
|
let p = Self::new();
|
||
|
p.render()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[cfg(test)]
|
||
|
mod tests {
|
||
|
use super::*;
|
||
|
|
||
|
#[test]
|
||
|
fn render_page_and_write() {
|
||
|
const FILE: &str = "./tmp/identity-owner_update_email.html";
|
||
|
|
||
|
let tw = TestWriterBuilder::default()
|
||
|
.file(FILE.into())
|
||
|
.contents(OwnerUpdateEmailPage::page())
|
||
|
.build()
|
||
|
.unwrap();
|
||
|
tw.write();
|
||
|
}
|
||
|
}
|