ets-labs / python-domain-models

Domain models framework for Python projects
BSD 3-Clause "New" or "Revised" License
22 stars 4 forks source link

DomainModel View Contexts #25

Closed rmk135 closed 7 years ago

rmk135 commented 8 years ago

The idea is to wide domain model views functionality for specifying views for related models.

class Photo(models.DomainModel):

    id = fields.Int()
    url = fields.String()
    content_type = fields.String()

    public_view = views.View(include=[url])

class Profile(models.DomainModel):

    id = fields.Int()
    name = fields.String()
    main_photo = fields.Model(Photo)

    public_view = views.View(include=[name, main_photo],
                             contexts=[views.Context(field=main_photo, 
                                                     view=Photo.public_view)])

Notes:

boonya commented 8 years ago

How to define contextual view: https://github.com/ets-labs/domain_models/pull/33/files#diff-469a50d37f12edde45a4bd1a8aaa762cR36 How to use contextual view: https://github.com/ets-labs/domain_models/pull/33/files#diff-469a50d37f12edde45a4bd1a8aaa762cR172

boonya commented 7 years ago

Done https://github.com/ets-labs/python-domain-models/pull/33