Beispiel #1
0
    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:
            return dict(
                msg="%s %s" % (_("Cannot delete project because it contains scenes or " "libgroups:"), project.id),
                status="error",
                updates=[],
            )

        session.delete(project)

        msg = "%s %s" % (_("Deleted project:"), proj)

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

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

        return dict(msg=msg, status="ok", updates=updates)
Beispiel #2
0
    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

        if description is not None and not project.description == description:
            project.description = description
            modified = True

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

            # invalidate cache
            project.touch()

            msg = "%s %s" % (_("Updated project:"), proj)

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

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

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

        return dict(msg="%s %s" % (_("Project is unchanged:"), proj), status="info", updates=[])
Beispiel #3
0
    def post(self, proj, project_name=None, description=None):
        """Create a new project"""
        session = session_get()
        user = tmpl_context.user

        # 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)
Beispiel #4
0
    def put(self, category_id, ordering=None, naming_convention=None):
        """Edit a category"""
        session = session_get()
        user = tmpl_context.user
        category = category_get(category_id)
        old = category.__dict__.copy()

        modified = False
        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=[])
Beispiel #5
0
    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)
Beispiel #6
0
    def remove_supervisor(self, proj, category_id, user_id):
        """Remove a supervisor from a category"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        category = category_get(category_id)
        remuser = user_get(user_id)
        updates = []

        if remuser in project.supervisors[category]:
            query = session.query(Supervisor).filter_by(proj_id=project.id)
            query = query.filter_by(category_id=category.id)
            query = query.filter_by(user_id=remuser.user_id)
            sup = query.one()
            session.delete(sup)

            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_PROJECT_SUPERVISORS,
                        filter='%s-%s' % (project.id, category.id)))

            # log into Journal
            msg = '%s %s %s/%s' % (remuser.user_id,
                                   _('revoked as supervisor from:'),
                                   project.id, category.id)
            journal.add(user, msg)
            notify.send(updates)

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

        return dict(msg='%s %s %s' % (
                remuser.user_id, _('is not a supervisor for:'), project.id),
                status='error', updates=[])
Beispiel #7
0
    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)

            msg = '%s %s' % (_('Revoked approval for Asset:'), asset.path)
            updates = [dict(item=asset, type='updated', topic=TOPIC_ASSETS)]
            status = 'ok'

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

            # notify clients
            notify.send(updates)
        else:
            msg = '%s %s' % (_('Asset is not approved:'), asset.path)
            updates = []
            status = 'error'

        return dict(msg=msg, status=status, updates=updates)
Beispiel #8
0
    def post(self, proj, parent_id, name, description=None):
        """Create a new libgroup"""
        session = session_get()
        project = tmpl_context.project
        user = tmpl_context.user
        parent = parent_id and libgroup_get(proj, parent_id) or None
        
        # 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)
Beispiel #9
0
    def post(self, proj, sc, description=None):
        """Create a new scene"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        
        # 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)
Beispiel #10
0
    def put(self, proj, sc, description=None):
        """Edit a scene"""
        session = session_get()
        user = tmpl_context.user
        scene = scene_get(proj, sc)
        old = scene.__dict__.copy()

        modified = False
        if description is not None and not scene.description == description:
            scene.description = description
            modified = True
        
        if modified:
            new = scene.__dict__.copy()

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

            # log into Journal
            journal.add(user, '%s - %s' % (msg, diff_dicts(old, new)))
            
            # notify clients
            updates = [dict(item=scene, type='updated', topic=TOPIC_SCENES)]
            notify.send(updates)
            return dict(msg=msg, status='ok', updates=updates)
        return dict(msg='%s %s' % (_('Scene is unchanged:'), scene.path),
                                                    status='info', updates=[])
