Skip to content

Commit

Permalink
Fix badge date 248 (#278)
Browse files Browse the repository at this point in the history
* Use Docker to seed db (#253)

* added to .gitignore
* added a file testdb_seed
* removed reseting db from docker_script because this is handled in docker-compose-dev

NOTE:
docker-compose.yml is not currently used and will not reset or seed the database.
Just use docker-compose-dev.yml for now.

* Update packages related to security issues

requests: 2.18.4 > 2.22.0
SQLAlchemy 1.1.14 > 1.3.3
PyJWT 1.4.2 > 1.7.1
urllib3 1.22 > 1.25.2

* Update versions and specify jwt decode algorithm

alembic 0.9.6 > 1.0.10
flask-sqlalchemy 2.3.2 > 2.4.0
pyscopg2 2.7.5 > psycopg2-binary 2.7.5
sqlalchemy-utils 0.33.5 > 0.33.11
werkzeug 0.14.1 > 0.15.4

Specifying a jwt decode algorithm avoids a deprication warning that would have been introduced from these version update commits.w

* code formating and remove unused import

* updates pipfile and requirements to fix security

requirements.txt is generated by pipfile so fixing pipfile should have been the first step. This commit should fix the outdated libraries that had security issues.

* badges are labeled with current year

Using the db table Year which stores a single value (what the current year is) the badges will display the current year.
  • Loading branch information
Adam Levin authored and codenprose committed Jun 7, 2019
1 parent 7744051 commit 8f7f449
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/api/models/Badge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from api.models import Quiz
from api.models.Year import Year

# this file and the classes in it do not correspond to a table in the Database

Expand All @@ -20,14 +21,16 @@ def can_receive(self, user, quiz_result):
return user.progress >= self.quantity

def serialize_to_json(self):
if len(Year.query.all()) == 0:
raise ValueError("Year not initialized")
return {
"id": self.id,
"title": self.title,
"progress_text": self.progress_text,
"description": self.description,
"congrats_text": self.congrats_text,
"graphic": self.graphic,
"year": 2018, # if we get a table in to track current year we need to use that
"year": Year.query.get(1).year,
}


Expand Down

0 comments on commit 8f7f449

Please sign in to comment.