Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@project_set_active
@require(in_group('administrators'))
@expose('spam.templates.forms.form')
def edit(self, proj, **kwargs):
"""Display a EDIT form."""
project = tmpl_context.project
f_edit.value = dict(proj=project.id,
id_=project.id,
project_name=project.name,
description=project.description)
tmpl_context.form = f_edit
return dict(title='%s %s' % (_('Edit project:'), proj))
@project_set_active
@require(is_project_admin())
@expose('spam.templates.forms.form')
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))
"""Base class for forms that submit data to a custom REST method via the
``_method`` parameter
"""
custom_method = twc.Param('The custom REST method to use for submitting '
'the form', default='POST')
custom_method_field = twf.IgnoredField(name='_method')
submit = SubmitWithFeedback(id='submit', value='Submit')
def prepare(self):
if not self.child.children.custom_method_field.value:
self.child.children.custom_method_field.value = self.custom_method
super(RestForm, self).prepare()
# User
class FormUserNew(RestForm):
"""New user form."""
user_name = twf.TextField(validator=StringLength(max=16, required=True))
display_name = twf.TextField(validator=StringLength(max=255, required=True))
password = twf.PasswordField(validator=StringLength(max=80, required=True))
class FormUserEdit(RestForm):
"""Edit user form."""
custom_method = 'PUT'
user_id = twf.HiddenField()
user_name_ = twf.LabelField()
display_name = twf.TextField(validator=StringLength(max=255, required=True))
class FormUserConfirm(RestForm):
"""Generic user confirmation form."""
"""New note form."""
proj = twf.HiddenField()
annotable_id = twf.HiddenField()
text = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS,
validator=twc.Required)
class FormNoteConfirm(RestForm):
"""Generic note confirmation form."""
proj = twf.HiddenField()
note_id = twf.HiddenField()
text_ = twf.LabelField()
# Project
class FormProjectNew(RestForm):
"""New project form."""
proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectEdit(RestForm):
"""Edit project form."""
custom_method = 'PUT'
proj = twf.HiddenField()
id_ = twf.LabelField()
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectEdit(RestForm):
"""Edit project form."""
custom_method = 'PUT'
proj = twf.HiddenField()
id_ = twf.LabelField()
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectConfirm(RestForm):
"""Generic project confirmation form."""
proj = twf.HiddenField()
id_ = twf.LabelField()
project_name_ = twf.LabelField(label='Name')
description_ = twf.LabelField()
# Scene
class FormSceneNew(RestForm):
"""New scene form."""
proj = twf.HiddenField()
project_name_ = twf.LabelField()
sc = twf.TextField(label='name', validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
description_ = twf.LabelField()
# Libgroups
class FormLibgroupNew(RestForm):
"""New libgroup form."""
proj = twf.HiddenField()
parent_id = twf.HiddenField()
project_name_ = twf.LabelField()
parent_ = twf.LabelField()
name = twf.TextField(validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormLibgroupEdit(RestForm):
"""Edit libgroup form."""
custom_method = 'PUT'
proj = twf.HiddenField()
libgroup_id = twf.HiddenField()
project_name_ = twf.LabelField()
libgroup_name_ = twf.LabelField(label='Name')
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormLibgroupConfirm(RestForm):
"""Generic libgroup confirmation form."""
proj = twf.HiddenField()
libgroup_id = twf.HiddenField()
project_name_ = twf.LabelField()
libgroup_name_ = twf.LabelField(label='Name')
description_ = twf.LabelField()
"""Generic note confirmation form."""
proj = twf.HiddenField()
note_id = twf.HiddenField()
text_ = twf.LabelField()
# Project
class FormProjectNew(RestForm):
"""New project form."""
proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectEdit(RestForm):
"""Edit project form."""
custom_method = 'PUT'
proj = twf.HiddenField()
id_ = twf.LabelField()
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectConfirm(RestForm):
"""Generic project confirmation form."""
proj = twf.HiddenField()
id_ = twf.LabelField()
project_name_ = twf.LabelField(label='Name')
description_ = twf.LabelField()
"""Remove tag form."""
custom_method = 'REMOVE'
taggable_id = twf.HiddenField()
tagids = twf.MultipleSelectField(label='Tags', options=[], size=SEL_SIZE)
# Note
class FormNoteNew(RestForm):
"""New note form."""
proj = twf.HiddenField()
annotable_id = twf.HiddenField()
text = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS,
validator=twc.Required)
class FormNoteConfirm(RestForm):
"""Generic note confirmation form."""
proj = twf.HiddenField()
note_id = twf.HiddenField()
text_ = twf.LabelField()
# Project
class FormProjectNew(RestForm):
"""New project form."""
proj = twf.TextField(label='id', validator=twc.All(StringLength(max=15),
twc.RegexValidator(regex=G.pattern_name), required=True))
project_name = twf.TextField(label='Name', validator=StringLength(max=40))
description = twf.TextArea(cols=TEXT_AREA_COLS, rows=TEXT_AREA_ROWS)
class FormProjectEdit(RestForm):
naming_convention=u'^[a-zA-Z0-9_]+_PNT\.[a-zA-Z0-9]+$')
session.add(paint)
audio = model.Category(u'audio', ordering=8,
naming_convention=u'^[a-zA-Z0-9_]+_AUD\.[a-zA-Z0-9]+$')
session.add(audio)
animatic = model.Category(u'animatic', ordering=9,
naming_convention=u'^[a-zA-Z0-9_]+_A[23]D\.[a-zA-Z0-9]+$')
session.add(animatic)
layout = model.Category(u'layout', ordering=10,
naming_convention=u'^[a-zA-Z0-9_]+_LAY\.[a-zA-Z0-9]+$')
session.add(layout)
animation = model.Category(u'animation', ordering=11,
naming_convention=u'^[a-zA-Z0-9_]+_ANI\.[a-zA-Z0-9]+$')
session.add(animation)
effects = model.Category(u'effects', ordering=12,
naming_convention=u'^[a-zA-Z0-9_]+_FX\.[a-zA-Z0-9]+$')
session.add(effects)
render = model.Category(u'render', ordering=13,
naming_convention=u'^[a-zA-Z0-9_]+_RND\.#\.[a-zA-Z0-9]+$')
session.add(render)
compositing = model.Category(u'compositing', ordering=14,
naming_convention=u'^[a-zA-Z0-9_]+_CMP\.#\.[a-zA-Z0-9]+$')
session.add(compositing)
transaction.commit()
def post_submit(self, proj, asset_id, comment=None):
"""Submit an asset to supervisors for approval."""
session = session_get()
user = tmpl_context.user
asset = asset_get(proj, asset_id)
if not asset.submitted and not asset.approved:
asset.submit(user)
text = u'[%s v%03d]\n%s' % (_('submitted'), asset.current.ver,
comment or '')
asset.current.notes.append(Note(user, text))
session.refresh(asset.current.annotable)
# log into Journal
journal.add(user, 'submitted %s' % asset)
# send a stomp message to notify clients
notify.send(asset)
notify.ancestors(asset)
return dict(msg='submitted asset "%s"' % asset.path,
result='success')