NodeType editing
This commit is contained in:
parent
f987b317ec
commit
10ad8a6a9f
@ -23,7 +23,7 @@ thumb = Thumbnail(app)
|
|||||||
assets = Environment(app)
|
assets = Environment(app)
|
||||||
|
|
||||||
# Import controllers
|
# Import controllers
|
||||||
#from models import model
|
from application.modules.nodes import nodes
|
||||||
from application.modules.main import homepage
|
from application.modules.main import homepage
|
||||||
from application.modules.shots import shots
|
from application.modules.shots import shots
|
||||||
from application.modules.projects import projects
|
from application.modules.projects import projects
|
||||||
@ -32,3 +32,4 @@ from application.modules.projects import projects
|
|||||||
app.register_blueprint(filemanager)
|
app.register_blueprint(filemanager)
|
||||||
app.register_blueprint(shots, url_prefix='/shots')
|
app.register_blueprint(shots, url_prefix='/shots')
|
||||||
app.register_blueprint(projects, url_prefix='/projects')
|
app.register_blueprint(projects, url_prefix='/projects')
|
||||||
|
app.register_blueprint(nodes, url_prefix='/nodes')
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
from flask import abort
|
||||||
|
from flask import Blueprint
|
||||||
|
from flask import jsonify
|
||||||
|
from flask import render_template
|
||||||
|
from flask import redirect
|
||||||
|
from flask import request
|
||||||
|
from flask import flash
|
||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
from application import db
|
||||||
|
|
||||||
|
from application.modules.nodes.models import Node, NodeType
|
||||||
|
from application.modules.nodes.forms import NodeTypeForm
|
||||||
|
|
||||||
|
|
||||||
|
# Name of the Blueprint
|
||||||
|
nodes = Blueprint('nodes', __name__)
|
||||||
|
|
||||||
|
@nodes.route("/")
|
||||||
|
def index():
|
||||||
|
"""Display the node types
|
||||||
|
"""
|
||||||
|
node_types = [t for t in NodeType.query.all()]
|
||||||
|
|
||||||
|
return render_template('nodes/index.html',
|
||||||
|
title='nodes',
|
||||||
|
node_types=node_types)
|
||||||
|
|
||||||
|
shots = []
|
||||||
|
for shot in Node.query.\
|
||||||
|
join(NodeType).\
|
||||||
|
filter(NodeType.url == 'shot'):
|
||||||
|
status = None
|
||||||
|
if shot.status:
|
||||||
|
status = shot.status.name
|
||||||
|
shots.append(dict(
|
||||||
|
id=shot.id,
|
||||||
|
name=shot.name,
|
||||||
|
description=shot.description,
|
||||||
|
duration=shot.node_shot[0].duration,
|
||||||
|
status=status,
|
||||||
|
notes=shot.node_shot[0].notes))
|
||||||
|
return render_template('shots/index.html',
|
||||||
|
title='shots',
|
||||||
|
shots=shots)
|
||||||
|
|
||||||
|
|
||||||
|
@nodes.route("/create", methods=('GET', 'POST'))
|
||||||
|
def create():
|
||||||
|
form = NodeTypeForm()
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
node_type = NodeType(
|
||||||
|
name=form.name.data,
|
||||||
|
description=form.description.data,
|
||||||
|
url=form.url.data)
|
||||||
|
|
||||||
|
db.session.add(node_type)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return redirect(url_for('nodes.index'))
|
||||||
|
return render_template('nodes/create.html', form=form)
|
16
attract/application/modules/nodes/forms.py
Normal file
16
attract/application/modules/nodes/forms.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from flask_wtf import Form
|
||||||
|
from wtforms import TextField
|
||||||
|
from wtforms import BooleanField
|
||||||
|
from wtforms import SelectField
|
||||||
|
from wtforms import TextAreaField
|
||||||
|
from wtforms import IntegerField
|
||||||
|
|
||||||
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
from application.modules.nodes.models import Node, NodeType
|
||||||
|
|
||||||
|
class NodeTypeForm(Form):
|
||||||
|
name = TextField('Node Name', validators=[DataRequired()])
|
||||||
|
url = TextField('Url', validators=[DataRequired()])
|
||||||
|
description = TextAreaField('Description', validators=[DataRequired()])
|
||||||
|
is_extended = BooleanField('Is extended')
|
@ -50,12 +50,6 @@ class NodeType(db.Model):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
# Create Many to Many table
|
|
||||||
# nodes_assets_table = db.Table('nodes_assets', db.Model.metadata,
|
|
||||||
# db.Column('node_id', db.Integer, db.ForeignKey('node.id')),
|
|
||||||
# db.Column('asset_id', db.Integer, db.ForeignKey('asset.id'))
|
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class Node(db.Model):
|
class Node(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key = True)
|
id = db.Column(db.Integer, primary_key = True)
|
||||||
@ -76,8 +70,6 @@ class Node(db.Model):
|
|||||||
status_id = db.Column(db.Integer(), db.ForeignKey(Status.id))
|
status_id = db.Column(db.Integer(), db.ForeignKey(Status.id))
|
||||||
status = db.relationship(Status, backref='Node')
|
status = db.relationship(Status, backref='Node')
|
||||||
|
|
||||||
#assets = db.relationship('Asset', secondary=nodes_assets_table)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from sqlalchemy.orm import aliased
|
|||||||
from application import db
|
from application import db
|
||||||
|
|
||||||
from application.modules.shots.forms import ShotForm
|
from application.modules.shots.forms import ShotForm
|
||||||
from application.modules.nodes.models import Node, NodeType, Status
|
from application.modules.nodes.models import Node, NodeType
|
||||||
from application.modules.shots.models import NodeShot
|
from application.modules.shots.models import NodeShot
|
||||||
|
|
||||||
|
|
||||||
@ -56,8 +56,7 @@ def view(shot_id):
|
|||||||
@shots.route("/create", methods=('GET', 'POST'))
|
@shots.route("/create", methods=('GET', 'POST'))
|
||||||
def create():
|
def create():
|
||||||
form = ShotForm()
|
form = ShotForm()
|
||||||
# Populate dropdown select with available Statuses
|
|
||||||
form.status_id.choices = [(status.id, status.name) for status in Status.query.all()]
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
shot_type = NodeType.query.filter_by(url='shot').first()
|
shot_type = NodeType.query.filter_by(url='shot').first()
|
||||||
shot = Node(
|
shot = Node(
|
||||||
@ -85,7 +84,7 @@ def edit(shot_id):
|
|||||||
description=shot.description,
|
description=shot.description,
|
||||||
duration=shot.node_shot[0].duration,
|
duration=shot.node_shot[0].duration,
|
||||||
note=shot.node_shot[0].notes)
|
note=shot.node_shot[0].notes)
|
||||||
form.status_id.choices = [(status.id, status.name) for status in Status.query.all()]
|
#form.status_id.choices = [(status.id, status.name) for status in Status.query.all()]
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
print shot.node_shot
|
print shot.node_shot
|
||||||
|
@ -7,9 +7,18 @@ from wtforms import IntegerField
|
|||||||
|
|
||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
from application.modules.nodes.models import Node, NodeType
|
||||||
|
|
||||||
class ShotForm(Form):
|
class ShotForm(Form):
|
||||||
|
statuses = Node.query\
|
||||||
|
.join(NodeType)\
|
||||||
|
.filter(NodeType.url == 'shot_status')\
|
||||||
|
.all()
|
||||||
|
|
||||||
name = TextField('Shot Name', validators=[DataRequired()])
|
name = TextField('Shot Name', validators=[DataRequired()])
|
||||||
description = TextAreaField('Description', validators=[DataRequired()])
|
description = TextAreaField('Description', validators=[DataRequired()])
|
||||||
status_id = SelectField('Status', coerce=int)
|
status_id = SelectField('Status',
|
||||||
|
coerce=int,
|
||||||
|
choices=[(status.id, status.name) for status in statuses])
|
||||||
duration = IntegerField('Duration')
|
duration = IntegerField('Duration')
|
||||||
notes = TextAreaField('Notes')
|
notes = TextAreaField('Notes')
|
||||||
|
31
attract/application/templates/nodes/create.html
Normal file
31
attract/application/templates/nodes/create.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{% extends 'layout.html' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="col-md-9">
|
||||||
|
<h2>Create Node type</h2>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<form method="POST" action="{{url_for('nodes.create')}}">
|
||||||
|
{{ form.hidden_tag() }}
|
||||||
|
<div class="form-group">
|
||||||
|
{{ form.name.label }}
|
||||||
|
{{ form.name(size=20, class='form-control') }}
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{ form.description.label }}
|
||||||
|
{{ form.description(size=20, class='form-control') }}
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{ form.url.label }}
|
||||||
|
{{ form.url(size=20, class='form-control') }}
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{ form.is_extended.label }}
|
||||||
|
{{ form.is_extended(class='form-control') }}
|
||||||
|
</div>
|
||||||
|
<input class="btn btn-default" type="submit" value="Create Node Type">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
51
attract/application/templates/nodes/index.html
Normal file
51
attract/application/templates/nodes/index.html
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{% extends 'layout.html' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped" id="shots">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Node Name</th>
|
||||||
|
<th>Url</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th width="8%"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for node_type in node_types %}
|
||||||
|
<tr id="row_{{node_type.id}}">
|
||||||
|
<td>{{node_type.name}}</td>
|
||||||
|
<td>{{node_type.url}}</td>
|
||||||
|
<td>
|
||||||
|
{% if node_type.description %}
|
||||||
|
{{node_type.description|truncate(25)}}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-default btn-xs" href="#"><i class="glyphicon glyphicon-edit"></i> Edit</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>Node Name</th>
|
||||||
|
<th>Url</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th width="8%"></th>
|
||||||
|
</tr>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<a href="{{url_for('nodes.create')}}" class="btn btn-default">Create</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user