Compare commits
5 Commits
6043e1f5a7
...
feature/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15c9d589fe | ||
|
|
fa116c08c1 | ||
|
|
4f9129e718 | ||
|
|
df45f3a704 | ||
|
|
90ef093fca |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -414,4 +414,5 @@ fabric.properties
|
|||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
celerybeat-schedule.db
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ def get_articles_block_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST.dict()
|
data = request.POST.dict()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from django.core.files import File
|
|||||||
import base64
|
import base64
|
||||||
from django.core.validators import validate_email
|
from django.core.validators import validate_email
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
|
|
||||||
# @login_required(login_url='/profile/login/')
|
# @login_required(login_url='/profile/login/')
|
||||||
# def subscribe_ajax(request):
|
# def subscribe_ajax(request):
|
||||||
@@ -36,8 +36,6 @@ def mailing_subscribe_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
email = request.POST['email']
|
email = request.POST['email']
|
||||||
@@ -82,8 +80,6 @@ def send_message_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
@@ -216,8 +212,6 @@ def chats_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
from ChatServiceApp.funcs import get_chat_receivers_for_user, get_msgs_for_chat_w_users
|
from ChatServiceApp.funcs import get_chat_receivers_for_user, get_msgs_for_chat_w_users
|
||||||
|
|
||||||
receivers, unread_msgs_count = get_chat_receivers_for_user(request.user)
|
receivers, unread_msgs_count = get_chat_receivers_for_user(request.user)
|
||||||
@@ -248,8 +242,6 @@ def support_tickets_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
html = get_profile_support_page_content_html(request)
|
html = get_profile_support_page_content_html(request)
|
||||||
|
|
||||||
return JsonResponse({'html': html}, status=200)
|
return JsonResponse({'html': html}, status=200)
|
||||||
@@ -263,8 +255,6 @@ def change_avatar_confirm_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
file_data = json.loads(request.body)
|
file_data = json.loads(request.body)
|
||||||
@@ -291,8 +281,6 @@ def change_profile_confirm_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
if not data:
|
if not data:
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -366,8 +354,6 @@ def dashboard_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
from .funcs import get_dashboard_page_content_html
|
from .funcs import get_dashboard_page_content_html
|
||||||
@@ -386,7 +372,6 @@ def change_profile_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
html = get_profile_change_page_content_html(request)
|
html = get_profile_change_page_content_html(request)
|
||||||
return JsonResponse({'html': html}, status=200)
|
return JsonResponse({'html': html}, status=200)
|
||||||
@@ -397,8 +382,6 @@ def my_routes_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,8 +396,6 @@ def login_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
@@ -502,9 +483,6 @@ def registration_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ def get_file_from_msg_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -52,9 +49,6 @@ def show_chat_w_user_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -80,9 +74,6 @@ def update_chat_ajax2(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
res_Dict = {}
|
res_Dict = {}
|
||||||
msgs = []
|
msgs = []
|
||||||
Dict = {}
|
Dict = {}
|
||||||
@@ -172,9 +163,6 @@ def update_chat_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
res_Dict = {}
|
res_Dict = {}
|
||||||
msgs = []
|
msgs = []
|
||||||
Dict = {}
|
Dict = {}
|
||||||
@@ -393,9 +381,6 @@ def support_show_chat_by_ticket_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -449,8 +434,6 @@ def support_create_ticket_form_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
'form': TicketForm()
|
'form': TicketForm()
|
||||||
@@ -471,9 +454,6 @@ def create_ticket_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Admin_StaticPage(Admin_Trans_BaseModelViewPage):
|
|||||||
if request.user.is_superuser:
|
if request.user.is_superuser:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not obj or obj.url in ('main', 'works'):
|
if obj.url in ('main', 'spec_technics', 'works'):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
admin.site.register(StaticPage,Admin_StaticPage)
|
admin.site.register(StaticPage,Admin_StaticPage)
|
||||||
|
|||||||
@@ -1,29 +1,6 @@
|
|||||||
from django.http import HttpResponse, Http404, FileResponse
|
from django.http import HttpResponse, Http404, FileResponse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
def get_and_set_lang(request):
|
|
||||||
from django.utils.translation import activate, get_language
|
|
||||||
lang = None
|
|
||||||
|
|
||||||
referer_url = request.META.get('HTTP_REFERER')
|
|
||||||
if referer_url:
|
|
||||||
url_list = referer_url.split('//')
|
|
||||||
if len(url_list) > 1:
|
|
||||||
url_list = url_list[1].split('/')
|
|
||||||
if len(url_list) > 1 and url_list[1] in settings.MODELTRANSLATION_LANGUAGES:
|
|
||||||
lang = url_list[1]
|
|
||||||
|
|
||||||
if not lang:
|
|
||||||
lang = get_language()
|
|
||||||
|
|
||||||
if not lang:
|
|
||||||
lang = 'en'
|
|
||||||
|
|
||||||
return activate(lang)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_inter_Dict(user):
|
def get_inter_Dict(user):
|
||||||
|
|
||||||
from SubscribesApp.funcs import get_cur_user_subscribe
|
from SubscribesApp.funcs import get_cur_user_subscribe
|
||||||
|
|||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
celery -A TWB.celery:app worker -l info
|
||||||
|
|
||||||
|
celery -A TWB.celery:app beat -l info
|
||||||
@@ -14,7 +14,6 @@ from django.urls import reverse
|
|||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
import json
|
import json
|
||||||
from GeneralApp.funcs import get_inter_http_respose
|
from GeneralApp.funcs import get_inter_http_respose
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
|
|
||||||
def get_address_point_ajax(request):
|
def get_address_point_ajax(request):
|
||||||
from .funcs import search_cities_in_db, search_airports_in_db
|
from .funcs import search_cities_in_db, search_airports_in_db
|
||||||
@@ -22,9 +21,6 @@ def get_address_point_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|||||||
@@ -15,16 +15,12 @@ from django.template.loader import render_to_string
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from .forms import *
|
from .forms import *
|
||||||
from .funcs import *
|
from .funcs import *
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def del_route_ajax(request):
|
def del_route_ajax(request):
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -58,8 +54,6 @@ def edit_route_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|
||||||
Dict = {}
|
Dict = {}
|
||||||
@@ -105,8 +99,6 @@ def new_route_view_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
# form = RouteForm()
|
# form = RouteForm()
|
||||||
# Dict = {
|
# Dict = {
|
||||||
# 'form': form
|
# 'form': form
|
||||||
@@ -140,8 +132,6 @@ def find_routes_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
|
||||||
@@ -185,8 +175,6 @@ def get_my_routes_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
routes_Dict = get_routes_Dict(request.user)
|
routes_Dict = get_routes_Dict(request.user)
|
||||||
if 'errors' in routes_Dict:
|
if 'errors' in routes_Dict:
|
||||||
@@ -218,8 +206,6 @@ def create_or_change_route_ajax(request, route_id=None):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
Dict = {}
|
Dict = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from .models import *
|
from .models import *
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.translation import get_language, activate
|
|
||||||
|
|
||||||
def get_cur_user_subscribe(user):
|
def get_cur_user_subscribe(user):
|
||||||
|
|
||||||
@@ -27,9 +26,6 @@ def get_profile_subscribe_page_content_html(request):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
# data = json.loads(request.body)
|
# data = json.loads(request.body)
|
||||||
# all_options = SubscribeOption.objects.filter(enable=True)
|
# all_options = SubscribeOption.objects.filter(enable=True)
|
||||||
subscribes, all_options = get_subsribes_w_options()
|
subscribes, all_options = get_subsribes_w_options()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import json
|
|||||||
from datetime import datetime, time, timedelta
|
from datetime import datetime, time, timedelta
|
||||||
from channels.layers import get_channel_layer
|
from channels.layers import get_channel_layer
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
from GeneralApp.funcs import get_and_set_lang
|
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url='/profile/login/')
|
@login_required(login_url='/profile/login/')
|
||||||
@@ -25,8 +25,6 @@ def subscribe_now_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
@@ -79,8 +77,6 @@ def show_cur_subscribe_ajax(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
lang = get_and_set_lang(request)
|
|
||||||
|
|
||||||
html = get_profile_subscribe_page_content_html(request)
|
html = get_profile_subscribe_page_content_html(request)
|
||||||
return JsonResponse({'html': html}, status=200)
|
return JsonResponse({'html': html}, status=200)
|
||||||
|
|
||||||
|
|||||||
7
SubscribesApp/serializers.py
Normal file
7
SubscribesApp/serializers.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
class SubscribersSerializer(serializers.Serializer):
|
||||||
|
email = serializers.EmailField(error_messages={'invalid': 'Invalid email'})
|
||||||
|
email_notification = serializers.BooleanField()
|
||||||
|
auto_subscribe = serializers.BooleanField()
|
||||||
9
SubscribesApp/urls.py
Normal file
9
SubscribesApp/urls.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from SubscribesApp.views import SubscribersView
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
|
||||||
|
path('auto-subscribe/', SubscribersView.as_view(), name='auto_subscribe'),
|
||||||
|
|
||||||
|
]
|
||||||
@@ -1,3 +1,43 @@
|
|||||||
from django.shortcuts import render
|
from django.contrib.auth.models import User
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from rest_framework import status
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
# Create your views here.
|
from SubscribesApp.models import SubscribeForUser
|
||||||
|
from SubscribesApp.serializers import SubscribersSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class SubscribersView(APIView):
|
||||||
|
# permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
serializer = SubscribersSerializer(data=request.data)
|
||||||
|
|
||||||
|
if serializer.is_valid():
|
||||||
|
validated_data = serializer.validated_data
|
||||||
|
email = validated_data['email']
|
||||||
|
email_notification = validated_data['email_notification']
|
||||||
|
auto_subscribe = validated_data['auto_subscribe']
|
||||||
|
|
||||||
|
user = User.objects.filter(email=email)
|
||||||
|
|
||||||
|
if user:
|
||||||
|
|
||||||
|
subscribe_for_user = SubscribeForUser.objects.filter(user_id=user[0].id)
|
||||||
|
|
||||||
|
if email_notification:
|
||||||
|
subscribe_for_user.update(receive_finish_subscribe_msg=True)
|
||||||
|
else:
|
||||||
|
subscribe_for_user.update(receive_finish_subscribe_msg=False)
|
||||||
|
|
||||||
|
if auto_subscribe:
|
||||||
|
subscribe_for_user.update(auto_continue=True)
|
||||||
|
else:
|
||||||
|
subscribe_for_user.update(auto_continue=False)
|
||||||
|
|
||||||
|
return JsonResponse({"message": "Subscriptions updated successfully"}, status=status.HTTP_200_OK)
|
||||||
|
else:
|
||||||
|
return JsonResponse({"message": "User not found"}, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
else:
|
||||||
|
return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
27
TWB/celery.py
Executable file
27
TWB/celery.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from celery import Celery
|
||||||
|
from celery.schedules import crontab
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "TWB.settings")
|
||||||
|
|
||||||
|
app = Celery('bo', include=['TWB.tasks'])
|
||||||
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||||
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||||
|
|
||||||
|
app.conf.beat_schedule = {
|
||||||
|
'update-currency-rates': {
|
||||||
|
'task': 'TWB.tasks.check_auto_subscribe',
|
||||||
|
'schedule': crontab(minute=0, hour='*/1'),
|
||||||
|
},
|
||||||
|
'subscription_expiration_check': {
|
||||||
|
'task': 'TWB.tasks.subscription_expiration_check',
|
||||||
|
'schedule': crontab(hour=0, minute=0),
|
||||||
|
# 'schedule': crontab(minute='*', hour='*'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
app.conf.broker_url = settings.CELERY_BROKER_URL
|
||||||
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from decouple import config
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -60,7 +61,6 @@ AUTHENTICATION_BACKENDS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SOCIALACCOUNT_PROVIDERS = {
|
SOCIALACCOUNT_PROVIDERS = {
|
||||||
'google': {
|
'google': {
|
||||||
'SCOPE': [
|
'SCOPE': [
|
||||||
@@ -172,11 +172,8 @@ CHANNEL_LAYERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
POSTGRES_DB = config('POSTGRES_DB')
|
||||||
|
POSTGRES_USER = config('POSTGRES_USER')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
@@ -185,8 +182,8 @@ CHANNEL_LAYERS = {
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': 'twbDB',
|
'NAME': POSTGRES_DB,
|
||||||
'USER': 'test_user',
|
'USER': POSTGRES_USER,
|
||||||
'PASSWORD': 'test_db_pass',
|
'PASSWORD': 'test_db_pass',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '5432',
|
'PORT': '5432',
|
||||||
@@ -336,6 +333,16 @@ CKEDITOR_CONFIGS = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CELERY_BROKER_URL = config('CELERY_BROKER_URL')
|
||||||
|
CELERY_RESULT_BACKEND = config('CELERY_RESULT_BACKEND')
|
||||||
|
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
EMAIL_HOST = 'smtp.gmail.com'
|
||||||
|
EMAIL_USE_TLS = True
|
||||||
|
EMAIL_PORT = 587
|
||||||
|
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
|
||||||
|
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
|
||||||
|
|
||||||
|
|
||||||
# CKEDITOR_OPTIONS = {
|
# CKEDITOR_OPTIONS = {
|
||||||
# 'height': 291,
|
# 'height': 291,
|
||||||
|
|||||||
40
TWB/tasks.py
Normal file
40
TWB/tasks.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
from SubscribesApp.models import SubscribeForUser
|
||||||
|
from TWB import settings
|
||||||
|
from TWB.celery import app
|
||||||
|
from django.core.mail import send_mail
|
||||||
|
|
||||||
|
|
||||||
|
@app.task
|
||||||
|
def check_auto_subscribe():
|
||||||
|
current_time = datetime.now()
|
||||||
|
subscribes = SubscribeForUser.objects.filter(auto_continue=True)
|
||||||
|
if subscribes:
|
||||||
|
for subscribe in subscribes:
|
||||||
|
if subscribe.paid_period_to_DT and subscribe.paid_period_to_DT <= current_time + timedelta(hours=1):
|
||||||
|
user_email = subscribe.user.email
|
||||||
|
subject = 'Подписка продлена!'
|
||||||
|
message = 'Ваша подписка успешно продлена!'
|
||||||
|
send_mail(subject, message, settings.EMAIL_HOST_USER, [user_email], fail_silently=False)
|
||||||
|
else:
|
||||||
|
print('Нету подписок')
|
||||||
|
|
||||||
|
|
||||||
|
@app.task
|
||||||
|
def subscription_expiration_check():
|
||||||
|
current_time = datetime.now()
|
||||||
|
subscribes = SubscribeForUser.objects.filter(paid_period_to_DT__gte=current_time)
|
||||||
|
if subscribes:
|
||||||
|
for subscribe in subscribes:
|
||||||
|
expiration_date = subscribe.paid_period_to_DT
|
||||||
|
remaining_days = (expiration_date - current_time).days
|
||||||
|
|
||||||
|
if remaining_days <= 7:
|
||||||
|
message = f'Ваша подписка заканчивается через {remaining_days} дня. Пожалуйста, продлите её.'
|
||||||
|
|
||||||
|
user_email = subscribe.user.email
|
||||||
|
subject = 'Подписка истекает!'
|
||||||
|
send_mail(subject, message, settings.EMAIL_HOST_USER, [user_email], fail_silently=False)
|
||||||
|
else:
|
||||||
|
print('Нету подписок')
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
@@ -9,7 +8,6 @@ from AuthApp.views import login_View
|
|||||||
handler404 = Page404
|
handler404 = Page404
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('admin/', admin.site.urls),
|
|
||||||
path('ckeditor/', include('ckeditor_uploader.urls')),
|
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
|
|
||||||
@@ -39,7 +37,9 @@ urlpatterns = [
|
|||||||
|
|
||||||
path('test_404', Page404, name='page_404'),
|
path('test_404', Page404, name='page_404'),
|
||||||
|
|
||||||
path('', include('PushMessages.urls'))
|
path('', include('PushMessages.urls')),
|
||||||
|
path('', include('SubscribesApp.urls')),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
from django.conf.urls.i18n import i18n_patterns
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
|
|||||||
8
env.sample
Normal file
8
env.sample
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
EMAIL_HOST_USER=
|
||||||
|
EMAIL_HOST_PASSWORD=
|
||||||
|
|
||||||
|
POSTGRES_DB=
|
||||||
|
POSTGRES_USER=
|
||||||
|
|
||||||
|
CELERY_BROKER_URL=
|
||||||
|
CELERY_RESULT_BACKEND=
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@ Django==4.2.2
|
|||||||
django-ckeditor==6.5.1
|
django-ckeditor==6.5.1
|
||||||
psycopg2-binary==2.9.6
|
psycopg2-binary==2.9.6
|
||||||
requests
|
requests
|
||||||
Pillow==9.5.0
|
|
||||||
django-modeltranslation==0.18.10
|
django-modeltranslation==0.18.10
|
||||||
overpass
|
overpass
|
||||||
geopy
|
geopy
|
||||||
@@ -13,5 +12,6 @@ django-colorfield
|
|||||||
django-webpush==0.3.5
|
django-webpush==0.3.5
|
||||||
django-allauth==0.60.0
|
django-allauth==0.60.0
|
||||||
pytz==2024.1
|
pytz==2024.1
|
||||||
#django-tz-detect==0.4.0
|
celery==5.3.6
|
||||||
|
djangorestframework==3.14.0
|
||||||
|
python-decouple==3.8
|
||||||
|
|||||||
@@ -121,10 +121,6 @@
|
|||||||
width: 70%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown{
|
|
||||||
vertical-align: sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
.handler_curtain_left{
|
.handler_curtain_left{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -140,10 +136,6 @@
|
|||||||
transition: 200ms;
|
transition: 200ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unsubscribe_info {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container_content_handler_curtain_left{
|
.container_content_handler_curtain_left{
|
||||||
display: flex;
|
display: flex;
|
||||||
rotate: 90deg;
|
rotate: 90deg;
|
||||||
@@ -262,7 +254,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
header{
|
header{
|
||||||
padding: 3px 16px;
|
padding: 5px 16px;
|
||||||
margin-top: unset;
|
margin-top: unset;
|
||||||
}
|
}
|
||||||
.header_logo, .header_btn_mover, .header_btn_sender{
|
.header_logo, .header_btn_mover, .header_btn_sender{
|
||||||
@@ -394,14 +386,11 @@
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
.header_logo_mobile {
|
.header_logo_mobile {
|
||||||
margin-right: 20px;
|
margin-right: 37px;
|
||||||
}
|
}
|
||||||
.line_f_header{
|
.line_f_header{
|
||||||
top: 43px;
|
top: 43px;
|
||||||
}
|
}
|
||||||
header .header-second{
|
|
||||||
margin-top: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.self_news_img{
|
.self_news_img{
|
||||||
width: 40%;
|
width: 40%;
|
||||||
@@ -506,8 +495,6 @@
|
|||||||
.footer_logo{
|
.footer_logo{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 40px 0;
|
margin: 40px 0;
|
||||||
max-width: 90px;
|
|
||||||
margin-left: 43%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer_text_sub{
|
.footer_text_sub{
|
||||||
|
|||||||
@@ -2201,7 +2201,7 @@ a.open_inf_carrier{
|
|||||||
height: 1px;
|
height: 1px;
|
||||||
background: #dad7d7;
|
background: #dad7d7;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 100px;
|
top: 60px;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,8 +299,7 @@ section.register>h1 {
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.footer_logo{
|
.footer_logo{
|
||||||
margin-bottom: 20px;
|
margin-bottom: 40px;
|
||||||
max-width: 45px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
footer>div {
|
footer>div {
|
||||||
@@ -503,12 +502,10 @@ footer>div {
|
|||||||
|
|
||||||
header .header-first {
|
header .header-first {
|
||||||
float: left;
|
float: left;
|
||||||
/*margin-top: 12px;*/
|
margin-top: 12px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.header_logo_mobile{
|
.header_logo_mobile{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -666,7 +663,6 @@ header>div>a>span{
|
|||||||
|
|
||||||
header .header-second {
|
header .header-second {
|
||||||
float: right;
|
float: right;
|
||||||
margin-top: 20px;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2624,17 +2620,6 @@ button#send_feedback_form:active{
|
|||||||
/* display: block;*/
|
/* display: block;*/
|
||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
.unsubscribe_info {
|
|
||||||
color: #27242499;
|
|
||||||
font-size: 12px;
|
|
||||||
margin-top: 5px;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.tab-btn-1,
|
.tab-btn-1,
|
||||||
.tab-btn-2 {
|
.tab-btn-2 {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB |
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 2.8 KiB |
@@ -6,12 +6,10 @@ function update_count_unread_messages (data) {
|
|||||||
let list_unrd_parent = document.querySelectorAll(".icon_unread_messages")
|
let list_unrd_parent = document.querySelectorAll(".icon_unread_messages")
|
||||||
let i = 0
|
let i = 0
|
||||||
for (i;i < list_unrd.length;i++){
|
for (i;i < list_unrd.length;i++){
|
||||||
|
|
||||||
if (!list_unrd_parent[i].classList.contains("showed")){
|
if (!list_unrd_parent[i].classList.contains("showed")){
|
||||||
list_unrd_parent[i].classList.toggle("showed")
|
list_unrd_parent[i].classList.toggle("showed")
|
||||||
|
|
||||||
list_unrd[i].innerHTML = data.unread_msgs_count.toString()
|
|
||||||
}
|
}
|
||||||
|
list_unrd[i].innerHTML = data.unread_msgs_count.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,15 +78,15 @@
|
|||||||
<div class="sf_1_column">Copyright © 2023. {% trans "Все права защищены." %}</div>
|
<div class="sf_1_column">Copyright © 2023. {% trans "Все права защищены." %}</div>
|
||||||
|
|
||||||
<div class="sf_2_column">
|
<div class="sf_2_column">
|
||||||
<a href="/{{ request.LANGUAGE_CODE }}/info_page/publichnaya-oferta/">{% trans "Публичная оферта" %}</a>
|
<a href="/ru/info_page/publichnaya-oferta/">{% trans "Публичная оферта" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sf_3_column">
|
<div class="sf_3_column">
|
||||||
<a href="/{{ request.LANGUAGE_CODE }}/info_page/politika-konfidencialnosti/">{% trans "Политика конфиденциальности" %}</a>
|
<a href="/ru/info_page/politika-konfidencialnosti/">{% trans "Политика конфиденциальности" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sf_4_column">
|
<div class="sf_4_column">
|
||||||
<a href="/{{ request.LANGUAGE_CODE }}/info_page/pravila-polzovaniya-servisom/">{% trans "Правила пользования сервисом" %}</a>
|
<a href="/ru/info_page/pravila-polzovaniya-servisom/">{% trans "Правила пользования сервисом" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
<div class="header-first">
|
<div class="header-first">
|
||||||
<div class="header_logo">
|
<div class="header_logo">
|
||||||
<a href="{% url 'main' %}">
|
<a href="{% url 'main' %}">
|
||||||
<img class="svg" src="/static/img/png/finlogo.png" style="height: 90px;">
|
<img class="svg" src="/static/img/svg/Logo.svg">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="header_logo_mobile">
|
<div class="header_logo_mobile">
|
||||||
{# <a href="/"><img class="svg" src="/static/img/svg/LogoMobile.svg"></a>#}
|
{# <a href="/"><img class="svg" src="/static/img/svg/LogoMobile.svg"></a>#}
|
||||||
<a href="{% url 'main' %}"><img class="svg" src="/static/img/png/finlogo.png" style="height: 30px;"></a>
|
<a href="{% url 'main' %}"><img class="svg" src="/static/img/svg/LogoMobile.svg"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<button class="confirm_profile_btn" onclick="change_profile_confirm(this)">
|
<button class="confirm_profile_btn" onclick="change_profile_confirm(this)">
|
||||||
<p id="save_changes_txt">
|
<p id="save_changes_txt">
|
||||||
{% translate "Сохранить" %}
|
{% translate "Сохарнить" %}
|
||||||
</p>
|
</p>
|
||||||
<p id="changes_saved_txt">
|
<p id="changes_saved_txt">
|
||||||
{% translate "Изменения сохранены" %}
|
{% translate "Изменения сохранены" %}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
<div class="title_subscribe">{% translate "Ваш тарифный план" %}</div>
|
<div class="title_subscribe">{% translate "Ваш тарифный план" %}</div>
|
||||||
<div class="name_subscribe">{{ subscribe_for_user.subscribe.name }}</div>
|
<div class="name_subscribe">{{ subscribe_for_user.subscribe.name }}</div>
|
||||||
<button class="extend_subscribe_btn">{% translate "Продлить" %}</button>
|
<button class="extend_subscribe_btn">{% translate "Продлить" %}</button>
|
||||||
<div class="unsubscribe_info">*{% translate "для отмены подписки создайте запрос в техподдерже" %}</div>
|
|
||||||
<div class="subscribe_was_paid">{% translate "оплачен до:" %} {{ subscribe_for_user.paid_period_to_DT|date:"d.m.y" }}</div>
|
<div class="subscribe_was_paid">{% translate "оплачен до:" %} {{ subscribe_for_user.paid_period_to_DT|date:"d.m.y" }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrapper_switch_cont">
|
<div class="wrapper_switch_cont">
|
||||||
|
|||||||
@@ -55,8 +55,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-align-center">
|
<div class="text-align-center">
|
||||||
<button onclick="send_subscribe({{ subscribe.id }})" class="arrange_subscribe">{% translate "Оформить подписку" %}</button>
|
<button onclick="send_subscribe({{ subscribe.id }})" class="arrange_subscribe">{% translate "Оформить подписку" %}</button>
|
||||||
<div class="unsubscribe_info">*{% translate "для отмены подписки создайте запрос в техподдерже" %}</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
<div class="form_wrapper">
|
<div class="form_wrapper">
|
||||||
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
||||||
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи!</span>{% endblocktrans %}</div>
|
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи</span>!{% endblocktrans %}</div>
|
||||||
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
||||||
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи!</span>{% endblocktrans %}</div>
|
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи</span>!{% endblocktrans %}</div>
|
||||||
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
{% if page.url == 'contacts' or page.url == 'about_service' %}
|
||||||
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи!</span>{% endblocktrans %}</div>
|
<div id=title_static>{% blocktrans %}Мы всегда на <span class="color_title">связи</span>!{% endblocktrans %}</div>
|
||||||
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
<span id="sub_title_static">{% translate "У вас есть вопрос? Отправьте нам сообщение" %}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<h2 id="title_static">{% translate "О сервисе Trip With Bonus" %}</h2>
|
<h2 id="title_static">{% translate "О сервисе Trip With Bonus" %}</h2>
|
||||||
<span id="sub_title_static">
|
<span id="sub_title_static">
|
||||||
<p>
|
<p>
|
||||||
{% translate "TripWithBonus — это сервис, созданный для того, чтобы отправитель и перевозчик нашли друг-друга!" %}
|
{% translate "TWB — это сервис, созданный для того, чтобы отправитель и перевозчик нашли друг-друга!" %}
|
||||||
{% translate "Наш сервис предлагает вам прямые контакты, а не является посредником!" %}
|
{% translate "Наш сервис предлагает вам прямые контакты, а не является посредником!" %}
|
||||||
</p>
|
</p>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user