Преглед изворни кода

changes to database script and adding typology

joel
Simon Bowie пре 1 година
родитељ
комит
f8ccdb0b51
4 измењених фајлова са 40 додато и 2 уклоњено
  1. +1
    -1
      database_functions.sh
  2. +3
    -1
      web/app/book.py
  3. +10
    -0
      web/app/templates/book.html
  4. +26
    -0
      web/app/templates/resources.html

+ 1
- 1
database_functions.sh Прегледај датотеку

@@ -57,7 +57,7 @@ Table_import()
{
docker cp $IMPORT_TXT_FILE $CONTAINER:/tmp/import_file

docker exec -i $CONTAINER bash -c "mysql -u $USERNAME -p$PASSWORD $DATABASE -e 'LOAD DATA LOCAL INFILE '\''/tmp/import_file'\'' REPLACE INTO TABLE $TABLE FIELDS TERMINATED BY '\''\t'\'' LINES TERMINATED BY '\''\n'\'' IGNORE 1 ROWS;'"
docker exec -i $CONTAINER bash -c "mysql -u $USERNAME -p$PASSWORD $DATABASE -e 'LOAD DATA LOCAL INFILE '\''/tmp/import_file'\'' REPLACE INTO TABLE $TABLE FIELDS TERMINATED BY '\''\t'\'' LINES TERMINATED BY '\''\r'\'' IGNORE 1 ROWS;'"
}

Drop_table()

+ 3
- 1
web/app/book.py Прегледај датотеку

@@ -35,7 +35,9 @@ def get_books():
practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name)
# year
year_filter = get_filter_values('year', type)
return render_template('resources.html', resources=books, type=type, practices_filter=practices_filter, year_filter=year_filter)
# typology
typology_filter = get_filter_values('typology', type)
return render_template('resources.html', resources=books, type=type, practices_filter=practices_filter, year_filter=year_filter, typology_filter=typology_filter)

# route for displaying a single book based on the ID in the database
@book.route('/books/<int:book_id>')

+ 10
- 0
web/app/templates/book.html Прегледај датотеку

@@ -22,6 +22,16 @@
<div class="col">
<table class="table table-hover">
<tbody>
{% if resource['typology'] %}
<tr>
<th>
Typology category:
</th>
<td>
<a href="{{ resource['typology'] }}">{{ resource['typology'] }}</a>
</td>
</tr>
{% endif %}
{% if resource['bookUrl'] %}
<tr>
<th>

+ 26
- 0
web/app/templates/resources.html Прегледај датотеку

@@ -76,6 +76,32 @@
{% endif %}
</div>
<div class="row">
{% if typology_filter %}
<div class="col-sm-6 d-md-block d-sm-none d-none">
<div class="filter-title">Typology category</div>
<ul class="filter-items">
{% for typology in typology_filter %}
<li {% if request.args.get('typology') == typology %} class="fw-bold"{% endif %}>
<a href="/books?typology={{typology}}">{{ typology }}</a>
</li>
{% endfor %}
</ul>
</div>
<div class="d-md-none accordion">
<div class="accordion-item">
<div class="filter-title accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#filter-typology">Typology category</div>
<div class="accordion-body">
<ul id="filter-typology" class="collapse filter-items">
{% for typology in typology_filter %}
<li {% if request.args.get('typology') == typology %} class="fw-bold"{% endif %}>
<a href="/books?typology={{typology}}">{{ typology }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endif %}
{% if languages_filter %}
<div class="col-sm-6 d-md-block d-sm-none d-none">
<div class="filter-title">Scripting languages</div>

Loading…
Откажи
Сачувај