mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2025-06-28 16:15:44 +08:00
Move to using inline todos, update .dockerignore, and remove duplicate timezone records in seed data
This commit is contained in:
parent
b024a74364
commit
f7b949a45e
7 changed files with 40 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from config.settings import ROOT_DIR, SEED_DATA, get_secret
|
||||
from config.settings import ROOT_DIR, SEED_DATA, TIME_ZONE, get_secret
|
||||
from django.db.models.signals import post_migrate
|
||||
from django.dispatch import receiver
|
||||
from django_celery_beat.models import CrontabSchedule, PeriodicTask
|
||||
|
@ -64,7 +64,7 @@ def create_celery_beat_schedules(sender, **kwargs):
|
|||
day_of_week=schedule["day_of_week"],
|
||||
day_of_month=schedule["day_of_month"],
|
||||
month_of_year=schedule["month_of_year"],
|
||||
timezone=schedule["timezone"],
|
||||
timezone=TIME_ZONE,
|
||||
).first()
|
||||
# If it does not exist, create a new Schedule
|
||||
if not SCHEDULE:
|
||||
|
@ -74,14 +74,16 @@ def create_celery_beat_schedules(sender, **kwargs):
|
|||
day_of_week=schedule["day_of_week"],
|
||||
day_of_month=schedule["day_of_month"],
|
||||
month_of_year=schedule["month_of_year"],
|
||||
timezone=schedule["timezone"],
|
||||
timezone=TIME_ZONE,
|
||||
)
|
||||
print(
|
||||
f"Created Crontab Schedule for Hour:{SCHEDULE.hour},Minute:{SCHEDULE.minute}"
|
||||
f"Created Crontab Schedule for Hour:{
|
||||
SCHEDULE.hour},Minute:{SCHEDULE.minute}"
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f"Crontab Schedule for Hour:{SCHEDULE.hour},Minute:{SCHEDULE.minute} already exists"
|
||||
f"Crontab Schedule for Hour:{SCHEDULE.hour},Minute:{
|
||||
SCHEDULE.minute} already exists"
|
||||
)
|
||||
for task in seed_data["scheduled_tasks"]:
|
||||
TASK = PeriodicTask.objects.filter(name=task["name"]).first()
|
||||
|
@ -93,7 +95,7 @@ def create_celery_beat_schedules(sender, **kwargs):
|
|||
day_of_week=task["schedule"]["day_of_week"],
|
||||
day_of_month=task["schedule"]["day_of_month"],
|
||||
month_of_year=task["schedule"]["month_of_year"],
|
||||
timezone=task["schedule"]["timezone"],
|
||||
timezone=TIME_ZONE,
|
||||
).first()
|
||||
TASK = PeriodicTask.objects.create(
|
||||
crontab=SCHEDULE,
|
||||
|
|
|
@ -41,7 +41,8 @@ class CustomUserViewSet(DjoserUserViewSet):
|
|||
key = f"usergroup_users:{user.user_group.id}"
|
||||
queryset = cache.get(key)
|
||||
if not queryset:
|
||||
queryset = CustomUser.objects.filter(user_group=user.user_group)
|
||||
queryset = CustomUser.objects.filter(
|
||||
user_group=user.user_group)
|
||||
cache.set(key, queryset, 60 * 60)
|
||||
return queryset
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue