Przeglądaj źródła

changes to database script and adding typology

joel
Simon Bowie 1 rok temu
rodzic
commit
f8ccdb0b51
4 zmienionych plików z 40 dodań i 2 usunięć
  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 Wyświetl plik

{ {
docker cp $IMPORT_TXT_FILE $CONTAINER:/tmp/import_file 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() Drop_table()

+ 3
- 1
web/app/book.py Wyświetl plik

practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name) practices_filter = Resource.query.filter_by(type='practice').with_entities(Resource.id, Resource.name)
# year # year
year_filter = get_filter_values('year', type) 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 # route for displaying a single book based on the ID in the database
@book.route('/books/<int:book_id>') @book.route('/books/<int:book_id>')

+ 10
- 0
web/app/templates/book.html Wyświetl plik

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

+ 26
- 0
web/app/templates/resources.html Wyświetl plik

{% endif %} {% endif %}
</div> </div>
<div class="row"> <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 %} {% if languages_filter %}
<div class="col-sm-6 d-md-block d-sm-none d-none"> <div class="col-sm-6 d-md-block d-sm-none d-none">
<div class="filter-title">Scripting languages</div> <div class="filter-title">Scripting languages</div>

Ładowanie…
Anuluj
Zapisz