Добавил абуз вч отметок
This commit is contained in:
@@ -295,7 +295,7 @@ class SignalMarksEntryAPIView(LoginRequiredMixin, View):
|
||||
|
||||
# Проверяем, можно ли добавить новую отметку (прошло 5 минут)
|
||||
can_add_mark = True
|
||||
if last_mark:
|
||||
if last_mark and last_mark.timestamp:
|
||||
time_diff = timezone.now() - last_mark.timestamp
|
||||
can_add_mark = time_diff >= timedelta(minutes=5)
|
||||
|
||||
@@ -364,17 +364,18 @@ class SaveSignalMarksView(LoginRequiredMixin, View):
|
||||
tech_analyze = TechAnalyze.objects.get(id=tech_analyze_id)
|
||||
|
||||
# Проверяем, можно ли добавить отметку
|
||||
last_mark = tech_analyze.marks.first()
|
||||
if last_mark:
|
||||
last_mark = tech_analyze.marks.order_by('-timestamp').first()
|
||||
if last_mark and last_mark.timestamp:
|
||||
time_diff = timezone.now() - last_mark.timestamp
|
||||
if time_diff < timedelta(minutes=5):
|
||||
skipped_count += 1
|
||||
continue
|
||||
|
||||
# Создаём отметку
|
||||
# Создаём отметку с текущим временем
|
||||
ObjectMark.objects.create(
|
||||
tech_analyze=tech_analyze,
|
||||
mark=mark_value,
|
||||
timestamp=timezone.now(),
|
||||
created_by=custom_user,
|
||||
)
|
||||
created_count += 1
|
||||
|
||||
Reference in New Issue
Block a user