| @login_required | @login_required | ||||
| def create_resource(): | def create_resource(): | ||||
| if request.method == 'POST': | if request.method == 'POST': | ||||
| if request.form.get('type') == 'tool': | |||||
| if request.form.get('resource_type') == 'tool': | |||||
| name = request.form.get('name') | name = request.form.get('name') | ||||
| description = request.form.get('description') | 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: | if not name: | ||||
| flash('Name is required!') | flash('Name is required!') | ||||
| return redirect(url_for('create.create')) | return redirect(url_for('create.create')) | ||||
| # create a new tool with the form data | # 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 | # add the new tool to the database | ||||
| db.session.add(new_tool) | db.session.add(new_tool) | ||||
| db.session.commit() | db.session.commit() | ||||
| elif request.form.get('type') == 'example': | |||||
| elif request.form.get('resource_type') == 'example': | |||||
| name = request.form.get('name') | name = request.form.get('name') | ||||
| description = request.form.get('description') | description = request.form.get('description') | ||||
| db.session.add(new_example) | db.session.add(new_example) | ||||
| db.session.commit() | db.session.commit() | ||||
| elif request.form.get('type') == 'practice': | |||||
| elif request.form.get('resource_type') == 'practice': | |||||
| name = request.form.get('name') | name = request.form.get('name') | ||||
| description = request.form.get('description') | description = request.form.get('description') | ||||
| created = db.Column(db.DateTime, default=datetime.utcnow) | created = db.Column(db.DateTime, default=datetime.utcnow) | ||||
| name = db.Column(db.Text) | name = db.Column(db.Text) | ||||
| description = 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 | # table for examples | ||||
| class Example(db.Model): | class Example(db.Model): |
| </div> | </div> | ||||
| <div class="mb-3 mt-3"> | <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> | <textarea class="form-control" rows="4" type="text" name="description" placeholder="Tool description" autofocus=""></textarea> | ||||
| </div> | </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> | ||||
| <div id="resource_type_example" class="resource_type_input" style="display: none;"> | <div id="resource_type_example" class="resource_type_input" style="display: none;"> | ||||
| <div class="mb-3 mt-3"> | <div class="mb-3 mt-3"> |
| Created: | Created: | ||||
| </th> | </th> | ||||
| <td> | <td> | ||||
| {{ tool['created'] }} | |||||
| {{ tool['created'].strftime("%Y-%m-%d %H:%M") }} UTC | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <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> | </tbody> | ||||
| </table> | </table> | ||||
| </div> | </div> |
| </a> | </a> | ||||
| </div> | </div> | ||||
| <div class="card-body"> | <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 %} | {% if current_user.is_authenticated %} | ||||
| <a href="{{ url_for('tool.edit_tool', tool_id=tool['id']) }}"> | <a href="{{ url_for('tool.edit_tool', tool_id=tool['id']) }}"> | ||||
| <span class="badge bg-warning">Edit</span> | <span class="badge bg-warning">Edit</span> |
| tool = Tool.query.get(tool_id) | tool = Tool.query.get(tool_id) | ||||
| tool.name = name | tool.name = name | ||||
| tool.description = description | 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() | db.session.commit() | ||||
| return redirect(url_for('tool.get_tools')) | return redirect(url_for('tool.get_tools')) | ||||