1.6.12 fix next package for my_routes
This commit is contained in:
@@ -3,6 +3,7 @@ from .models import *
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
class Admin_Route(Admin_Trans_BaseModel):
|
class Admin_Route(Admin_Trans_BaseModel):
|
||||||
|
readonly_fields = ['highlight_end_DT', 'rising_DT']
|
||||||
list_display = [
|
list_display = [
|
||||||
'id', 'owner_type', 'receive_msg_by_email', 'type_transport', 'cargo_type',
|
'id', 'owner_type', 'receive_msg_by_email', 'type_transport', 'cargo_type',
|
||||||
'departure_DT', 'from_city', 'from_place',
|
'departure_DT', 'from_city', 'from_place',
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ def get_city_by_type_transport_and_address_point(type_transport, address_point):
|
|||||||
from ReferenceDataApp.models import Airport, City
|
from ReferenceDataApp.models import Airport, City
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# if type_transport == 'avia':
|
if type_transport == 'avia':
|
||||||
# return Airport.objects.get(id=address_point).city
|
return Airport.objects.get(id=address_point).city
|
||||||
# else:
|
else:
|
||||||
return City.objects.get(id=address_point)
|
return City.objects.get(id=address_point)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f'get_city_by_type_transport_and_address_point Error = {str(e)}, type_transport = {type_transport}, address_point = {address_point}'
|
msg = f'get_city_by_type_transport_and_address_point Error = {str(e)}, type_transport = {type_transport}, address_point = {address_point}'
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from django.template import loader, RequestContext
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from BaseModels.mailSender import techSendMail
|
from BaseModels.mailSender import techSendMail
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from .forms import *
|
from .forms import *
|
||||||
@@ -41,14 +41,20 @@ def highlight_route_ajax(request):
|
|||||||
msg = _('Нет доступа к выделению')
|
msg = _('Нет доступа к выделению')
|
||||||
return JsonResponse({'errors': msg})
|
return JsonResponse({'errors': msg})
|
||||||
|
|
||||||
route.highlight_color = '#FF0000'
|
|
||||||
route.save(update_fields=['highlight_color'])
|
|
||||||
|
|
||||||
from SubscribesApp.funcs import get_cur_user_subscribe
|
from SubscribesApp.funcs import get_cur_user_subscribe
|
||||||
user_subscribe = get_cur_user_subscribe(request.user)
|
user_subscribe = get_cur_user_subscribe(request.user)
|
||||||
user_subscribe.used_route_highlight_count += 1
|
user_subscribe.used_route_highlight_count += 1
|
||||||
user_subscribe.save(update_fields=['used_route_highlight_count'])
|
user_subscribe.save(update_fields=['used_route_highlight_count'])
|
||||||
|
|
||||||
|
|
||||||
|
route.highlight_color = '#FF0000'
|
||||||
|
highlight_hours = user_subscribe.get_highlight_hours()
|
||||||
|
route.highlight_end_DT = datetime.now() + timedelta(hours=highlight_hours)
|
||||||
|
route.save(update_fields=['highlight_color', 'highlight_end_DT'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dict = {
|
Dict = {
|
||||||
'route': route,
|
'route': route,
|
||||||
}
|
}
|
||||||
|
|||||||
18
RoutesApp/migrations/0008_route_highlight_end_dt.py
Normal file
18
RoutesApp/migrations/0008_route_highlight_end_dt.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.2 on 2024-08-13 13:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('RoutesApp', '0007_rename_select_color_route_highlight_color'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='route',
|
||||||
|
name='highlight_end_DT',
|
||||||
|
field=models.DateTimeField(blank=True, null=True, verbose_name='Дата и время окончания выделения'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -71,6 +71,10 @@ class Route(BaseModel):
|
|||||||
verbose_name=_('Цвет выделения'),
|
verbose_name=_('Цвет выделения'),
|
||||||
blank=True, null=True
|
blank=True, null=True
|
||||||
)
|
)
|
||||||
|
highlight_end_DT = models.DateTimeField(
|
||||||
|
verbose_name=_('Дата и время окончания выделения'),
|
||||||
|
blank=True, null=True
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.name:
|
if self.name:
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ class Admin_SubscribeOption(Admin_Trans_BaseModel):
|
|||||||
(None, {
|
(None, {
|
||||||
'classes': ['wide'],
|
'classes': ['wide'],
|
||||||
'fields': (
|
'fields': (
|
||||||
'allow_route_rising_count', 'allow_route_highlight_count'
|
('allow_route_rising_count',),
|
||||||
|
('allow_route_highlight_count', 'route_highlight_hours'),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -53,6 +54,8 @@ class Admin_SubscribeOption(Admin_Trans_BaseModel):
|
|||||||
list_display = [
|
list_display = [
|
||||||
'id', 'enable',
|
'id', 'enable',
|
||||||
'name',
|
'name',
|
||||||
|
'allow_route_rising_count',
|
||||||
|
'allow_route_highlight_count', 'route_highlight_hours',
|
||||||
'order', 'modifiedDT', 'createDT'
|
'order', 'modifiedDT', 'createDT'
|
||||||
]
|
]
|
||||||
list_editable = ['enable']
|
list_editable = ['enable']
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.2 on 2024-08-13 13:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('SubscribesApp', '0006_rename_allow_route_select_count_subscribeoption_allow_route_highlight_count'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='subscribeoption',
|
||||||
|
name='route_highlight_hours',
|
||||||
|
field=models.IntegerField(default=24, verbose_name='Количество часов выделения цветом объявлений'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -17,8 +17,12 @@ from datetime import datetime, timedelta
|
|||||||
|
|
||||||
class SubscribeOption(BaseModel):
|
class SubscribeOption(BaseModel):
|
||||||
|
|
||||||
allow_route_rising_count = models.IntegerField(verbose_name=_('Количество поднятий объявлений') ,default=0)
|
allow_route_rising_count = models.IntegerField(
|
||||||
allow_route_highlight_count = models.IntegerField(verbose_name=_('Количество выделений объявлений'), default=0)
|
verbose_name=_('Количество поднятий объявлений') ,default=0)
|
||||||
|
allow_route_highlight_count = models.IntegerField(
|
||||||
|
verbose_name=_('Количество выделений объявлений'), default=0)
|
||||||
|
route_highlight_hours = models.IntegerField(
|
||||||
|
verbose_name=_('Количество часов выделения цветом объявлений'), default=24)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('Опция подписки')
|
verbose_name = _('Опция подписки')
|
||||||
@@ -88,6 +92,14 @@ class SubscribeForUser(BaseModel):
|
|||||||
res += f' {str(self.id)}'
|
res += f' {str(self.id)}'
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_highlight_hours(self):
|
||||||
|
options = self.subscribe.options.filter(
|
||||||
|
allow_route_highlight_count__gt=0,
|
||||||
|
)
|
||||||
|
if options:
|
||||||
|
return options[0].route_highlight_hours
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def remains_route_adding_options(self):
|
def remains_route_adding_options(self):
|
||||||
total_data = SubscribeOption.objects.filter(
|
total_data = SubscribeOption.objects.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user