How to use the spam.lib.journaling.journal.add 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
def post_archive(self, proj):
        """Archive a project"""
        project = tmpl_context.project
        session = session_get()
        user = tmpl_context.user

        project.archived = True

        # invalidate cache
        project.touch()

        msg = '%s %s' % (_('Archived project:'), proj)

        # log into Journal
        journal.add(user, '%s %s' % (msg, project))

        # notify clients
        updates = [
            dict(item=project, type='deleted', topic=TOPIC_PROJECTS_ACTIVE),
            dict(item=project, type='added', topic=TOPIC_PROJECTS_ARCHIVED),
            ]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / shot / main.py View on Github external
if handle_in is not None and not shot.handle_in == handle_in:
            shot.handle_in = handle_in
            modified = True
        
        if handle_out is not None and not shot.handle_out == handle_out:
            shot.handle_out = handle_out
            modified = True
        
        if modified:
            new = shot.__dict__.copy()

            msg = '%s %s' % (_('Updated shot:'), shot.path)

            # log into Journal
            journal.add(user, '%s - %s' % (msg, diff_dicts(old, new)))
            
            # notify clients
            updates = [dict(item=shot, type='updated', topic=TOPIC_SHOTS)]
            notify.send(updates)

            return dict(msg=msg, status='ok', updates=updates)

        return dict(msg='%s %s' % (_('Shot is unchanged:'), shot.path),
                                                    status='info', updates=[])
github lento / spam / spam / controllers / scene / main.py View on Github external
status='error', updates=[])

        session.delete(scene)

        # delete association objects or they will be orphaned
        session.flush()
        session.delete(scene.taggable)
        session.delete(scene.annotable)

        # invalidate project cache
        project.touch()

        msg = '%s %s' % (_('Deleted scene:'), scene.path)

        # log into Journal
        journal.add(user, '%s - %s' % (msg, scene))
        
        # notify clients
        updates = [
            dict(item=scene, type='deleted', topic=TOPIC_SCENES),
            dict(item=project, type='updated', topic=TOPIC_PROJECT_STRUCTURE),
            ]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / category.py View on Github external
def post_delete(self, category_id):
        """Delete a category.

        Only delete the category record from the common db, all the assets
        in this category will be orphaned, and must be removed manually.
        """
        session = session_get()
        user = tmpl_context.user
        category = category_get(category_id)
        session.delete(category)

        msg = '%s %s' % (_('Deleted category:'), category.id)

        # log into Journal
        journal.add(user, '%s - %s' % (msg, category))

        # notify clients
        updates = [dict(item=category, type='deleted', topic=TOPIC_CATEGORIES)]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / project / main.py View on Github external
def post_activate(self, proj):
        """Activate a project"""
        query = query_projects_archived().filter_by(id=proj.decode('utf-8'))
        project = query.one()
        session = session_get()
        user = tmpl_context.user

        project.archived = False

        # invalidate cache
        project.touch()

        msg = '%s %s' % (_('Activated project:'), proj)

        # log into Journal
        journal.add(user, '%s %s' % (msg, project))

        # notify clients
        updates = [
            dict(item=project, type='added', topic=TOPIC_PROJECTS_ACTIVE),
            dict(item=project, type='deleted', topic=TOPIC_PROJECTS_ARCHIVED),
            ]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / asset / main.py View on Github external
def post_recall(self, proj, asset_id, comment=None):
        """Recall 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.recall(user)
            text = u'[%s v%03d]\n%s' % (_('recalled'), asset.current.ver,
                                                                comment or '')
            asset.current.notes.append(Note(user, text))
            session.refresh(asset.current.annotable)

            # log into Journal
            journal.add(user, 'recall submission for %s' % asset)
        
            # send a stomp message to notify clients
            notify.send(asset)
            notify.ancestors(asset)
            return dict(msg='recalled submission for asset "%s"' % asset.path,
                                                            result='success')
        return dict(msg='submission for asset "%s" cannot be recalled' %
                                                    asset.path, result='failed')
github lento / spam / spam / controllers / libgroup / main.py View on Github external
session.delete(libgroup)

        # delete association objects or they will be orphaned
        session.flush()
        session.delete(libgroup.container)
        session.delete(libgroup.taggable)
        session.delete(libgroup.annotable)

        # invalidate project cache
        project.touch()

        msg = '%s %s' % (_('Deleted libgroup:'), libgroup.path)

        # log into Journal
        journal.add(user, '%s - %s' % (msg, libgroup))
        
        # notify clients
        updates = [
            dict(item=libgroup, type='deleted', topic=TOPIC_LIBGROUPS),
            dict(item=project, type='updated', topic=TOPIC_PROJECT_STRUCTURE),
            ]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / asset / main.py View on Github external
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)

            # log into Journal
            journal.add(user, 'approved %s' % asset)
        
            # send a stomp message to notify clients
            notify.send(asset)
            notify.ancestors(asset)
            return dict(msg='approved asset "%s"' % asset.path,
                                                            result='success')
        return dict(msg='asset "%s" cannot be approved' % asset.path,
                                                            result='failed')
github lento / spam / spam / controllers / user / main.py View on Github external
group.users.append(adduser)
                added.append(adduser.user_id)
                
                # prepare updates to notify clients
                updates.append(dict(item=adduser, type='added',
                            topic=TOPIC_GROUPS, filter=group.group_name))
        
        added = ', '.join(added)

        if added:
            # log into Journal
            msg = '%s %s %s' % (added,
                                n_('added to group:',
                                   'added to group:', len(added)),
                                group.group_id)
            journal.add(user, msg)
            notify.send(updates)

            return dict(msg=msg, status='ok', updates=updates)

        return dict(msg='%s %s' % (_('Selected users are already in group:'),
                                    group.group_id), status='info', updates=[])