How to use the spam.lib.journaling.journal 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
# add project to db
        project = Project(proj, name=project_name, description=description)
        session.add(project)

        # create directories and init hg repo
        repo.project_create_dirs(project.id)
        repo.repo_init(project.id)

        # grant project rights to user "admin"
        admin = session.query(User).filter_by(user_name=u'admin').one()
        project.admins.append(admin)

        msg = '%s %s' % (_('Created project:'), project.id)

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

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

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / category.py View on Github external
def post(self, category_id, ordering=None, naming_convention=None):
        """Create a new category"""
        session = session_get()
        user = tmpl_context.user

        # add category to shared db
        category = Category(category_id, ordering=ordering,
                                            naming_convention=naming_convention)
        session.add(category)

        msg = '%s %s' % (_('Created category:'), category_id)

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

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

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / tag.py View on Github external
updates.append(dict(item=tag, type='deleted', topic=TOPIC_TAGS,
                                                            filter=taggable_id))

        if removed_tags:
            removed = ', '.join([t.id for t in removed_tags])
            msg = '%s %s %s' % (removed,
                                n_('tag removed from:',
                                   'tags removed from:', len(removed_tags)),
                                taggable_id)
            status = 'ok'

            # notify clients
            notify.send(updates)

            # log into Journal
            journal.add(user, '%s - %s' % (msg, taggable.tagged))
        else:
            msg = _('No tag removed')
            status = 'info'

        return dict(msg=msg, status=status, updates=updates)
github lento / spam / spam / controllers / scene / main.py View on Github external
# add scene to db
        scene = Scene(project.id, sc, description)
        session.add(scene)
        session.flush()
        
        # create directories
        repo.scene_create_dirs(project.id, scene)
        
        # invalidate project cache
        project.touch()

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

        # log into Journal
        journal.add(user, '%s - %s' % (msg, scene))
        
        # notify clients
        updates = [
            dict(item=scene, type='added', 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 / tag.py View on Github external
updates.append(dict(item=tag, type='added', topic=TOPIC_TAGS,
                                                            filter=taggable_id))

        if added_tags:
            added = ', '.join([t.id for t in added_tags])
            msg = '%s %s %s' % (added,
                                n_('tag added to:',
                                   'tags added to:', len(added_tags)),
                                taggable_id)
            status = 'ok'

            # notify clients
            notify.send(updates)

            # log into Journal
            journal.add(user, '%s - %s' % (msg, taggable.tagged))
        else:
            msg = _('No new tag applied')
            status = 'info'

        return dict(msg=msg, status=status, updates=updates)
github lento / spam / spam / controllers / asset / main.py View on Github external
project = tmpl_context.project
        user = tmpl_context.user
        container = container_get(project.id, container_type, container_id)
        category = category_get(category_id)
        
        # add asset to db
        asset = Asset(container, category, name, user)
        session.add(asset)
        session.flush()
        text = '[%s v000]\n%s' % (_('created'), comment or '')
        asset.current.notes.append(Note(user, text))
        
        # log into Journal
        new = asset.__dict__.copy()
        new.pop('_sa_instance_state', None)
        journal.add(user, 'created %s' % asset)

        # send a stomp message to notify clients
        notify.send(asset, update_type='added')
        return dict(msg='created asset "%s"' % asset.name, result='success',
                                                                    asset=asset)
github lento / spam / spam / controllers / shot / main.py View on Github external
# add shot to db
        shot = Shot(scene, sh, description=description, action=action,
                    frames=frames, handle_in=handle_in, handle_out=handle_out)
        session.add(shot)
        session.flush()
        
        # create directories
        repo.shot_create_dirs(scene.project.id, shot)
        
        # invalidate project cache
        project.touch()

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

        # log into Journal
        journal.add(user, '%s - %s' % (msg, shot))
        
        # notify clients
        updates = [
            dict(item=shot, type='added', topic=TOPIC_SHOTS),
            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 / user / main.py View on Github external
def post(self, user_name, display_name, password):
        """Create a new user"""
        session = session_get()
        user = tmpl_context.user

        # add user to shared db
        newuser = User(user_name, display_name=display_name)
        newuser.password = password
        session.add(newuser)
        session.flush()

        msg = '%s %s' % (_('Created User:'), newuser.id)

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

        # notify clients
        updates = [dict(item=newuser, type='added', topic=TOPIC_USERS)]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / category.py View on Github external
if ordering is not None and not ordering == category.ordering:
            category.ordering = ordering
            modified = True

        if (naming_convention is not None and
                        not naming_convention == category.naming_convention):
            category.naming_convention = naming_convention
            modified = True

        if modified:
            new = category.__dict__.copy()

            msg = '%s %s' % (_('Updated category:'), category_id)

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

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

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

        return dict(msg='%s %s' % (_('Category is unchanged:'), category_id),
                                                    status='info', updates=[])
github lento / spam / spam / controllers / libgroup / main.py View on Github external
# add libgroup to db
        libgroup = Libgroup(project.id, name, parent, description)
        session.add(libgroup)
        session.flush()
        
        # create directories
        repo.libgroup_create_dirs(project.id, libgroup)
        
        # invalidate project cache
        project.touch()

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

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

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