소스 검색

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…
취소
저장