How to use the spam.lib.notifications.notify 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 / tag.py View on Github external
added_tags.append(tag)

                # prepare updates to notify clients
                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 / shot / main.py View on Github external
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 / libgroup / main.py View on Github external
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)
github lento / spam / spam / controllers / category.py View on Github external
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 / project / main.py View on Github external
def post_upgrade(self, proj):
        """Upgrade the DB schema for a project"""
        project = tmpl_context.project
        project.schema_upgrade()
        project.touch()

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

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

        # notify clients
        updates = [
            dict(item=project, type='updated', 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
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 / libgroup / main.py View on Github external
libgroup.description = description
            modified = True
        
        if modified:
            new = libgroup.__dict__.copy()

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

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

            return dict(msg=msg, status='ok', updates=updates)
        return dict(msg='%s %s' % (_('Libgroup is unchanged:'), libgroup.path),
                                                    status='info', updates=[])
github lento / spam / spam / controllers / user / main.py View on Github external
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 / tag.py View on Github external
def post_delete(self, tag_id):
        """Delete a tag."""
        session = session_get()
        user = tmpl_context.user
        tag = tag_get(tag_id)

        session.delete(tag)

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

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

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / lib / journaling.py View on Github external
def add(self, user, text):
        entry = Journal(user, text)
        session_get().add(entry)
        notify.send(entry, update_type='added')