summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/opendc/models/portfolio.py
blob: 8e3f2a52ebf08def3737f7fa25a4ddfd98ff920f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from opendc.models.project import Project
from opendc.models.model import Model


class Portfolio(Model):
    """Model representing a Portfolio."""

    collection_name = 'portfolios'

    def check_user_access(self, user_id, edit_access):
        """Raises an error if the user with given [user_id] has insufficient access.

        Checks access on the parent project.

        :param user_id: The User ID of the user.
        :param edit_access: True when edit access should be checked, otherwise view access.
        """
        project = Project.from_id(self.obj['projectId'])
        project.check_user_access(user_id, edit_access)