Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template object #90

Closed
hatched opened this issue Mar 28, 2019 · 1 comment
Closed

Add template object #90

hatched opened this issue Mar 28, 2019 · 1 comment

Comments

@hatched
Copy link
Contributor

hatched commented Mar 28, 2019

It's not clear what variables are available to the template when requesting data over the wire. It would be best if we created a static data structure and populated it with the values from the charmstore requests so that any future developer can see what data is available.

https://github.com/canonical-websites/jaas.ai/pull/79/files#r269294127

@huwshimi
Copy link
Collaborator

huwshimi commented Apr 2, 2019

When we get the charms and bundles we parse the data into something more friendly and at that point we try and make things more generic and standardised between the charms and bundles e.g. https://github.com/canonical-websites/jaas.ai/blob/master/webapp/store/models.py#L178

For the variables passed to the templates this is the proper place to do this manipulation and then it becomes the same across the app (in the code introduced in the linked PR above there were a number of bugs introduced by even that small amount of code).

I'll put up a PR moving these into the model code.

For variables that don't make sense to go in the models there is also the possibility of assigning to variables inside the templates e.g. {% set entity_data = context.entity.charm_data %}. This way the standard models can be passed to the those templates wherever they are used and there is no need to do variable name changes in multiple views that might use that template (esp for included blocks).

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants