Skip to content
Snippets Groups Projects
Commit 025bea19 authored by thomaswoehlke's avatar thomaswoehlke
Browse files

work

parent c571286a
No related branches found
No related tags found
2 merge requests!161Issue 66 attempt 01,!160Issue 66 attempt 01
...@@ -54,11 +54,12 @@ class CommonDateReported(db.Model): ...@@ -54,11 +54,12 @@ class CommonDateReported(db.Model):
def create_new_object_factory(cls, my_date_rep): def create_new_object_factory(cls, my_date_rep):
my_datum = date.fromisoformat(my_date_rep) my_datum = date.fromisoformat(my_date_rep)
(my_iso_year, week_number, weekday) = my_datum.isocalendar() (my_iso_year, week_number, weekday) = my_datum.isocalendar()
my_year_week = "" + str(my_iso_year)
if week_number < 10: if week_number < 10:
my_year_week = "" + str(my_iso_year) + "-0"+str(week_number) my_year_week += "-0"
else: else:
my_year_week = "" + str(my_iso_year) + "-"+str(week_number) my_year_week += "-"
day_of_year = my_datum.timetuple() my_year_week += str(week_number)
return CommonDateReported( return CommonDateReported(
date_reported=my_date_rep, date_reported=my_date_rep,
datum=my_datum, datum=my_datum,
......
from sqlalchemy import and_ from sqlalchemy import and_
from datetime import date
from database import db, ITEMS_PER_PAGE from database import db, ITEMS_PER_PAGE
from covid19.blueprints.common.common_model import CommonDateReported, CommonRegion from covid19.blueprints.common.common_model import CommonDateReported, CommonRegion
...@@ -9,22 +8,8 @@ class EuropeDateReported(CommonDateReported): ...@@ -9,22 +8,8 @@ class EuropeDateReported(CommonDateReported):
@classmethod @classmethod
def create_new_object_factory(cls, my_date_rep): def create_new_object_factory(cls, my_date_rep):
my_datum = date.fromisoformat(my_date_rep) o = CommonDateReported.create_new_object_factory(my_date_rep)
(my_iso_year, week_number, weekday) = my_datum.isocalendar() return EuropeDateReported(o)
if week_number < 10:
my_year_week = "" + str(my_iso_year) + "-0" + str(week_number)
else:
my_year_week = "" + str(my_iso_year) + "-" + str(week_number)
return EuropeDateReported(
date_reported=my_date_rep,
datum=my_datum,
year=my_datum.year,
month=my_datum.month,
day_of_month=my_datum.day,
day_of_week=weekday,
week_of_year=week_number,
year_week=my_year_week
)
class EuropeContinent(CommonRegion): class EuropeContinent(CommonRegion):
......
...@@ -7,6 +7,11 @@ from covid19.blueprints.common.common_model import CommonDateReported, CommonReg ...@@ -7,6 +7,11 @@ from covid19.blueprints.common.common_model import CommonDateReported, CommonReg
class WhoDateReported(CommonDateReported): class WhoDateReported(CommonDateReported):
__mapper_args__ = {'polymorphic_identity': 'who_date_reported'} __mapper_args__ = {'polymorphic_identity': 'who_date_reported'}
@classmethod
def create_new_object_factory(cls, my_date_rep):
o = cls.create_new_object_factory(my_date_rep)
return WhoDateReported(o)
class WhoRegion(CommonRegion): class WhoRegion(CommonRegion):
__mapper_args__ = {'polymorphic_identity': 'who_region'} __mapper_args__ = {'polymorphic_identity': 'who_region'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment