Merge remote-tracking branch 'origin/master'

This commit is contained in:
zakhy 2025-03-08 16:00:09 +07:00
commit 569fe3d364
4 changed files with 13 additions and 16 deletions

View File

@ -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,

View File

@ -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))

View File

@ -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):

View File

@ -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({