summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/daily/retriever.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/app/daily/retriever.py b/app/daily/retriever.py
index d2e5464..3b7da87 100644
--- a/app/daily/retriever.py
+++ b/app/daily/retriever.py
@@ -4,16 +4,21 @@ import json
from django.utils import timezone
from django.template.loader import render_to_string
+from django.contrib.auth.models import User
+from django.db.models import Q
from .models import CheckIn, Daily, Weather
def create_daily():
- d, created = Daily.objects.get_or_create(
- date=timezone.now()
- )
- if not created:
- print("already existed")
+ users = User.objects.filter(Q(username="luxagraf") | Q(username="corrinne"))
+ for user in users:
+ d, created = Daily.objects.get_or_create(
+ user=user,
+ date=timezone.now()
+ )
+ if not created:
+ print("already existed")
def get_yesterday_weather():
@@ -41,7 +46,8 @@ def get_yesterday_weather():
hail=int(data['hail']),
thunder=int(data['thunder']),
)
- d = Daily.objects.get(date=dt)
- d.weather = w
- d.weather_human = render_to_string('human_weather.txt', {'object': w}).strip()
- d.save()
+ dailies = Daily.objects.filter(date=dt)
+ for d in dailies:
+ d.weather = w
+ d.weather_human = render_to_string('human_weather.txt', {'object': w}).strip()
+ d.save()