diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 6454291..9d58936 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -415,7 +415,7 @@ def registration_ajax(request): user = User.objects.create_user(username=form.data['email'], email=form.data['email'], password=form.data['password']) # user = auth.authenticate(username=new_user_Dict['name'], password=new_user_Dict['pass']) if user: - auth.login(request, user) + auth.login(request, user, backend='django.contrib.auth.backends.ModelBackend') user.last_name = form.data['lastname'] user.first_name = form.data['firstname'] diff --git a/AuthApp/models.py b/AuthApp/models.py index 7447648..d8fdac9 100644 --- a/AuthApp/models.py +++ b/AuthApp/models.py @@ -74,8 +74,23 @@ class UserProfile(BaseModel): def create_user_profile(sender, instance, created, **kwargs): + user_profile = None if created: - UserProfile.objects.create(user=instance) + user_profile = UserProfile.objects.create(user=instance) + + # if user_profile and not user_profile.avatar: + # from allauth.socialaccount.models import SocialAccount + # # try: + # social_accounts = SocialAccount.objects.filter(user=instance) + # if social_accounts: + # for social_account in social_accounts: + # if 'picture' in social_account.account.extra_data and social_account.account.extra_data['picture']: + # with open(social_account.account.extra_data['picture'], 'rb') as fd: + # user_profile.avatar.save(f'avatar_{instance.id}.jpeg', fd.read(), True) + # + # # except Exception as e: + # # msg = f'post_save create_user_profile Error = {str(e)}' + # # print(msg) post_save.connect(create_user_profile, sender=User, dispatch_uid='post_save_connect') @@ -85,6 +100,7 @@ def preSaveUser(sender, instance, **kwargs): if not instance.email: instance.email = str(instance.username).lower() + try: instance.user_profile.modifiedDT = datetime.now() except: diff --git a/AuthApp/urls.py b/AuthApp/urls.py index 6d627a1..6bb962e 100644 --- a/AuthApp/urls.py +++ b/AuthApp/urls.py @@ -21,6 +21,8 @@ urlpatterns = [ path('login/', login_View, name='login_profile'), path('logout/', logout_View, name='logout_profile'), + path('account/signup/', login_View, name="custom_singup" ), + # ajax ---------------- # url(r'^login$', user_login_View_ajax, name='user_login_View_ajax'), diff --git a/BaseModels/mailSender.py b/BaseModels/mailSender.py index 176f6a7..8b50189 100644 --- a/BaseModels/mailSender.py +++ b/BaseModels/mailSender.py @@ -266,19 +266,22 @@ def techSendMail(sets, html_content, title=None, add_emails=None): # return msg print('techSendMail') + project_name = '' + if 'project_name' in sets: + project_name = sets['project_name'] try: # subject = u'truEnergy Data техническое оповещение' - from_email = 'support@truenergy.by' + from_email = sets['sender_email'] to = ['web@syncsystems.net'] if add_emails: to.extend(add_emails) - text_content = 'Technical message from truEnergy.' + text_content = f'Technical message from {project_name}' if title: subject = title else: - subject = u'truEnergy Data техническое оповещение' + subject = f'{project_name} - техническое оповещение' res = admin_send_mail_by_SMTPlib(sets, subject, from_email, to, html_content) diff --git a/GeneralApp/allauth_funcs.py b/GeneralApp/allauth_funcs.py new file mode 100644 index 0000000..a632c74 --- /dev/null +++ b/GeneralApp/allauth_funcs.py @@ -0,0 +1,51 @@ +from allauth.socialaccount.adapter import DefaultSocialAccountAdapter +from allauth.account.utils import user_field +from django.conf import settings +from allauth.account.adapter import DefaultAccountAdapter +import requests +from django.core.files import File +from django.core.files.temp import NamedTemporaryFile + +class MyAccountAdapter(DefaultAccountAdapter): + + def get_login_redirect_url(self, request): + path = super(MyAccountAdapter, self).get_login_redirect_url(request) + + try: + user = request.user + user_profile = user.user_profile + if user_profile and not user_profile.avatar: + social_accounts = user.socialaccount_set.all() + if social_accounts: + for social_account in social_accounts: + if 'picture' in social_account.extra_data and social_account.extra_data['picture']: + r = requests.get(social_account.extra_data['picture']) + + img_temp = NamedTemporaryFile() + img_temp.write(r.content) + img_temp.flush() + user_profile.avatar.save(f'avatar_{user.id}.jpeg', File(img_temp), True) + break + + except Exception as e: + msg = f'post_save create_user_profile Error = {str(e)}' + print(msg) + + return path + +# class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): +# def populate_user(self, request, sociallogin, data): +# from AuthApp.models import UserProfile +# +# user = super().populate_user(request, sociallogin, data) +# try: +# picture = sociallogin.account.extra_data['picture'] +# user_profile = UserProfile.objects.get_or_create(user=user) +# with open(picture, 'rb') as fd: +# user_profile.avatar.save(f'user_{user.id}_avatar.jpeg', fd.read(), True) +# # user_field(user, "profile_photo", picture) +# except Exception as e: +# msg = f'CustomSocialAccountAdapter populate_user Error = {str(e)}' +# print(msg) +# +# return user \ No newline at end of file diff --git a/GeneralApp/funcs_options.py b/GeneralApp/funcs_options.py index 282c38b..80bb858 100644 --- a/GeneralApp/funcs_options.py +++ b/GeneralApp/funcs_options.py @@ -13,6 +13,16 @@ def get_options_by_opt_types(opt_types, only_vals=False): res = {} opts = opts.values('opt_type', 'value', 'prefix') for item in opts: + if item['opt_type'] == 'domain': + + try: + from django.contrib.sites.models import Site + current_site = Site.objects.get_current() + res.update({item['opt_type']: current_site.domain}) + continue + except Exception as e: + print(str(e)) + if item['prefix']: res.update({item['opt_type']: f"{item['prefix']}{item['value']}"}) else: @@ -29,6 +39,6 @@ def get_first_option_value_by_opt_type(opt_type): return None def get_mail_send_options(): - opt_types = ['mail_server_url', 'mail_server_smtp_port', 'sender_mail_login', 'sender_mail_password', 'sender_email'] + opt_types = ['mail_server_url', 'mail_server_smtp_port', 'sender_mail_login', 'sender_mail_password', 'sender_email', 'project_name'] return get_options_by_opt_types(opt_types, only_vals=True) diff --git a/GeneralApp/views.py b/GeneralApp/views.py index 66e17c3..1b83e5f 100644 --- a/GeneralApp/views.py +++ b/GeneralApp/views.py @@ -19,6 +19,11 @@ def test_code(request): from RoutesApp.models import Route from ReferenceDataApp.models import Airport, City + # import allauth + # from allauth.socialaccount.models import SocialApp + # apps = SocialApp.objects.all() + # apps.delete() + from RoutesApp.search_matches import search_matches search_matches() diff --git a/PushMessages/views.py b/PushMessages/views.py index 39889d2..8f20032 100644 --- a/PushMessages/views.py +++ b/PushMessages/views.py @@ -6,6 +6,7 @@ from webpush import send_user_notification import json from django.shortcuts import render, get_object_or_404 from django.conf import settings +from django.utils.translation import gettext as _ def get_key_Dict(): @@ -16,7 +17,7 @@ def get_key_Dict(): } return Dict -def send_push(user, title, text, img=None): +def send_push(user, title, text, url=None, button_name=None, img=None): try: # body = request.body # data = json.loads(body) @@ -28,8 +29,17 @@ def send_push(user, title, text, img=None): # user = get_object_or_404(User, pk=user_id) Dict = { 'head': title, - 'body': text + 'body': text, } + if url: + Dict['url'] = url + if button_name: + Dict['button_name'] = button_name + else: + Dict['button_name'] = _('Перейти'), + + if img: + Dict['img'] = img # payload = {'head': data['head'], 'body': data['body']} send_user_notification(user=user, payload=Dict, ttl=1000) diff --git a/RoutesApp/funcs.py b/RoutesApp/funcs.py index 1ee5adb..f9f845f 100644 --- a/RoutesApp/funcs.py +++ b/RoutesApp/funcs.py @@ -150,6 +150,16 @@ def get_routes_Dict(user=None, data=None): res_Dict = {} if data: + + type_transport = None + if 'type_transport' in data and data['type_transport']: + items_list = data['type_transport'].split(',') + kwargs.update({f'type_transport__in': items_list}) + + if len(items_list) == 1: + type_transport = items_list[0] + + for key, val in data.items(): if val: if key == 'weight': @@ -162,9 +172,9 @@ def get_routes_Dict(user=None, data=None): else: kwargs.update({f'{key}__lte': int(weight_list[0])}) - if key == 'type_transport': - items_list = val.split(',') - kwargs.update({f'{key}__in': items_list}) + # if key == 'type_transport': + # items_list = val.split(',') + # kwargs.update({f'{key}__in': items_list}) if key in ( @@ -184,19 +194,18 @@ def get_routes_Dict(user=None, data=None): kwargs.update({key: val}) if key == 'from_address_point': - kwargs.update({f'from_city__id': val}) + city = get_city_by_type_transport_and_address_point(type_transport, val) + kwargs.update({f'from_city': city}) + res_Dict.update({ - 'from_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point( - 'road', val - ) + 'from_address_point_txt': city.get_country_n_city_str() }) if key == 'to_address_point': - kwargs.update({f'to_city__id': val}) + city = get_city_by_type_transport_and_address_point(type_transport, val) + kwargs.update({f'to_city': city}) res_Dict.update({ - 'to_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point( - 'road', val - ) + 'to_address_point_txt': city.get_country_n_city_str() }) if key == 'from_el': diff --git a/RoutesApp/search_matches.py b/RoutesApp/search_matches.py index 65d9fec..81b1994 100644 --- a/RoutesApp/search_matches.py +++ b/RoutesApp/search_matches.py @@ -5,22 +5,53 @@ from django.template.loader import render_to_string from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options from BaseModels.mailSender import admin_send_mail_by_SMTPlib, techSendMail -def send_mail_found_matches_routes(route, kwargs, search_owner_type): + + +def get_Dict_for_send_msgs(kwargs, search_owner_type): + print('get_Dict_for_send_msgs') Dict = { - 'route': route, 'search_owner_type': search_owner_type } sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True) Dict.update(sets) - Dict.update({'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg',}) + + + Dict.update({'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg', }) find_routes_page_url = f'{sets["domain"]}/routes/route_search_results/?' kwargs_list = [f'{key}={value}' for key, value in kwargs.items()] kwargs_list.append(f'owner_type={search_owner_type}') find_routes_page_url += f'{"&".join(kwargs_list)}' + Dict.update({'find_routes_page_url': find_routes_page_url}) + return Dict + + + +def send_push_message_for_found_matches_routes(route, data_Dict): + print(f'send_push_message_for_found_matches_routes to route id = {route.id}') + + if not route.owner.is_authenticated: + return None + + from PushMessages.views import send_push + title = 'Мы нашли исполнителя по Вашему объявлению!' + text = 'Для просмотра результата нажмите на кнопку ниже' + send_push(route.owner, title, text, url=data_Dict['find_routes_page_url'], button_name=_('Перейти к найденному')) + return None + + + +def send_mail_found_matches_routes(route, data_Dict): + print(f'send_mail_found_matches_routes to route id = {route.id}') + + Dict = { + 'route': route, + } + Dict.update(data_Dict) + html = render_to_string('mail/m_found_matched_routes.html', Dict) @@ -38,6 +69,7 @@ def send_mail_found_matches_routes(route, kwargs, search_owner_type): def search_matches(for_routes=None): + print('search_matches') log = '' @@ -53,6 +85,11 @@ def search_matches(for_routes=None): 'from_place', 'to_place', 'cargo_type', 'weight' ] + if for_routes: + msg = f'last hour create routes count = {for_routes.count()}' + else: + msg = f'last hour not create routes' + print(msg) for route in for_routes: kwargs = {} @@ -87,15 +124,22 @@ def search_matches(for_routes=None): ) if found_routes: - msg = send_mail_found_matches_routes(route, params, found_routes[0].owner_type) + msg = f'found routes for send messages = {found_routes.count()}' + + data_Dict = get_Dict_for_send_msgs(params, found_routes[0].owner_type) + msg = send_push_message_for_found_matches_routes(route, data_Dict) + if msg: + log += msg + msg = send_mail_found_matches_routes(route, data_Dict) if msg: log += msg except Exception as e: msg = f'
\n! search_matches Error = {str(e)}' + print(msg) log += msg mail_sets = get_mail_send_options() - techSendMail(mail_sets, log, msg) + techSendMail(mail_sets, log, title='search_matches fail') return log diff --git a/TWB/settings.py b/TWB/settings.py index f77f3e4..76c5b35 100644 --- a/TWB/settings.py +++ b/TWB/settings.py @@ -36,6 +36,40 @@ WEBPUSH_SETTINGS = { "VAPID_ADMIN_EMAIL": "admin@tripwb.com" } + +SOCIALACCOUNT_LOGIN_ON_GET=True +ACCOUNT_DEFAULT_HTTP_PROTOCOL='https' + +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_AUTHENTICATION_METHOD = 'email' +ACCOUNT_EMAIL_VERIFICATION = 'optional' +LOGIN_REDIRECT_URL = '/profile/page/dashboard/' +LOGOUT_REDIRECT_URL = '/profile/login/' +ACCOUNT_SIGNUP_REDIRECT_URL = '/profile/page/dashboard/' +ACCOUNT_LOGOUT_ON_GET = True +# SOCIALACCOUNT_ADAPTER = 'GeneralApp.allauth_funcs.MyAccountAdapter' +ACCOUNT_ADAPTER = 'GeneralApp.allauth_funcs.MyAccountAdapter' + +AUTHENTICATION_BACKENDS = [ + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +] + + + +SOCIALACCOUNT_PROVIDERS = { + 'google': { + 'SCOPE': [ + 'profile', + 'email', + ], + 'AUTH_PARAMS': { + 'access_type': 'online', + }, + } +} + # NOTIFICATION_KEY = 'BJLyGzmo8sLI3Qkc6pN2cz11frCXiJdewvgve7Yps-_fM1lY1LSnTQfQxYtAgQ_26nAji_rgeYC1DkLiTwxw0Mo' # SESSION_COOKIE_HTTPONLY = False @@ -56,6 +90,8 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django.contrib.humanize', + 'django.contrib.sites', + 'colorfield', 'ckeditor', @@ -63,6 +99,11 @@ INSTALLED_APPS = [ 'webpush', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + 'allauth.socialaccount.providers.google', + 'GeneralApp', 'AuthApp', 'RoutesApp', @@ -82,8 +123,12 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'AuthApp.middleware.ResponseInterceptionMiddleware', + + "allauth.account.middleware.AccountMiddleware", ] +SITE_ID = 1 + ROOT_URLCONF = 'TWB.urls' TEMPLATES = [ diff --git a/TWB/urls.py b/TWB/urls.py index c772353..3fbaabd 100644 --- a/TWB/urls.py +++ b/TWB/urls.py @@ -4,6 +4,7 @@ from django.urls import path, include from django.conf.urls.static import static from django.conf import settings from GeneralApp.views import Page404 +from AuthApp.views import login_View handler404 = Page404 @@ -12,12 +13,17 @@ urlpatterns = [ path('ckeditor/', include('ckeditor_uploader.urls')), path('i18n/', include('django.conf.urls.i18n')), - # path('webpush/', include('webpush.urls')), + path('accounts/signup/', login_View, name='signup'), + + path('accounts/', include('allauth.urls')), + path('accounts/', include('allauth.socialaccount.urls')), path('messages/', include('ChatServiceApp.urls')), path('user_account/', include('AuthApp.js_urls')), + + path('routes/', include('RoutesApp.js_urls')), path('subscribes/', include('SubscribesApp.js_urls')), diff --git a/requirements.pip b/requirements.pip index 618a0c6..75932d7 100644 --- a/requirements.pip +++ b/requirements.pip @@ -11,4 +11,5 @@ daphne==4.0.0 channels-redis==4.1.0 django-colorfield django-webpush==0.3.5 +django-allauth==0.60.0 diff --git a/static/css/mobile_styles.css b/static/css/mobile_styles.css index 92180f7..c28ee50 100644 --- a/static/css/mobile_styles.css +++ b/static/css/mobile_styles.css @@ -71,41 +71,41 @@ left: 33%; } - .cards_item_1, - .cards_item_2, - .cards_item_3, - .cards_item_4 - { - width: 46%; - height: 180px; - background-size:60%; - } + /* .cards_item_1,*/ + /*.cards_item_2,*/ + /*.cards_item_3,*/ + /*.cards_item_4*/ + /*{*/ + /* width: 46%;*/ + /* height: 180px;*/ + /* background-size:60%;*/ + /*}*/ - .card_title_1{ - font-size: 34px; - font-style: normal; - font-weight: 700; - line-height: 42px; - margin: 22px 0 0 10px; - text-shadow: 1px 1px 0px #272424; - } - .card_title_2{ - font-size: 17px; - font-style: normal; - font-weight: 600; - line-height: 26px; - margin: 10px 0 0 10px; - text-shadow: 1px 1px 0px #272424; - } - .card_title_3{ - margin: 10px 0 0 10px; - width: 95%; - font-size: 12px; - font-style: normal; - font-weight: 400; - line-height: 20px; - text-shadow: 1px 1px 0px #272424; - } + /* .card_title_1{*/ + /* font-size: 34px;*/ + /* font-style: normal;*/ + /* font-weight: 700;*/ + /* line-height: 42px;*/ + /* margin: 22px 0 0 10px;*/ + /* text-shadow: 1px 1px 0px #272424;*/ + /*}*/ + /*.card_title_2{*/ + /* font-size: 17px;*/ + /* font-style: normal;*/ + /* font-weight: 600;*/ + /* line-height: 26px;*/ + /* margin: 10px 0 0 10px;*/ + /* text-shadow: 1px 1px 0px #272424;*/ + /*}*/ + /*.card_title_3{*/ + /* margin: 10px 0 0 10px;*/ + /* width: 95%;*/ + /* font-size: 12px;*/ + /* font-style: normal;*/ + /* font-weight: 400;*/ + /* line-height: 20px;*/ + /* text-shadow: 1px 1px 0px #272424;*/ + /*}*/ .sf_1_column { padding-left: 25px; padding-right: 90px; @@ -159,6 +159,17 @@ rotate: 270deg; } + .cards_item_1, + .cards_item_2, + .cards_item_3, + .cards_item_4{ + height: 322px; + width: 65%; + float: unset; + margin: 15px auto; + + } + .filter_img{ width: 15px; display: block; @@ -420,7 +431,7 @@ margin-top: unset; } - button#more_button{ + #more_button{ width: 50%; /*margin-top: 40px;*/ } @@ -1511,6 +1522,45 @@ + + .cards_item_1, + .cards_item_2, + .cards_item_3, + .cards_item_4{ + width: 70%; + height: unset; + float: unset; + margin: 15px auto; + + } + + .cards_item_img, .cards_item_text{ + float: unset; + width: unset; + } + + .cards_item_1>.cards_item_img>img, + .cards_item_2>.cards_item_img>img, + .cards_item_3>.cards_item_img>img, + .cards_item_4>.cards_item_img>img{ + float: unset; + aspect-ratio: 4/3; + object-fit: cover; + width: 100%; + border-radius: 10px; + } + .cards_item_text{ + padding-bottom: 20px; + } + + .card_title_1{ + margin: 25px 0 0 20px; + } + + + + + .read_more_about_subscribe{ padding: 0 14px; height: 30px; @@ -1792,7 +1842,7 @@ width: 100%; margin-top: 20px; } - button#more_button{ + #more_button{ width: 100%; margin-top: 40px; } @@ -1802,14 +1852,32 @@ justify-content: center; } - .cards_item_1, - .cards_item_2, - .cards_item_3, - .cards_item_4 - { - width: 100%; - height: 180px; - background-size:60%; + /*.cards_item_1,*/ + /*.cards_item_2,*/ + /*.cards_item_3,*/ + /*.cards_item_4*/ + /*{*/ + /* width: 100%;*/ + /* height: 180px;*/ + /* background-size:60%;*/ + /*}*/ + .card_title_1{ + font-size: 34px; + font-style: normal; + font-weight: 700; + line-height: 42px; + } + .card_title_2{ + font-size: 18px; + font-style: normal; + font-weight: 600; + line-height: 26px; + } + .card_title_3{ + font-size: 12px; + font-style: normal; + font-weight: 400; + line-height: 20px; } .cards_wrapper{ diff --git a/static/css/styles.css b/static/css/styles.css index a42f711..5d97f54 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -780,7 +780,7 @@ span.btn_profile_name { /*height: 60px;*/ font-size: 18px; font-weight: 500; - width: 100%; + width: 80%; margin-top: 10px; display: inline-block; @@ -2137,9 +2137,9 @@ span#sub_title_static{ } -button#more_button{ +#more_button{ display: inline-block; - height: 60px; + /*height: 60px;*/ width: 20%; background: #FF613A; color: #FFF; @@ -2652,18 +2652,40 @@ button#send_feedback_form:active{ } .cards_wrapper{ - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: center; + /*display: flex;*/ + /*flex-direction: row;*/ + /*flex-wrap: wrap;*/ + /*justify-content: center;*/ + display: inline-block; +} +.cards_item_1, .cards_item_3{ + float: left; +} +.cards_item_2, .cards_item_4{ + float: right; +} +.cards_item_1>.cards_item_img>img, +.cards_item_2>.cards_item_img>img, +.cards_item_3>.cards_item_img>img, +.cards_item_4>.cards_item_img>img{ + float: right; +} + +#reg_or_text{ + margin: 10px; +} + +.cards_item_2>.cards_item_text>div, .cards_item_3>.cards_item_text>div{ + color: #1d1e20; } + + .cards_item_1{ - width: 48%; - height: 322px; border-radius: 10px; - background: url(/static/img/png/cards_item_1.png) #1d1e20 50%; + /*background: url(/static/img/png/cards_item_1.png) #1d1e20 50%;*/ + background: #1d1e20 50%; background-repeat: no-repeat; background-position: right; @@ -2672,13 +2694,7 @@ button#send_feedback_form:active{ margin: 10px; } -.cards_item_1_left, -.cards_item_2_left, -.cards_item_3_left, -.cards_item_4_left{ - width: 55%; - float: left; -} + @@ -2693,10 +2709,9 @@ button#send_feedback_form:active{ } .cards_item_2{ - width: 48%; - height: 322px; - border-radius: 10px; - background: url(/static/img/png/cards_item_2.png) white 50%; + border-radius: 10px; + /*background: url(/static/img/png/cards_item_2.png) white 50%;*/ + background: white 50%; background-repeat: no-repeat; background-position: right; @@ -2706,13 +2721,23 @@ button#send_feedback_form:active{ } -.cards_item_2>div, -.cards_item_3>div{ - color: black; - text-shadow: none; - text-shadow: 1px 1px 0px #ffffff; +.cards_item_text { + float: left; + width: 50%; } +.cards_item_img { + float: right; + width: 50%; +} + +/*.cards_item_2>div,*/ +/*.cards_item_3>div{*/ +/* color: black;*/ +/* text-shadow: none;*/ +/* text-shadow: 1px 1px 0px #ffffff;*/ +/*}*/ + .cards_item_2_right{ float: right; border-radius: 10px; @@ -2738,10 +2763,9 @@ button#send_feedback_form:active{ .cards_item_3{ - width: 48%; - height: 322px; border-radius: 10px; - background: url(/static/img/png/cards_item_3.png) white 50%; + /*background: url(/static/img/png/cards_item_3.png) white 50%;*/ + background: white 50%; background-repeat: no-repeat; background-position: right; box-shadow: -1px 4px 10px 0px rgba(198, 199, 203, 0.20), 0px -1px 10px 0px rgba(198, 199, 203, 0.20); @@ -2761,10 +2785,9 @@ button#send_feedback_form:active{ .cards_item_4{ - width: 48%; - height: 322px; border-radius: 10px; - background: url(/static/img/png/cards_item_4.png), #111217 50%; + /*background: url(/static/img/png/cards_item_4.png), #111217 50%;*/ + background: #111217 50%; background-repeat: no-repeat; background-position: right; @@ -2773,6 +2796,16 @@ button#send_feedback_form:active{ margin: 10px; } + +.cards_item_1, +.cards_item_2, +.cards_item_3, +.cards_item_4{ + height: 322px; + width: 48%; +} + + .cards_item_4_right{ float: right; border-radius: 10px; @@ -2789,7 +2822,7 @@ button#send_feedback_form:active{ font-style: normal; font-weight: 700; line-height: 52px; /* 118.182% */ - margin: 104px 0 0 20px; + margin: 67px 0 0 20px; } .card_title_2{ color: #FFF; @@ -2806,7 +2839,7 @@ button#send_feedback_form:active{ font-weight: 400; line-height: 22px; margin: 20px 0 0 20px; - width: 50%; + } /*faq_main_page*/ diff --git a/templates/blocks/b_header.html b/templates/blocks/b_header.html index 04e84ba..cbde507 100644 --- a/templates/blocks/b_header.html +++ b/templates/blocks/b_header.html @@ -66,7 +66,7 @@ {#
#} - {{ user.first_name }} {{ user.last_name }} + {{ user.first_name|truncatechars:6}} {{ user.last_name|truncatechars:5 }}
diff --git a/templates/forms/f_login.html b/templates/forms/f_login.html index 406b512..81368bb 100644 --- a/templates/forms/f_login.html +++ b/templates/forms/f_login.html @@ -1,12 +1,13 @@ {% load i18n %} +{% load socialaccount %} {% trans "Логин" as p_login %} {% trans "Пароль" as p_password %}
diff --git a/templates/pages/p_main.html b/templates/pages/p_main.html index a5e80ba..6a0e8c6 100644 --- a/templates/pages/p_main.html +++ b/templates/pages/p_main.html @@ -98,7 +98,7 @@

{% translate "Свяжитесь с перевозчиком" %}

- {% translate "Откройте контакты на сайте и договоритесь о месте встречи и условиях перевозки" %} + {% translate "Откройте контакты на сайте и договоритесь о месте встречи и условиях перевозки. В случае, если Вы не нашли объявления о перевозчиках по Вашему запросу, Вы можете разместить свое объявление воспользовавшись формой в личном кабинете." %}
@@ -112,7 +112,10 @@
- {% translate "Отправить посылку" %} + {% translate "Отправить посылку" %} +
@@ -121,8 +124,8 @@
-

{% translate "Разместите объявление" %}

- {% translate "Укажите откуда, куда хотите перевезти посылку, а также Вашу дату отправления и прибытия. При желании Вы можете указать дополнительные параметры: тип, вес, вид перевозки и т.д" %} +

{% translate "Найдите отправителя" %}

+ {% translate "Зайдите на сайт Trip With Bonus и в форме вверху страницы, заполните данные для поиска отправителя посылки." %}
@@ -131,7 +134,7 @@

{% translate "Свяжитесь с отправителем" %}

- {% translate "В отобразившемся списке выберите подходящего отправителя и посылку, откройте контакты и свяжитесь удобным способом. Если не нашли подходящего отправителя с посылкой, разместите объявление о возможности перевезти посылку и отправители Вас сами найдут" %} + {% translate "Откройте контакты на сайте и договоритесь о месте встречи и условиях перевозки. В случае, если Вы не нашли объявления об отправителях по Вашему запросу, Вы можете разместить свое объявление воспользовавшись формой в личном кабинете." %}
@@ -140,7 +143,7 @@

{% translate "Передайте посылку" %}

- {% translate "Обсудите с отправителем все условия: время, место и прочие детали. Готово! Доставьте посылку из пункта А в пункт Б и получите благодарность отправителя!" %} + {% translate "Встречайтесь, знакомьтесь и принимайте посылку" %}
@@ -148,7 +151,10 @@
- + {% translate "Перевезти посылку" %} +
@@ -167,31 +173,47 @@
+ +
+ +
+ +
{% translate "+5%" %}
{% translate "рост путешествий ежегодно" %}
{% translate "В среднем на 5% растёт количество путешествий ежегодно. Просто путешествуй и получай бонусы." %}
- -{#
#} -{#
#} -{#
#} +
+
+
+ +
+ +
{% translate "в 3 раза" %}
{% translate "быстрее других сервисов" %}
{% translate "Почтовые сервисы доставляет посылки в среднем за 10 дней. С нами - быстрее!" %}
+
+ + + + {#
#} - - -{#
#} -{# #} -{#
#}
+
+ +
+ +
{% translate "+142" %}
{% translate "заявки ежедневно" %}
{% translate "На перевозку или отправку посылок в разные уголки мира" %}
+
+ {#
#} {#
#} @@ -199,9 +221,16 @@
-
{% translate "30+" %}
-
{% translate "стран" %}
-
{% translate "С TWB отправляй посылки по всему миру! С нами нет границ!" %}
+
+ +
+ +
+
{% translate "30+" %}
+
{% translate "стран" %}
+
{% translate "С TWB отправляй посылки по всему миру! С нами нет границ!" %}
+
+ {#
#} {#
#} diff --git a/templates/sw.js b/templates/sw.js index db390a8..ae4afd5 100644 --- a/templates/sw.js +++ b/templates/sw.js @@ -7,12 +7,32 @@ self.addEventListener('push', function (event) { const data = JSON.parse(eventInfo); const head = data.head || 'New Notification 🕺🕺'; const body = data.body || 'This is default content. Your notification didn\'t have one 🙄🙄'; + const icon = data.img || 'static/img/svg/Logo.svg'; + + let notificationOptions = { + body: body, + icon: icon, + }; + if ('url' in data){ + notificationOptions['data'] = { url: data.url }; + notificationOptions['actions'] = [{action: "open_url", title: data.button_name}] + } // Keep the service worker alive until the notification is created. event.waitUntil( - self.registration.showNotification(head, { - body: body, - icon: 'static/img/svg/Logo.svg' - }) + self.registration.showNotification(head, notificationOptions) ); -}); \ No newline at end of file +}); + +self.addEventListener('notificationclick', function(event) { + + switch(event.action){ + case 'open_url': + clients.openWindow(event.notification.data.url); + break; + case 'any_other_action': + clients.openWindow("https://www.example.com"); + break; + } +} +, false); \ No newline at end of file diff --git a/templates/tb_base.html b/templates/tb_base.html index 90b3e3c..dbceb29 100644 --- a/templates/tb_base.html +++ b/templates/tb_base.html @@ -33,7 +33,7 @@ init_ws() const beep = new Audio('/static/sounds/beep_2.mp3') - + {% endif %} @@ -56,6 +56,9 @@ {% block meta %} {% endblock %} + + +