Beispiel #11
0
    def put(self, user_id, display_name=None):
        """Edit a user"""
        session = session_get()
        user = tmpl_context.user
        edituser = user_get(user_id)
        old = edituser.__dict__.copy()
        
        modified = False
        if display_name and not edituser.display_name == display_name:
            edituser.display_name = display_name
            modified = True
        
        if modified:
            new = edituser.__dict__.copy()

            msg = '%s %s' % (_('Updated user:'******'%s - %s' % (msg, diff_dicts(old, new)))

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

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

        return dict(msg='%s %s' % (_('User is unchanged:'), edituser.user_id),
                                                    status='info', updates=[])
Beispiel #12
0
    def post_delete(self, proj, asset_id):
        """Delete an asset.
        
        Only delete the asset record from the db, the asset file(s) must be
        removed manually.
        (This should help prevent awful accidents) ;)
        """
        session = session_get()
        user = tmpl_context.user
        asset = asset_get(proj, asset_id)

        session.delete(asset)

        # delete association objects or they will be orphaned
        session.flush()
        for ver in asset.versions:
            session.delete(ver.annotable)
        session.delete(asset.taggable)

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

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

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

        return dict(msg=msg, status='ok', updates=updates)
Beispiel #13
0
    def post(self, proj, container_type, container_id, category_id, name,
                                                                comment=None):
        """Create a new asset"""
        session = session_get()
        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))

        msg = '%s %s' % (_('Created Asset:'), asset.name)

        # log into Journal
        new = asset.__dict__.copy()
        new.pop('_sa_instance_state', None)
        journal.add(user, '%s - %s' % (msg, asset))

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

        return dict(msg=msg, status='ok', updates=updates)
Beispiel #14
0
    def post(self, proj, sc, sh, description=None, action=None, frames=None,
                                            handle_in=None, handle_out=None):
        """Create a new shot"""
        project = tmpl_context.project
        session = session_get()
        user = tmpl_context.user
        scene = scene_get(proj, sc)
        
        # 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)
Beispiel #15
0
    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',
                        topic=TOPIC_PROJECT_ADMINS, filter=project.id))

            # log into Journal
            msg = '%s %s %s' % (remuser.user_id,
                                _('revoked as administrator for:'),
                                project.id)
            journal.add(user, msg)
            notify.send(updates)

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

        return dict(msg='%s %s %s' % (
                remuser.user_id, _('is not an administrator for:'), project.id),
                status='error', updates=[])
Beispiel #16
0
    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)

            msg = '%s %s' % (_('Checkedout Asset:'), asset.path)
            updates = [dict(item=asset, type='updated', topic=TOPIC_ASSETS)]
            status = 'ok'

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

            # notify clients
            notify.send(updates)
        else:
            msg = '%s %s' % (_('Asset is already checkedout:'), asset.path)
            updates = []
            status = 'error'

        return dict(msg=msg, status=status, updates=updates)
Beispiel #17
0
    def remove_from_group(self, user_id, group_id):
        """Remove a user from a group"""
        session = session_get()
        user = tmpl_context.user
        remuser = user_get(user_id)
        group = group_get(group_id)
        updates = []
        
        if remuser in group.users:
            group.users.remove(remuser)
            
            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_GROUPS, filter=group.group_name))

            # log into Journal
            msg = '%s %s %s' % (remuser.user_id,
                                _('removed from group'),
                                group.group_id)
            journal.add(user, msg)
            notify.send(updates)

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

        return dict(msg='%s %s %s' % (remuser.user_id, _('is not in group:'),
                                    group.group_id), status='error', updates=[])
