basxsoftwareassociation / bread

Engine to create database applications based on Django and the IBM Carbon Design System
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

first (very basic) implementation of document templates #126

Closed wipascal closed 2 years ago

wipascal commented 2 years ago

This is mainly to find out if I am going in the right direction.

Todo's for future PRs:

Maybe (?):

@saemideluxe What do you think?

wipascal commented 2 years ago

Okay, looks good to me. One thing more that just jumped to my mind: We should add a method on DocumentTemplate which accepts a Model instance and returns the correct URL. I suggest we use bread.utils.links.ModelHref to allow for a lazy object (but not for the template object itself, that should in most cases be concrete I think).

Hmm I don't understand what you mean. Could you sketch how you would want to use such a method?

saemideluxe commented 2 years ago

Hmm I don't understand what you mean. Could you sketch how you would want to use such a method?

Something like (names are just very long to make intent clear):

# assuming e.g. inside bread.views.ReadView or similar
employment_contract_template = DocumentTemplate.objects.get(name="Employment Contract")

return hg.DIV(
    hg.A("Download Employment Contract", href=employment_contract_template.url_for_filled_out_with(hg.C("object")))
)

Does that make sense? I expect that is how we use if most often.

saemideluxe commented 2 years ago

Ah, I think the new black version (now out of beta for the first time btw) has some changes.