How to use the spam.lib.decorators.asset_set_active function in spam

To help you get started, we’ve selected a few spam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_owner())
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_status, error_handler=get_submit)
    def post_submit(self, proj, asset_id, comment=None):
        """Submit an asset to supervisors for approval."""
        session = session_get()
        user = tmpl_context.user
        asset = asset_get(proj, asset_id)
        
        if not asset.submitted and not asset.approved:
            asset.submit(user)
            text = u'[%s v%03d]\n%s' % (_('submitted'), asset.current.ver,
                                                                comment or '')
            asset.current.notes.append(Note(user, text))
            session.refresh(asset.current.annotable)
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_owner())
    @expose('spam.templates.forms.form')
    def get_submit(self, proj, asset_id, **kwargs):
        """Display a SUBMIT form."""
        asset = asset_get(proj, asset_id)

        f_status.custom_method = 'SUBMIT'
        f_status.value = dict(proj=asset.project.id,
                              asset_id=asset.id,
                              project_name_=asset.project.name,
                              container_=asset.parent.owner.path,
                              category_id_=asset.category.id,
                              asset_name_=asset.name,
                             )
                     
        tmpl_context.form = f_status
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_supervisor())
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_status, error_handler=get_submit)
    def post_revoke(self, proj, asset_id, comment=None):
        """Revoke approval for an asset."""
        session = session_get()
        user = tmpl_context.user
        asset = asset_get(proj, asset_id)
        
        if asset.approved:
            asset.revoke(user)
            text = u'[%s v%03d]\n%s' % (_('revoked approval'),
                                            asset.current.ver, comment or '')
            asset.current.notes.append(Note(user, text))
            session.refresh(asset.current.annotable)
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_supervisor())
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_status, error_handler=get_submit)
    def post_approve(self, proj, asset_id, comment=None):
        """Approve an asset submitted for approval."""
        session = session_get()
        user = tmpl_context.user
        asset = asset_get(proj, asset_id)
        
        if asset.submitted and not asset.approved:
            asset.approve(user)
            text = u'[%s v%03d]\n%s' % (_('approved'), asset.current.ver,
                                                                comment or '')
            asset.current.notes.append(Note(user, text))
            session.refresh(asset.current.annotable)
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_supervisor())
    @expose('spam.templates.forms.form')
    def get_sendback(self, proj, asset_id, **kwargs):
        """Display a SENDBACK form."""
        asset = asset_get(proj, asset_id)

        f_status.custom_method = 'SENDBACK'
        f_status.value = dict(proj=asset.project.id,
                              asset_id=asset.id,
                              project_name_=asset.project.name,
                              container_=asset.parent.owner.path,
                              category_id_=asset.category.id,
                              asset_name_=asset.name,
                             )
                     
        tmpl_context.form = f_status
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_supervisor())
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_status, error_handler=get_submit)
    def post_sendback(self, proj, asset_id, comment=None):
        """Send back an asset for revision."""
        session = session_get()
        user = tmpl_context.user
        asset = asset_get(proj, asset_id)
        
        if asset.submitted and not asset.approved:
            asset.sendback(user)
            text = u'[%s v%03d]\n%s' % (_('sent back for revisions'),
                                            asset.current.ver, comment or '')
            asset.current.notes.append(Note(user, text))
            session.refresh(asset.current.annotable)
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_owner())
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_publish, error_handler=get_publish)
    def post_publish(self, proj, asset_id, uploaded, comment=None,
                                                                uploader=None):
        """Publish a new version of an asset.
        
        This will commit to the repo the file(s) already uploaded in a temporary
        storage area, and create a thumbnail and preview if required.
        """
        session = session_get()
        asset = asset_get(proj, asset_id)
        user = tmpl_context.user

        if not asset.checkedout or user != asset.owner:
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(Any(is_asset_supervisor(), is_asset_artist()))
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_confirm)
    def checkout(self, proj, asset_id):
        """Checkout an asset.
        
        The asset will be blocked and only the current owner will be able to
        publish new versions until it is released.
        """
        session = session_get()
        asset = asset_get(proj, asset_id)
        user = tmpl_context.user
        
        if not asset.checkedout:
            asset.checkout(user)
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(is_asset_supervisor())
    @expose('spam.templates.forms.form')
    def get_approve(self, proj, asset_id, **kwargs):
        """Display a APPROVE form."""
        asset = asset_get(proj, asset_id)

        f_status.custom_method = 'APPROVE'
        f_status.value = dict(proj=asset.project.id,
                              asset_id=asset.id,
                              project_name_=asset.project.name,
                              container_=asset.parent.owner.path,
                              category_id_=asset.category.id,
                              asset_name_=asset.name,
                             )
                     
        tmpl_context.form = f_status
github lento / spam / spam / controllers / asset / main.py View on Github external
    @asset_set_active
    @require(Any(is_asset_owner(), is_asset_supervisor()))
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_confirm)
    def release(self, proj, asset_id):
        """Release an asset.
        
        The asset will be unblocked and available for other users to checkout.
        """
        asset = asset_get(proj, asset_id)
        user = tmpl_context.user
        
        if asset.checkedout:
            asset.release()
            notify.send(asset)
            notify.ancestors(asset)