How to use the spam.lib.decorators.project_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 / project / main.py View on Github external
    @project_set_active
    @require(in_group('administrators'))
    @expose('spam.templates.forms.form')
    def edit(self, proj, **kwargs):
        """Display a EDIT form."""
        project = tmpl_context.project
        f_edit.value = dict(proj=project.id,
                            id_=project.id,
                            project_name=project.name,
                            description=project.description)
        tmpl_context.form = f_edit
        return dict(title='%s %s' % (_('Edit project:'), proj))
github lento / spam / spam / controllers / scene / main.py View on Github external
    @project_set_active
    @require(is_project_admin())
    @expose('spam.templates.forms.form')
    def edit(self, proj, sc, **kwargs):
        """Display a EDIT form."""
        scene = scene_get(proj, sc)

        f_edit.value = dict(proj=scene.project.id,
                            sc=scene.name,
                            project_name_=scene.project.name,
                            scene_name_=scene.name,
                            description=scene.description,
                           )
        tmpl_context.form = f_edit
        return dict(title='%s %s' % (_('Edit scene:'), scene.path))
github lento / spam / spam / controllers / project / main.py View on Github external
    @project_set_active
    @require(in_group('administrators'))
    @expose('spam.templates.forms.form')
    def get_delete(self, proj, **kwargs):
        """Display a DELETE confirmation form."""
        project = tmpl_context.project
        f_confirm.custom_method = 'DELETE'
        f_confirm.value = dict(proj=project.id,
                               id_=project.id,
                               project_name_=project.name,
                               description_=project.description,
                              )
        warning = _('This will only delete the project entry in the database. '
                    'The data and history of the project must be deleted '
                    'manually if needed.')
        tmpl_context.form = f_confirm
        return dict(title='%s %s?' % (_('Are you sure you want to delete:'),
github lento / spam / spam / controllers / project / main.py View on Github external
    @project_set_active
    @require(is_project_user())
    @with_trailing_slash
    @expose('json')
    @expose('spam.templates.tabbed_content')
    def get_one(self, proj):
        """Return a `tabbed` page for project tabs."""
        project = tmpl_context.project
        tabs = [('Summary', 'tab/summary'),
                ('Scenes', url('/scene/%s' % project.id)),
                ('Library', url('/libgroup/%s' % project.id)),
               ]
        if is_project_admin():
            tabs.append(('Users', 'tab/users'))
        
        return dict(page='project/%s' % project.id, project=project, tabs=tabs,
                                            sidebar=('projects', project.id))
github lento / spam / spam / controllers / asset / main.py View on Github external
    @project_set_active
    @asset_set_active
    @require(is_asset_owner())
    @expose('spam.templates.forms.form')
    def get_publish(self, proj, asset_id, **kwargs):
        """Display a PUBLISH form."""
        asset = asset_get(proj, asset_id)

        f_publish.custom_method = 'PUBLISH'
        f_publish.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,
                              )
github lento / spam / spam / controllers / project / main.py View on Github external
    @project_set_active
    @require(in_group('administrators'))
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_edit, error_handler=edit)
    def put(self, proj, project_name=None, description=None):
        """Edit a project"""
        project = tmpl_context.project
        old = project.__dict__.copy()
        session = session_get()
        user = tmpl_context.user

        modified = False
        if project_name is not None and not project.name == project_name:
            project.name = project_name
            modified = True
github lento / spam / spam / controllers / asset / main.py View on Github external
    @project_set_active
    @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))
github lento / spam / spam / controllers / user / main.py View on Github external
    @project_set_active
    @require(is_project_admin())
    @expose('json')
#    @expose('spam.templates.forms.result')
    def remove_admin(self, proj, user_id):
        """Remove an administrator from a project"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        remuser = user_get(user_id)
        updates = []
        
        if remuser in project.admins:
            project.admins.remove(remuser)
            
            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
github lento / spam / spam / controllers / user / main.py View on Github external
    @project_set_active
    @require(is_project_admin())
    @expose('json')
#    @expose('spam.templates.forms.result')
    def remove_artist(self, proj, category_id, user_id):
        """Remove an artist from a category"""
        session = session_get()
        user = tmpl_context.user
        project = project_get(proj)
        category = category_get(category_id)
        remuser = user_get(user_id)
        updates = []

        if remuser in project.artists[category]:
            query = session.query(Artist).filter_by(proj_id=project.id)
            query = query.filter_by(category_id=category.id)
            query = query.filter_by(user_id=remuser.user_id)
github lento / spam / spam / controllers / project / main.py View on Github external
    @project_set_active
    @require(in_group('administrators'))
    @expose('json')
    @expose('spam.templates.forms.result')
    @validate(f_confirm, error_handler=get_delete)
    def post_delete(self, proj):
        """Delete a project.

        Only delete the project record from the common db, the project
        repository must be removed manually.
        (This should help prevent awful accidents) ;)
        """
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project

        if project.scenes or project.libgroups: