diff --git a/attract/application/controllers/shots.py b/attract/application/controllers/shots.py index 271e01da..5a8c9d02 100644 --- a/attract/application/controllers/shots.py +++ b/attract/application/controllers/shots.py @@ -34,6 +34,7 @@ def index(): shots.append(dict( id=shot.id, name=shot.name, + description=shot.description, status=status)) return render_template('shots/index.html', title='shots', @@ -50,13 +51,48 @@ def view(shot_id): else: abort(404) -""" + class ShotForm(Form): - name = TextField('Blender-ID') - description = TextField('First Name', validators=[DataRequired()]) - parent_id = IntegerFiled('Last Name', validators=[DataRequired()]) - cloud_communications = BooleanField('Cloud Communications') -""" -@shots.route("/create") + name = TextField('Shot Name', validators=[DataRequired()]) + description = TextField('Description', validators=[DataRequired()]) + +@shots.route("/create", methods=('GET', 'POST')) def create(): - return 'create here' + form = ShotForm() + if form.validate_on_submit(): + shot_type = NodeType.query.filter_by(name='shot').first() + shot = Node( + name=form.name.data, + description=form.description.data, + node_type_id=shot_type.id) + db.session.add(shot) + db.session.commit() + return redirect('/') + return render_template('shots/create.html', form=form) + + +@shots.route("/edit/", methods=('GET', 'POST')) +def edit(shot_id): + shot = Node.query.get(shot_id) + form = ShotForm( + name=shot.name, + description=shot.description) + if form.validate_on_submit(): + shot.name = form.name.data + shot.description=form.description.data + db.session.commit() + return redirect('/') + return render_template( + 'shots/edit.html', + form=form, + shot_id=shot_id) + + +@shots.route("/delete/") +def delete(shot_id): + shot = Node.query.get(shot_id) + if shot: + db.session.delete(shot) + return redirect('/') + else: + abort(404) diff --git a/attract/application/templates/shots/create.html b/attract/application/templates/shots/create.html new file mode 100644 index 00000000..5ac9716f --- /dev/null +++ b/attract/application/templates/shots/create.html @@ -0,0 +1,23 @@ +{% extends 'layout.html' %} + +{% block body %} +
+

Create shot

+
+
+
+ {{ form.hidden_tag() }} +
+ {{ form.name.label }} + {{ form.name(size=20, class='form-control') }} +
+
+ {{ form.description.label }} + {{ form.description(size=20, class='form-control') }} +
+ +
+
+
+
+{% endblock %} diff --git a/attract/application/templates/shots/edit.html b/attract/application/templates/shots/edit.html new file mode 100644 index 00000000..6fa28b26 --- /dev/null +++ b/attract/application/templates/shots/edit.html @@ -0,0 +1,23 @@ +{% extends 'layout.html' %} + +{% block body %} +
+

Edit shot

+
+
+
+ {{ form.hidden_tag() }} +
+ {{ form.name.label }} + {{ form.name(size=20, class='form-control') }} +
+
+ {{ form.description.label }} + {{ form.description(size=20, class='form-control') }} +
+ +
+
+
+
+{% endblock %} diff --git a/attract/application/templates/shots/index.html b/attract/application/templates/shots/index.html index 0bd5f947..bdc3d9de 100644 --- a/attract/application/templates/shots/index.html +++ b/attract/application/templates/shots/index.html @@ -2,46 +2,54 @@ {% block body %}
- - - - - - - - - - - - - - {% for shot in shots %} - - - - - - - - - - {% endfor %} - - - - - - - - - - - - - -
Shot NameDescriptionDurationStatusTasksNotes
{{shot['name']}}{{shot['description']}}{{shot['status']}} - Edit -
Shot NameDescriptionDurationStatusTasksNotes
+
+
+ + + + + + + + + + + + + + {% for shot in shots %} + + + + + + + + + + {% endfor %} + + + + + + + + + + + + + +
Shot NameDescriptionDurationStatusTasksNotes
{{shot['name']}}{{shot['description']}}{{shot['status']}} + Edit +
Shot NameDescriptionDurationStatusTasksNotes
+
+
+
+
+ Create +
+
- -{% endblock %} \ No newline at end of file +{% endblock %}