def send_rejection_msg(profile, photo, reason): support = profile.matching_support chat = Chat.get_chat(profile, support) msg_body = ('Ваша фотография нарушала правила сайта и была удалена. ' 'Пожалуйста, згрузите новое фото. Это должна быть ' 'ваша фотография. Запрещено использовать фотографии:\n' '- несовершеннолетних детей\n' '- фотографии из Интернета и фото знаменитостей\n' '- изображения эротического характера\n' '- фотографии животных\n' '- предметы / картинки / рисунки') Message.objects.create(sender=support, receiver=profile, body=msg_body, chat=chat)
def emulate_message(messaged): prof_emu = find_profile_and_emulator(messaged) if not prof_emu: return profile, emulator = prof_emu chat = Chat.get_chat(profile, emulator) Message.objects.create( chat=chat, receiver=profile, sender=emulator, body='Привет') contact_kwargs = { 'emulator': emulator, 'contacted': profile, 'type': 'message' } Contact.objects.create(**contact_kwargs)
def reply(req): form = ReplyForm(req.POST) if form.is_valid(): profile = form.cleaned_data['profile'] moderator = profile.matching_support if not moderator: return HttpResponse('No matching support', status=500) chat = Chat.get_chat(profile, moderator) Message.objects.filter(chat=chat, receiver=moderator).update(is_read=True) Message.objects.create(sender=moderator, receiver=profile, body=form.cleaned_data['body'], chat=chat) if profile.user.email: send_feedback_email(profile, form.cleaned_data['body']) return HttpResponse('ok') return HttpResponse(str(form.errors), status=400)