Selaa lähdekoodia

enabling last updated date

main
Simon Bowie 5 päivää sitten
vanhempi
commit
696495745a
4 muutettua tiedostoa jossa 20 lisäystä ja 6 poistoa
  1. +5
    -5
      README.md
  2. +3
    -1
      web/app/models.py
  3. +6
    -0
      web/app/templates/book.html
  4. +6
    -0
      web/app/templates/resource.html

+ 5
- 5
README.md Näytä tiedosto

@@ -34,7 +34,7 @@ To deploy this environment, first copy env.template to a new file, env.dev. Fill

In the command line, navigate to the directory where this repository is stored on your local machine and run:

`docker-compose up -d --build`
`docker compose up -d --build`

Docker should build the application environment comprising a Python container running Flask and a database container running MariaDB.

@@ -42,13 +42,13 @@ The website should then be available in the browser at 'localhost:5000'.

To take down the environment, run:

`docker-compose down`
`docker compose down`

### populating the database

To intially create the database and a database user:

`docker-compose exec -it db mariadb -u root -p`
`docker compose exec -it db mariadb -u root -p`

Enter your root password as defined in .env.dev.

@@ -58,8 +58,8 @@ Enter your root password as defined in .env.dev.

Restart the containers to allow Flask to build the database tables:

`docker-compose down`
`docker-compose up -d --build`
`docker compose down`
`docker compose up -d --build`

You can then use database_functions.sh and an SQL file to populate the database e.g.


+ 3
- 1
web/app/models.py Näytä tiedosto

@@ -26,11 +26,11 @@ class Resource(db.Model):
# all resource types
id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
created = db.Column(db.DateTime, default=datetime.utcnow)
updated = db.Column(db.DateTime, onupdate=datetime.utcnow)
published = db.Column(db.Boolean)
type = db.Column(db.Text)
name = db.Column(db.Text)
description = db.Column(db.Text)
videoUrl = db.Column(db.Text)
# tools
developer = db.Column(db.Text)
developerUrl = db.Column(db.Text)
@@ -55,6 +55,8 @@ class Resource(db.Model):
bookUrl = db.Column(db.Text)
isbn = db.Column(db.Text)
typology = db.Column(db.Text)
# all
videoUrl = db.Column(db.Text)

# table for relationships
class Relationship(db.Model):

+ 6
- 0
web/app/templates/book.html Näytä tiedosto

@@ -110,6 +110,12 @@
</div>
</div>
{% endif %}
{% if resource['updated'] %}
<div class="">
<h3>Entry last updated</h3>
{{ resource['updated'].strftime('%Y-%m-%d')|safe }}
</div>
{% endif %}
{% if resource['desc'] %}
<div class="lg:col-span-2">
<h3>Publisher's description</h3>

+ 6
- 0
web/app/templates/resource.html Näytä tiedosto

@@ -95,6 +95,12 @@
{% endif %}
</div>
{% endif %}
{% if resource['updated'] %}
<div class="">
<h3>Entry last updated</h3>
{{ resource['updated'].strftime('%Y-%m-%d')|safe }}
</div>
{% endif %}
{% elif resource.type == 'practice' %}
{{ practice_markdown | safe }}
{% endif %}

Loading…
Peruuta
Tallenna