Compare commits
8 Commits
feature/su
...
2da7195dd0
| Author | SHA1 | Date | |
|---|---|---|---|
| 2da7195dd0 | |||
| 18f7fedbc2 | |||
| aa93813ba5 | |||
| def3d770ed | |||
| 6b8bcb8ebb | |||
| ff5afe518a | |||
| 6f42251f5f | |||
| 06917078ae |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -414,5 +414,4 @@ 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
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
celery -A TWB.celery:app worker -l info
|
|
||||||
|
|
||||||
celery -A TWB.celery:app beat -l info
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
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()
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
from django.urls import path
|
|
||||||
|
|
||||||
from SubscribesApp.views import SubscribersView
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
|
|
||||||
path('auto-subscribe/', SubscribersView.as_view(), name='auto_subscribe'),
|
|
||||||
|
|
||||||
]
|
|
||||||
@@ -1,43 +1,3 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.shortcuts import render
|
||||||
from django.http import JsonResponse
|
|
||||||
from rest_framework import status
|
|
||||||
from rest_framework.permissions import IsAuthenticated
|
|
||||||
from rest_framework.views import APIView
|
|
||||||
|
|
||||||
from SubscribesApp.models import SubscribeForUser
|
# Create your views here.
|
||||||
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)
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
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,7 +11,6 @@ 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
|
||||||
@@ -61,6 +60,7 @@ AUTHENTICATION_BACKENDS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SOCIALACCOUNT_PROVIDERS = {
|
SOCIALACCOUNT_PROVIDERS = {
|
||||||
'google': {
|
'google': {
|
||||||
'SCOPE': [
|
'SCOPE': [
|
||||||
@@ -172,8 +172,11 @@ CHANNEL_LAYERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POSTGRES_DB = config('POSTGRES_DB')
|
|
||||||
POSTGRES_USER = config('POSTGRES_USER')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
@@ -182,8 +185,8 @@ POSTGRES_USER = config('POSTGRES_USER')
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'NAME': POSTGRES_DB,
|
'NAME': 'twbDB',
|
||||||
'USER': POSTGRES_USER,
|
'USER': 'test_user',
|
||||||
'PASSWORD': 'test_db_pass',
|
'PASSWORD': 'test_db_pass',
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '5432',
|
'PORT': '5432',
|
||||||
@@ -333,16 +336,6 @@ 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
40
TWB/tasks.py
@@ -1,40 +0,0 @@
|
|||||||
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,3 +1,4 @@
|
|||||||
|
|
||||||
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
|
||||||
@@ -8,6 +9,7 @@ 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')),
|
||||||
|
|
||||||
@@ -37,9 +39,7 @@ 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
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
EMAIL_HOST_USER=
|
|
||||||
EMAIL_HOST_PASSWORD=
|
|
||||||
|
|
||||||
POSTGRES_DB=
|
|
||||||
POSTGRES_USER=
|
|
||||||
|
|
||||||
CELERY_BROKER_URL=
|
|
||||||
CELERY_RESULT_BACKEND=
|
|
||||||
@@ -2,6 +2,7 @@ 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
|
||||||
@@ -12,6 +13,5 @@ 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
|
||||||
celery==5.3.6
|
#django-tz-detect==0.4.0
|
||||||
djangorestframework==3.14.0
|
|
||||||
python-decouple==3.8
|
|
||||||
|
|||||||
@@ -121,6 +121,10 @@
|
|||||||
width: 70%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown{
|
||||||
|
vertical-align: sub;
|
||||||
|
}
|
||||||
|
|
||||||
.handler_curtain_left{
|
.handler_curtain_left{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -254,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
header{
|
header{
|
||||||
padding: 5px 16px;
|
padding: 3px 16px;
|
||||||
margin-top: unset;
|
margin-top: unset;
|
||||||
}
|
}
|
||||||
.header_logo, .header_btn_mover, .header_btn_sender{
|
.header_logo, .header_btn_mover, .header_btn_sender{
|
||||||
@@ -386,11 +390,14 @@
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
.header_logo_mobile {
|
.header_logo_mobile {
|
||||||
margin-right: 37px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
.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%;
|
||||||
|
|||||||
@@ -2201,7 +2201,7 @@ a.open_inf_carrier{
|
|||||||
height: 1px;
|
height: 1px;
|
||||||
background: #dad7d7;
|
background: #dad7d7;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 60px;
|
top: 100px;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ footer>div {
|
|||||||
|
|
||||||
header .header-first {
|
header .header-first {
|
||||||
float: left;
|
float: left;
|
||||||
margin-top: 12px;
|
/*margin-top: 12px;*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,6 +663,7 @@ header>div>a>span{
|
|||||||
|
|
||||||
header .header-second {
|
header .header-second {
|
||||||
float: right;
|
float: right;
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
static/img/1234.png
Normal file
BIN
static/img/1234.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
BIN
static/img/png/finlogo.png
Normal file
BIN
static/img/png/finlogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
BIN
static/img/png/new_logo_test.png
Normal file
BIN
static/img/png/new_logo_test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
@@ -6,12 +6,14 @@ 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function play_required_beep (data,beep) {
|
function play_required_beep (data,beep) {
|
||||||
|
|||||||
@@ -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="/ru/info_page/publichnaya-oferta/">{% trans "Публичная оферта" %}</a>
|
<a href="/{{ request.LANGUAGE_CODE }}/info_page/publichnaya-oferta/">{% trans "Публичная оферта" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sf_3_column">
|
<div class="sf_3_column">
|
||||||
<a href="/ru/info_page/politika-konfidencialnosti/">{% trans "Политика конфиденциальности" %}</a>
|
<a href="/{{ request.LANGUAGE_CODE }}/info_page/politika-konfidencialnosti/">{% trans "Политика конфиденциальности" %}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sf_4_column">
|
<div class="sf_4_column">
|
||||||
<a href="/ru/info_page/pravila-polzovaniya-servisom/">{% trans "Правила пользования сервисом" %}</a>
|
<a href="/{{ request.LANGUAGE_CODE }}/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/svg/Logo.svg">
|
<img class="svg" src="/static/img/png/finlogo.png" style="height: 90px;">
|
||||||
</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/svg/LogoMobile.svg"></a>
|
<a href="{% url 'main' %}"><img class="svg" src="/static/img/png/finlogo.png" style="height: 30px;"></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 "Изменения сохранены" %}
|
||||||
|
|||||||
Reference in New Issue
Block a user