Beispiel #18
0
    def post_add_admins(self, proj, userids):
        """Add administrators to a project"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        added = []
        updates = []

        for uid in userids:
            adduser = user_get(uid)
            if adduser not in project.admins:
                project.admins.append(adduser)
                added.append(adduser.user_id)
                
                # prepare updates to notify clients
                updates.append(dict(item=adduser, type='added',
                            topic=TOPIC_PROJECT_ADMINS, filter=project.id))
            
        added = ', '.join(added)
        
        if added:
            # log into Journal
            msg = '%s %s %s' % (added,
                                n_('set as administrator for:',
                                   'set as administrators for:', len(added)),
                                project.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 administrators for:'), project.id),
            status='info', updates=[])
Beispiel #19
0
    def post_add_to_group(self, group_id, userids):
        """Add users to a group"""
        session = session_get()
        user = tmpl_context.user
        group = group_get(group_id)
        added = []
        updates = []
        
        for uid in userids:
            adduser = user_get(uid)
            if adduser not in group.users:
                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=[])
Beispiel #20
0
    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()

            msg = '%s %s' % (_('Released Asset:'), asset.path)
            updates = [dict(item=asset, type='updated', topic=TOPIC_ASSETS)]
            status = 'ok'

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

            # notify clients
            notify.send(updates)
        else:
            msg = '%s %s' % (_('Asset is not checkedout:'), asset.path)
            updates = []
            status = 'error'

        return dict(msg=msg, status=status, updates=updates)
Beispiel #21
0
    def put(self, proj, libgroup_id, description=None):
        """Edit a libgroup"""
        session = session_get()
        user = tmpl_context.user
        libgroup = libgroup_get(proj, libgroup_id)
        old = libgroup.__dict__.copy()

        modified = False
        if description is not None and not libgroup.description == description:
            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=[])
Beispiel #22
0
    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)
            artist = query.one()
            session.delete(artist)

            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_PROJECT_ARTISTS,
                        filter='%s-%s' % (project.id, category.id)))

            # log into Journal
            msg = '%s %s %s/%s' % (remuser.user_id,
                                   _('revoked as artist from:'),
                                   project.id, category.id)
            journal.add(user, msg)
            notify.send(updates)

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

        return dict(msg='%s %s %s' % (
                remuser.user_id, _('is not an artist for:'), project.id),
                status='error', updates=[])
Beispiel #23
0
    def post_change_password(self, new_password, retype_password):
        """Change the current user password"""
        user = tmpl_context.user
        user.password = new_password
        msg = '%s %s' % (_('Changed password for User:'******'%s' % msg)

        # notify clients
        updates = [dict(item=user, type='updated', topic=TOPIC_USERS)]
        notify.send(updates)
        return dict(msg=msg, status='ok', updates=updates)
Beispiel #24
0
    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)
Beispiel #25
0
    def post_delete(self, proj, libgroup_id):
        """Delete a libgroup.
        
        Only delete the libgroup record from the db, the scene directories must
        be removed manually.
        (This should help prevent awful accidents) ;)
        """
        project = tmpl_context.project
        session = session_get()
        user = tmpl_context.user
        libgroup = libgroup_get(proj, libgroup_id)
        if libgroup.subgroups:
            return dict(msg='%s %s' % (
                    _('Cannot delete libgroup because it contains subgroups'),
                    libgroup.path),
                status='error')
        if libgroup.assets:
            return dict(msg='%s %s' % (
                    _('Cannot delete libgroup because it contains assets'),
                    libgroup.path),
                status='error')

        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)
Beispiel #26
0
    def put(self, proj, sc, sh, description=None, action=None, frames=None,
                                            handle_in=None, handle_out=None):
        """Edit a shot"""
        session = session_get()
        user = tmpl_context.user
        shot = shot_get(proj, sc, sh)
        old = shot.__dict__.copy()
        
        modified = False
        if description is not None and not shot.description == description:
            shot.description = description
            modified = True
        
        if action is not None and not shot.action == action:
            shot.action = action
            modified = True
        
        if frames is not None and not shot.frames == frames:
            shot.frames = frames
            modified = True
        
        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=[])
Beispiel #27
0
    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)
Beispiel #28
0
    def post_delete(self, user_id):
        """Delete a user."""
        session = session_get()
        user = tmpl_context.user
        deluser = user_get(user_id)

        session.delete(deluser)

        msg = '%s %s' % (_('Deleted user:'******'%s - %s' % (msg, deluser))

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

        return dict(msg=msg, status='ok', updates=updates)
Beispiel #29
0
    def post(self, taggable_id, tagids=[], new_tags=None):
        """Add tags to a ``taggable`` obect."""
        session = session_get()
        user = tmpl_context.user
        taggable = taggable_get(taggable_id)

        if isinstance(tagids, list):
            tags = [tag_get(i) for i in tagids]
        else:
            tags = [tag_get(tagids)]

        if new_tags:
            tags.extend([tag_get(name) for name in new_tags.split(', ')])

        added_tags = []
        updates = []
        for tag in tags:
            if tag not in taggable.tags:
                taggable.tags.append(tag)
                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)
Beispiel #30
0
    def post_delete(self, proj, sc, sh):
        """Delete a shot.
        
        Only delete the shot record from the db, the shot directories must be
        removed manually.
        (This should help prevent awful accidents) ;)
        """
        project = tmpl_context.project
        session = session_get()
        user = tmpl_context.user
        shot = shot_get(proj, sc, sh)
        
        if shot.assets:
            return dict(msg='%s %s' % (
                    _('Cannot delete shot "%s" because it contains assets'),
                    shot.path),
                status='error')

        session.delete(shot)

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

        # invalidate project cache
        project.touch()

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

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

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