1.3.2 send_mail_for_user_subscribes_that_is_going_to_finish
This commit is contained in:
48
GeneralApp/management/commands/every_1hour_start.py
Normal file
48
GeneralApp/management/commands/every_1hour_start.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from datetime import datetime
|
||||
from BaseModels.mailSender import techSendMail
|
||||
from ...funcs_options import get_options_by_opt_types, get_mail_send_options
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
mail_sets = get_mail_send_options()
|
||||
|
||||
log = ''
|
||||
log_begin_DT = datetime.now()
|
||||
msg = str(log_begin_DT)
|
||||
print('-------------')
|
||||
print(msg)
|
||||
|
||||
try:
|
||||
from RoutesApp.search_matches import search_matches
|
||||
msg = search_matches()
|
||||
if msg:
|
||||
print(msg)
|
||||
log += f'\n{msg}'
|
||||
except Exception as e:
|
||||
msg = f'every_1hour_start search_matches fail = {str(e)}'
|
||||
print(msg)
|
||||
techSendMail(mail_sets, msg, title='every_1hour_start search_matches')
|
||||
|
||||
|
||||
if datetime.now().hour == 19:
|
||||
try:
|
||||
from SubscribesApp.reports import send_mail_for_user_subscribes_that_is_going_to_finish
|
||||
msg = send_mail_for_user_subscribes_that_is_going_to_finish()
|
||||
if msg:
|
||||
print(msg)
|
||||
log += f'\n{msg}'
|
||||
except Exception as e:
|
||||
msg = f'send_mail_for_user_subscribes_that_is_going_to_finish search_matches fail = {str(e)}'
|
||||
print(msg)
|
||||
techSendMail(mail_sets, msg, title='every_1hour_start send_mail_for_user_subscribes_that_is_going_to_finish')
|
||||
|
||||
if log:
|
||||
techSendMail(mail_sets, str(msg), title='every_1hour_start get_competitors_prices')
|
||||
|
||||
|
||||
|
||||
print(f'- processing time = {str(datetime.now() - log_begin_DT)} -')
|
||||
|
||||
|
||||
@@ -22,65 +22,9 @@ def test_code(request):
|
||||
|
||||
res = None
|
||||
|
||||
# import allauth
|
||||
# from allauth.socialaccount.models import SocialApp
|
||||
# apps = SocialApp.objects.all()
|
||||
# apps.delete()
|
||||
from SubscribesApp.reports import send_mail_for_user_subscribes_that_is_going_to_finish
|
||||
send_mail_for_user_subscribes_that_is_going_to_finish()
|
||||
|
||||
# from PushMessages.views import send_push
|
||||
# send_push(request.user, 'test_title', 'test_content')
|
||||
|
||||
# from BaseModels.pay_systems.DVL_Group_kaz.api.funcs import create_order
|
||||
# create_order()
|
||||
|
||||
# from AuthApp.models import User
|
||||
# from SubscribesApp.models import SubscribeForUser, Subscribe
|
||||
# subscribes_null_price = Subscribe.objects.filter(price=0)
|
||||
# if not subscribes_null_price:
|
||||
# res = 'Subscribe not found'
|
||||
# else:
|
||||
# subscribe = subscribes_null_price[0]
|
||||
# users_wo_subscribe = User.objects.filter(rel_userSubscribes_for_user=None)
|
||||
# for user in users_wo_subscribe:
|
||||
# u_sub = SubscribeForUser.objects.create(
|
||||
# user=user,
|
||||
# subscribe=subscribe,
|
||||
# paid_period_from_DT=datetime.now(),
|
||||
# paid_period_to_DT=datetime.now() + timedelta(hours=subscribe.period)
|
||||
# )
|
||||
|
||||
# from RoutesApp.search_matches import search_matches
|
||||
# search_matches()
|
||||
|
||||
# try:
|
||||
# # body = request.body
|
||||
# # data = json.loads(body)
|
||||
# # if 'head' not in data or 'body' not in data or 'id' not in data:
|
||||
# # return JsonResponse(status=400, data={"message": "Invalid data format"})
|
||||
# # user_id = data['id']
|
||||
# user = request.user
|
||||
# payload = {'head': '123', 'body': 'qwerty'}
|
||||
# send_user_notification(user=user, payload=payload, ttl=1000)
|
||||
# return JsonResponse(status=200, data={"message": "Web push successful"})
|
||||
# except TypeError:
|
||||
# return JsonResponse(status=500, data={"message": "An error occurred"})
|
||||
|
||||
# routes = Route.objects.all()
|
||||
#
|
||||
# for route in routes:
|
||||
# print(route.id)
|
||||
# required_save = False
|
||||
# if not route.from_city:
|
||||
# route.from_city = get_city_by_type_transport_and_address_point(route.type_transport, route.from_address_point)
|
||||
# required_save = True
|
||||
#
|
||||
# if not route.to_city:
|
||||
# route.to_city = get_city_by_type_transport_and_address_point(route.type_transport,
|
||||
# route.to_address_point)
|
||||
# required_save = True
|
||||
#
|
||||
# if required_save:
|
||||
# route.save()
|
||||
if res:
|
||||
if type(res) == str:
|
||||
return HttpResponse(res)
|
||||
|
||||
Reference in New Issue
Block a user