layout updates, added json views, fixed relationships in schema

This commit is contained in:
evilchili
2024-02-16 01:19:25 -08:00
parent 1baf73a338
commit e231828425
13 changed files with 320 additions and 88 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
from .base import BaseController
from .character_sheet import CharacterSheet
from .json_data import JsonData
__all__ = [BaseController, CharacterSheet]
__all__ = [BaseController, CharacterSheet, JsonData]
+4 -1
View File
@@ -63,6 +63,8 @@ class BaseController:
def form(self):
if not self.model:
return
if not self.model_form:
return
if not self._form:
if self.request.POST:
self._form = self.model_form(self.request.POST, obj=self.record)
@@ -106,8 +108,9 @@ class BaseController:
db.add(self.record)
logging.debug(f"Added {self.record = }")
location = self.request.current_route_path()
if self.slug not in location:
if self.record.slug not in location:
location = f"{location}/{self.record.uri}"
logging.debug(f"Redirecting to {location}")
return HTTPFound(location=location)
def delete(self):
@@ -17,7 +17,7 @@ class CharacterForm(ModelForm):
save = SubmitField()
delete = SubmitField()
ancestry = DeferredSelectField('Ancestry', model=Ancestry, validate_choice=True, widget=Select())
ancestry = DeferredSelectField('Ancestry', model=Ancestry, default='human', validate_choice=True, widget=Select())
character_class = DeferredSelectMultipleField(
'CharacterClass',