| @@ -64,6 +64,10 @@ def create_resource(): | |||
| type = 'practice' | |||
| name = request.form.get('practice_name') | |||
| description = request.form.get('description') | |||
| longDescription = request.form.get('longDescription') | |||
| experimental = request.form.get('experimental') | |||
| considerations = request.form.get('considerations') | |||
| references = request.form.get('references') | |||
| if not name: | |||
| flash('Name is required!') | |||
| @@ -75,7 +79,7 @@ def create_resource(): | |||
| return redirect(url_for('create.create_resource',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | |||
| # create a new practice with the form data | |||
| new_practice = Resource(type=type, name=name, description=description) | |||
| new_practice = Resource(type=type, name=name, description=description, longDescription=longDescription, experimental=experimental, considerations=considerations, references=references) | |||
| # add the new practice to the database | |||
| db.session.add(new_practice) | |||
| @@ -85,18 +89,23 @@ def create_resource(): | |||
| type = 'book' | |||
| name = request.form.get('book_name') | |||
| description = request.form.get('description') | |||
| author = request.form.get('author') | |||
| year = request.form.get('year') | |||
| typology = request.form.get('typology') | |||
| bookUrl = request.form.get('bookUrl') | |||
| isbn = request.form.get('isbn') | |||
| if not name: | |||
| flash('Name is required!') | |||
| else: | |||
| book = Book.query.filter_by(name=name).first() # if this returns a book, then the name already exists in database | |||
| book = Resource.query.filter_by(type='book').filter_by(name=name).first() # if this returns a book, then the name already exists in database | |||
| if book: # if a book is found, we want to redirect back to create page | |||
| flash('Book with same name already exists') | |||
| return redirect(url_for('create.create_resource',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) | |||
| # create a new book with the form data | |||
| new_book = Resource(type=type, name=name, description=description) | |||
| new_book = Resource(type=type, name=name, description=description, author=author, year=year, typology=typology, bookUrl=bookUrl, isbn=isbn) | |||
| # add the new book to the database | |||
| db.session.add(new_book) | |||
| @@ -8,4 +8,13 @@ | |||
| // }) | |||
| // }) | |||
| // htmx.logAll(); | |||
| // htmx.logAll(); | |||
| // Dynamic HTML forms based on dropdown menu | |||
| $("#resource_type").change(function() { | |||
| var $ = jQuery.noConflict(); | |||
| var resource_type = $(this).val(); | |||
| $(".resource_type_input").hide("fast", function() { | |||
| $("#resource_type_" + resource_type).show("slow"); | |||
| }); | |||
| }); | |||
| @@ -1647,4 +1647,75 @@ a.menuitem:hover { | |||
| .lg\:opacity-100 { | |||
| opacity: 1; | |||
| } | |||
| } | |||
| /* CSS for forms */ | |||
| input.form-control { | |||
| margin: 8px 0; | |||
| box-sizing: border-box; | |||
| border: 2px solid black; | |||
| border-radius: 4px; | |||
| } | |||
| input.form-control[type=text] { | |||
| width: 100%; | |||
| padding: 12px 20px; | |||
| margin: 8px 0; | |||
| box-sizing: border-box; | |||
| border: 2px solid black; | |||
| border-radius: 4px; | |||
| } | |||
| textarea.form-control { | |||
| width: 100%; | |||
| padding: 35px 20px; | |||
| margin: 8px 0; | |||
| box-sizing: border-box; | |||
| border: 2px solid black; | |||
| border-radius: 4px; | |||
| } | |||
| select.selectpicker { | |||
| border: 2px solid black; | |||
| border-radius: 4px; | |||
| } | |||
| select.form-select { | |||
| border: 2px solid black; | |||
| border-radius: 4px; | |||
| } | |||
| .btn { | |||
| display: inline-block; | |||
| margin: 10px; | |||
| margin-bottom: 0; | |||
| font-weight: 400; | |||
| text-align: center; | |||
| white-space: nowrap; | |||
| vertical-align: middle; | |||
| -ms-touch-action: manipulation; | |||
| touch-action: manipulation; | |||
| cursor: pointer; | |||
| background-image: none; | |||
| border: 1px solid transparent; | |||
| padding: 6px 12px; | |||
| line-height: 1.42857143; | |||
| border-radius: 4px; | |||
| -webkit-user-select: none; | |||
| -moz-user-select: none; | |||
| -ms-user-select: none; | |||
| user-select: none; | |||
| } | |||
| .btn-default { | |||
| color: #333; | |||
| background-color: #fff; | |||
| border-color: #ccc; | |||
| } | |||
| .btn-danger { | |||
| color: #fff; | |||
| background-color: #d9534f; | |||
| border-color: #d43f3a; | |||
| } | |||
| @@ -74,6 +74,19 @@ | |||
| </a> | |||
| {% if current_user.is_authenticated %} | |||
| <a href="{{ url_for('create.create_resource') }}" | |||
| class="ml-auto {{ 'active' if request.path == url_for('create.create_resource') }} menuitem {% if type=='top' %} hidden lg:block {% else %} block {% endif %} " | |||
| > | |||
| Add resource | |||
| </a> | |||
| <a href="{{ url_for('auth.logout') }}" | |||
| class="menuitem {% if type=='top' %} hidden lg:block {% else %} block {% endif %} " | |||
| > | |||
| Logout | |||
| </a> | |||
| {% endif %} | |||
| <a href="{{ url_for('main.about') }}{% if view == 'list' %}?view=list{% endif %}" | |||
| class="ml-auto {{ 'active' if request.path == url_for('main.about') }} menuitem {% if type=='top' %} hidden lg:block {% else %} block {% endif %}" | |||
| @click="menuOpen = false"> | |||
| @@ -17,27 +17,22 @@ | |||
| <label for="tool_name">Tool name</label> | |||
| <input class="form-control" type="text" name="tool_name" placeholder="Tool name" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <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="developer">Developer</label> | |||
| <input class="form-control" type="text" name="developer" placeholder="Developer" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="developerUrl">Developer URL</label> | |||
| <input class="form-control" type="text" name="developerUrl" placeholder="Developer URL" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="projectUrl">Project URL</label> | |||
| <input class="form-control" type="text" name="projectUrl" placeholder="Project URL" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="repositoryUrl">Repository URL</label> | |||
| <input class="form-control" type="text" name="repositoryUrl" placeholder="Repository URL" autofocus=""> | |||
| @@ -47,42 +42,34 @@ | |||
| <label for="license">Software license</label> | |||
| <input class="form-control" type="text" name="license" placeholder="Software license" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="scriptingLanguage">Software language</label> | |||
| <input class="form-control" type="text" name="scriptingLanguage" placeholder="Software language" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="expertiseToUse">Expertise required to use</label> | |||
| <input class="form-control" type="text" name="expertiseToUse" placeholder="Expertise required to use" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="expertiseToHost">Expertise required to self-host</label> | |||
| <input class="form-control" type="text" name="expertiseToHost" placeholder="Expertise required to self-host" 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 class="mb-3 mt-3"> | |||
| <label for="ingestFormats">Import / ingest formats</label> | |||
| <input class="form-control" type="text" name="ingestFormats" placeholder="Import / ingest formats" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="outputFormats">Output formats</label> | |||
| <input class="form-control" type="text" name="outputFormats" placeholder="Output formats" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="status">Platform status</label> | |||
| <input class="form-control" type="text" name="status" placeholder="Platform status" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="linked_practice_id">Linked resources</label> | |||
| </div> | |||
| @@ -101,10 +88,25 @@ | |||
| <label for="practice_name">Practice name</label> | |||
| <input class="form-control" type="text" name="practice_name" placeholder="Practice name" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="description">Practice description</label> | |||
| <textarea class="form-control" rows="4" type="text" name="description" placeholder="Practice description" autofocus=""></textarea> | |||
| <label for="description">Description</label> | |||
| <textarea class="form-control" rows="4" type="text" name="description" placeholder="Description" autofocus=""></textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="longDescription">Full description</label> | |||
| <textarea class="form-control" rows="4" type="text" name="longDescription" placeholder="Full description" autofocus=""></textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="experimental">Experimental uses</label> | |||
| <textarea class="form-control" rows="4" type="text" name="experimental" placeholder="Experimental uses" autofocus=""></textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="considerations">Considerations</label> | |||
| <textarea class="form-control" rows="4" type="text" name="considerations" placeholder="Considerations" autofocus=""></textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="references">Further reading</label> | |||
| <textarea class="form-control" rows="4" type="text" name="references" placeholder="Further reading" autofocus=""></textarea> | |||
| </div> | |||
| </div> | |||
| <div id="resource_type_book" class="resource_type_input" style="display: none;"> | |||
| @@ -112,12 +114,35 @@ | |||
| <label for="book_name">Book name</label> | |||
| <input class="form-control" type="text" name="book_name" placeholder="Book name" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="description">Book description</label> | |||
| <label for="description">Description</label> | |||
| <textarea class="form-control" rows="4" type="text" name="description" placeholder="Book description" autofocus=""></textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="author">Author</label> | |||
| <input class="form-control" type="text" name="author" placeholder="Author" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="year">Publication year</label> | |||
| <input class="form-control" type="text" name="year" placeholder="Publication year" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="typology">Typology category</label> | |||
| <input class="form-control" type="text" name="typology" placeholder="Typology category" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="bookUrl">URL</label> | |||
| <input class="form-control" type="text" name="bookUrl" placeholder="URL" autofocus=""> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="isbn">ISBN</label> | |||
| <input class="form-control" type="text" name="isbn" placeholder="ISBN" autofocus=""> | |||
| </div> | |||
| </div> | |||
| <button type="submit" class="btn btn-primary mb-3">Submit</button> | |||
| <button type="submit" class="btn btn-default">Submit</button> | |||
| </form> | |||
| <script | |||
| src="https://code.jquery.com/jquery-3.7.1.js" | |||
| integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" | |||
| crossorigin="anonymous"></script> | |||
| {% endblock %} | |||
| @@ -128,8 +128,8 @@ | |||
| class="form-control">{{ request.form['longDescription'] or resource['longDescription'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="experimental">Experimental use</label> | |||
| <textarea name="experimental" placeholder="Experimental use" | |||
| <label for="experimental">Experimental uses</label> | |||
| <textarea name="experimental" placeholder="Experimental uses" | |||
| class="form-control">{{ request.form['experimental'] or resource['experimental'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| @@ -138,8 +138,8 @@ | |||
| class="form-control">{{ request.form['considerations'] or resource['considerations'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| <label for="references">References</label> | |||
| <textarea name="references" placeholder="References" | |||
| <label for="references">Further reading</label> | |||
| <textarea name="references" placeholder="Further reading" | |||
| class="form-control">{{ request.form['references'] or resource['references'] }}</textarea> | |||
| </div> | |||
| <div class="mb-3 mt-3"> | |||
| @@ -227,10 +227,9 @@ | |||
| {% endif %} | |||
| <div class="mb-3 mt-3"> | |||
| <button type="submit" class="btn btn-primary">Submit</button> | |||
| <button type="submit" class="btn btn-default">Submit</button> | |||
| </div> | |||
| </form> | |||
| <hr> | |||
| {% if resource['type'] == 'tool' %} | |||
| <form action="{{ url_for('tool.delete_tool', tool_id=resource['id']) }}" method="POST"> | |||
| @@ -16,6 +16,6 @@ | |||
| Remember me | |||
| </label> | |||
| </div> | |||
| <button class="btn btn-primary">Login</button> | |||
| <button class="btn btn-default">Login</button> | |||
| </form> | |||
| {% endblock %} | |||