def get_one(self, proj, sc, sh): """Return a `tabbed` page for shot tabs.""" shot = shot_get(proj, sc, sh) tabs = [('Summary', 'tab/summary'), ('Assets', url('/asset/%s/shot/%s' % (shot.project.id, shot.id))), ] return dict(page='%s' % shot.path, shot=shot, tabs=tabs, sidebar=('projects', shot.project.id))
def get_delete(self, proj, sc, sh, **kwargs): """Display a DELETE confirmation form.""" shot = shot_get(proj, sc, sh) f_confirm.custom_method = 'DELETE' f_confirm.value = dict(proj=shot.project.id, sc=shot.parent.name, sh=shot.name, project_name_=shot.project.name, scene_name_=shot.parent.name, shot_name_=shot.name, description_=shot.description, ) warning = ('This will only delete the shot 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:'), shot.path), warning=warning)
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=[])
def edit(self, proj, sc, sh, **kwargs): """Display a EDIT form.""" shot = shot_get(proj, sc, sh) f_edit.value = dict(proj=shot.project.id, sc=shot.parent.name, sh=shot.name, project_name_=shot.project.name, scene_name_=shot.parent.name, shot_name_=shot.name, description=shot.description, action=shot.action, frames=shot.frames, handle_in=shot.handle_in, handle_out=shot.handle_out, ) tmpl_context.form = f_edit return dict(title='%s %s' % (_('Edit shot:'), shot.path))
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)
def _before(self, *args, **kw): proj, sc, sh = request.url.split('/')[-5:-2] shot = shot_get(proj, sc, sh) tmpl_context.project = shot.project tmpl_context.scene = shot.parent tmpl_context.shot = shot