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=[])
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)
def get_one(self, proj, sc): """Return a `tabbed` page for scene tabs.""" scene = scene_get(proj, sc) tabs = [('Summary', 'tab/summary'), ('Shots', url('/shot/%s/%s/' % (scene.project.id, scene.name))), ] return dict(page='%s' % scene.path, scene=scene, tabs=tabs, sidebar=('projects', scene.project.id))
def new(self, proj, sc, **kwargs): """Display a NEW form.""" scene = scene_get(proj, sc) f_new.value = dict(proj=scene.project.id, sc=scene.name, project_name_=scene.project.name, scene_name_=scene.name, ) tmpl_context.form = f_new return dict(title=_('Create a new shot'))
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))
def get_delete(self, proj, sc, **kwargs): """Display a DELETE confirmation form.""" scene = scene_get(proj, sc) f_confirm.custom_method = 'DELETE' f_confirm.value = dict(proj=scene.project.id, sc=scene.name, project_name_=scene.project.name, scene_name_=scene.name, description_=scene.description, ) warning = _('This will only delete the scene entry in the database. ' 'The data must be deleted manually if needed.') tmpl_context.form = f_confirm return dict(title='%s %s?' % (_('Are you sure you want to delete:'), scene.path), warning=warning)
def post_delete(self, proj, sc): """Delete a scene. Only delete the scene 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 scene = scene_get(proj, sc) if scene.shots: return dict(msg='%s %s' % ( _('Cannot delete scene because it contains shots:'), scene.path), 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)
def get_all(self, proj, sc): """Return a `tab` page with a list of shots for a scene and a button to add new shots. This page is used as the `shots` tab in the scene view: :meth:`spam.controllers.scene.main.get_one`. """ project = tmpl_context.project user = tmpl_context.user scene = scene_get(proj, sc) tmpl_context.scene = scene t_shots.value = scene.shots t_shots.extra_data = dict(project=project, user_id=user.user_id, proj_id=project.id, parent_name=scene.name, container_type='shot', ) tmpl_context.t_shots = t_shots return dict(page='shot', sidebar=('projects', scene.project.id))
def _before(self, *args, **kw): proj, sc = request.url.split("/")[-4:-2] scene = scene_get(proj, sc) tmpl_context.project = scene.project tmpl_context.scene = scene