@@ -22,9 +22,18 @@ create = Blueprint('create', __name__) | |||
@login_required | |||
def create_resource(): | |||
if request.method == 'POST': | |||
if request.form.get('type') == 'tool': | |||
if request.form.get('resource_type') == 'tool': | |||
name = request.form.get('name') | |||
description = request.form.get('description') | |||
project_url = request.form.get('project_url') | |||
repository_url = request.form.get('repository_url') | |||
platform_status = request.form.get('platform_status') | |||
expertise = request.form.get('expertise') | |||
self_host_expertise = request.form.get('self_host_expertise') | |||
ingest = request.form.get('ingest') | |||
output = request.form.get('output') | |||
saas = request.form.get('saas') | |||
dependencies = request.form.get('dependencies') | |||
if not name: | |||
flash('Name is required!') | |||
@@ -36,13 +45,13 @@ def create_resource(): | |||
return redirect(url_for('create.create')) | |||
# create a new tool with the form data | |||
new_tool = Tool(name=name, description=description) | |||
new_tool = Tool(name=name, description=description, project_url=project_url, repository_url=repository_url, platform_status=platform_status, expertise=expertise, self_host_expertise=self_host_expertise, ingest=ingest, output=output, saas=saas, dependencies=dependencies) | |||
# add the new tool to the database | |||
db.session.add(new_tool) | |||
db.session.commit() | |||
elif request.form.get('type') == 'example': | |||
elif request.form.get('resource_type') == 'example': | |||
name = request.form.get('name') | |||
description = request.form.get('description') | |||
@@ -62,7 +71,7 @@ def create_resource(): | |||
db.session.add(new_example) | |||
db.session.commit() | |||
elif request.form.get('type') == 'practice': | |||
elif request.form.get('resource_type') == 'practice': | |||
name = request.form.get('name') | |||
description = request.form.get('description') | |||
@@ -24,6 +24,15 @@ class Tool(db.Model): | |||
created = db.Column(db.DateTime, default=datetime.utcnow) | |||
name = db.Column(db.Text) | |||
description = db.Column(db.Text) | |||
project_url = db.Column(db.Text) | |||
repository_url = db.Column(db.Text) | |||
platform_status = db.Column(db.Text) | |||
expertise = db.Column(db.Text) | |||
self_host_expertise = db.Column(db.Text) | |||
ingest = db.Column(db.Text) | |||
output = db.Column(db.Text) | |||
saas = db.Column(db.Text) | |||
dependencies = db.Column(db.Text) | |||
# table for examples | |||
class Example(db.Model): |
@@ -19,9 +19,54 @@ | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="description">Tool description</label> | |||
<label for="description">Short description</label> | |||
<textarea class="form-control" rows="4" type="text" name="description" placeholder="Tool description" autofocus=""></textarea> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="project_url">Project URL</label> | |||
<input class="form-control" type="text" name="project_url" placeholder="Project URL" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="repository_url">Repository URL</label> | |||
<input class="form-control" type="text" name="repository_url" placeholder="Repository URL" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="platform_status">Stand-alone or platform?</label> | |||
<input class="form-control" type="text" name="platform_status" placeholder="Stand-alone or platform?" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="expertise">Expertise required</label> | |||
<input class="form-control" type="text" name="expertise" placeholder="Expertise required" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="self_host_expertise">Expertise required to self-host</label> | |||
<input class="form-control" type="text" name="self_host_expertise" placeholder="Expertise required to self-host" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="ingest">Import / ingest</label> | |||
<input class="form-control" type="text" name="ingest" placeholder="Import / ingest" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="output">Output formats</label> | |||
<input class="form-control" type="text" name="output" placeholder="Output formats" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="saas">SAAS?</label> | |||
<input class="form-control" type="text" name="saas" placeholder="SAAS?" autofocus=""> | |||
</div> | |||
<div class="mb-3 mt-3"> | |||
<label for="dependencies">Technical dependencies</label> | |||
<input class="form-control" type="text" name="dependencies" placeholder="Technical dependencies" autofocus=""> | |||
</div> | |||
</div> | |||
<div id="resource_type_example" class="resource_type_input" style="display: none;"> | |||
<div class="mb-3 mt-3"> |
@@ -15,17 +15,97 @@ | |||
Created: | |||
</th> | |||
<td> | |||
{{ tool['created'] }} | |||
{{ tool['created'].strftime("%Y-%m-%d %H:%M") }} UTC | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Description: | |||
</th> | |||
<td> | |||
{{ tool['description'] }} | |||
</td> | |||
</tr> | |||
<th> | |||
Description: | |||
</th> | |||
<td> | |||
{{ tool['description'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Project page: | |||
</th> | |||
<td> | |||
{{ tool['project_url'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Code repository: | |||
</th> | |||
<td> | |||
{{ tool['repository_url'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Stand-alone or platform?: | |||
</th> | |||
<td> | |||
{{ tool['platform_status'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Expertise required: | |||
</th> | |||
<td> | |||
{{ tool['expertise'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Expertise required to self-host: | |||
</th> | |||
<td> | |||
{{ tool['self_host_expertise'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Import / ingest: | |||
</th> | |||
<td> | |||
{{ tool['ingest'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Output formats: | |||
</th> | |||
<td> | |||
{{ tool['output'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
SAAS?: | |||
</th> | |||
<td> | |||
{{ tool['saas'] }} | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Community-hosted examples: | |||
</th> | |||
<td> | |||
</td> | |||
</tr> | |||
<tr> | |||
<th> | |||
Technical dependencies: | |||
</th> | |||
<td> | |||
{{ tool['dependencies'] }} | |||
</td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
</div> |
@@ -23,7 +23,7 @@ | |||
</a> | |||
</div> | |||
<div class="card-body"> | |||
<span class="badge bg-secondary">{{ tool['created'] }}</span> | |||
<span class="badge bg-secondary">{{ tool['created'].strftime("%Y-%m-%d %H:%M") }} UTC</span> | |||
{% if current_user.is_authenticated %} | |||
<a href="{{ url_for('tool.edit_tool', tool_id=tool['id']) }}"> | |||
<span class="badge bg-warning">Edit</span> |
@@ -50,6 +50,15 @@ def edit_tool(tool_id): | |||
tool = Tool.query.get(tool_id) | |||
tool.name = name | |||
tool.description = description | |||
tool.project_url = project_url | |||
tool.repository_url = repository_url | |||
tool.platform_status = platform_status | |||
tool.expertise = expertise | |||
tool.self_host_expertise = self_host_expertise | |||
tool.ingest = ingest | |||
tool.output = output | |||
tool.saas = saas | |||
tool.dependencies = dependencies | |||
db.session.commit() | |||
return redirect(url_for('tool.get_tools')) | |||