diff --git a/src/routes/characters/edit.rs b/src/routes/characters/edit.rs index 5b84b05..f82c1f6 100644 --- a/src/routes/characters/edit.rs +++ b/src/routes/characters/edit.rs @@ -20,6 +20,28 @@ struct FormStateContext<'a> { pub selected_system: &'a CharacterDataType, } +fn edit_character_template(user: &User, character: Character) -> Result { + let character = character.uprade()?; + + let context = EditCharacterContext { + name: &character.character_name, + username: &user.username, + data_type: &character.data_type, + sheet: character.dyn_deserialize()?, + state: FormStateContext { + selected_system: &character.data_type, + }, + }; + + use CharacterDataType::*; + let template = match character.data_type { + ChroniclesOfDarknessV1 => Template::render("characters/edit_character", context), + ChangelingV1 => Template::render("characters/edit_changeling_character", context), + }; + + Ok(template) +} + #[get("///edit")] pub(super) async fn edit_character_page( character_id: i32, @@ -39,15 +61,6 @@ pub(super) async fn edit_character_page( return Err(Error::NoPermission); } - let context = EditCharacterContext { - name: &character.character_name, - username: &owner.username, - data_type: &character.data_type, - sheet: character.dyn_deserialize()?, - state: FormStateContext { - selected_system: &character.data_type, - }, - }; - - Ok(Template::render("characters/edit_character", context)) + let template = edit_character_template(logged_in_user, character)?; + Ok(template) } diff --git a/templates/characters/edit_changeling_character.html.tera b/templates/characters/edit_changeling_character.html.tera new file mode 100644 index 0000000..7deb032 --- /dev/null +++ b/templates/characters/edit_changeling_character.html.tera @@ -0,0 +1,134 @@ +{% import "characters/edit_character_macros" as macros %} +{% extends "base" %} + +{% block content %} + + + + + +

Core Sheet

+
+

Name:

+

System: {{data_type}}

+
+
+ {{ macros::attribute(name="Intelligence", value=sheet.base.intelligence) }} + {{ macros::attribute(name="Wits", value=sheet.base.wits) }} + {{ macros::attribute(name="Resolve", value=sheet.base.resolve) }} +
+ +
+ {{ macros::attribute(name="Strength", value=sheet.base.strength) }} + {{ macros::attribute(name="Dexterity", value=sheet.base.dexterity) }} + {{ macros::attribute(name="Stamina", value=sheet.base.stamina) }} +
+ +
+ {{ macros::attribute(name="Presence", value=sheet.base.presence) }} + {{ macros::attribute(name="Manipulation", value=sheet.base.manipulation) }} + {{ macros::attribute(name="Composure", value=sheet.base.composure) }} +
+
+ +
+
+ {% for skill_name, skill in sheet.base.mentalSkills %} + {{ macros::skill(name=skill_name, value=skill.dots) }} + {% endfor %} +
+ +
+ {% for skill_name, skill in sheet.base.physicalSkills %} + {{ macros::skill(name=skill_name, value=skill.dots) }} + {% endfor %} +
+ +
+ {% for skill_name, skill in sheet.base.socialSkills %} + {{ macros::skill(name=skill_name, value=skill.dots) }} + {% endfor %} +
+
+
+{% endblock content %}