diff --git a/app/bot/core/message_handler.py b/app/bot/core/message_handler.py index f137536..ac5e34a 100644 --- a/app/bot/core/message_handler.py +++ b/app/bot/core/message_handler.py @@ -113,9 +113,6 @@ class TelegramBotHandler: def handle_status(self): today = timezone.now().date() first_day_of_current_month = today.replace(day=1) - first_day_of_previous_month = ( - first_day_of_current_month - - datetime.timedelta(days=1)).replace(day=1) host_url = Settings.get_setting("HOST_URL", "http://localhost:8000") send_message("sendMessage", { @@ -174,7 +171,7 @@ class TelegramBotHandler: required_count = int( Settings.get_setting("circle_required_count", "4")) user_circes_count = Circle.objects.filter( - uploaded_at__gte=first_day_of_previous_month, + uploaded_at__gte=first_day_of_current_month, user=self.user_state).count() send_message("sendMessage", { 'chat_id': self.chat_id, diff --git a/app/bot/validators/is_corporate_email.py b/app/bot/validators/is_corporate_email.py index bc1db5d..373eb2c 100644 --- a/app/bot/validators/is_corporate_email.py +++ b/app/bot/validators/is_corporate_email.py @@ -2,5 +2,5 @@ import re def is_corporate_email(email): - pattern = r'^[a-zA-Z0-9._%+-]+@cybercode\.pro$' + pattern = r'^[a-zA-Z0-9._%+-]+@(cybercode\.pro|pgpi\.su)$' return bool(re.fullmatch(pattern, email)) diff --git a/app/bot/views.py b/app/bot/views.py index bf8be06..ca45350 100644 --- a/app/bot/views.py +++ b/app/bot/views.py @@ -15,18 +15,17 @@ import requests class TelegramBotWebhookView(CSRFExemptMixin, View): def post(self, request): - if request.method == 'POST': - message = {} - try: - message = json.loads(request.body.decode('utf-8')) - dispatcher = TelegramBotDispatcher() - dispatcher.dispatch(message) - except Exception as e: - error_logger.error( - f"Ошибка во время обработки сообщения: {e}\nСообщение: {message}\n") - return HttpResponse('error', status=500) + message = {} + try: + message = json.loads(request.body.decode('utf-8')) + dispatcher = TelegramBotDispatcher() + dispatcher.dispatch(message) + return HttpResponse('ok') + except Exception as e: + error_logger.error( + f"Ошибка во время обработки сообщения: {e}\nСообщение: {message}\n") + return HttpResponse('error', status=500) - return HttpResponse('ok') class TelegramBotSetwebhookView(View): diff --git a/app/report/views.py b/app/report/views.py index d9f2db3..9b90947 100644 --- a/app/report/views.py +++ b/app/report/views.py @@ -64,6 +64,7 @@ class ReportView(LoginRequiredMixin, FormView): continue user_circles_count = Circle.objects.filter( uploaded_at__gte=start_date, + uploaded_at__lte=end_date, user=user).count() if user_circles_count < required_count: report['not_accessed'].append({