コード例 #1
0
ファイル: tasks.py プロジェクト: sajalasati/oppia
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        references = feedback_services.get_feedback_message_references(user_id)
        if not references:
            # Model may not exist if user has already attended to the feedback.
            return

        feedback_services.update_feedback_email_retries_transactional(user_id)

        messages = {}
        for reference in references:
            message = feedback_services.get_message(reference.thread_id,
                                                    reference.message_id)

            exploration = exp_fetchers.get_exploration_by_id(
                reference.entity_id)

            message_text = message.text
            if len(message_text) > 200:
                message_text = message_text[:200] + '...'

            if exploration.id in messages:
                messages[exploration.id]['messages'].append(message_text)
            else:
                messages[exploration.id] = {
                    'title': exploration.title,
                    'messages': [message_text]
                }

        email_manager.send_feedback_message_email(user_id, messages)
        feedback_services.pop_feedback_message_references_transactional(
            user_id, len(references))
        self.render_json({})
コード例 #2
0
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        reference_dict = payload['reference_dict']

        message = feedback_services.get_message(reference_dict['thread_id'],
                                                reference_dict['message_id'])
        exploration = exp_fetchers.get_exploration_by_id(
            reference_dict['entity_id'])
        thread = feedback_services.get_thread(reference_dict['thread_id'])
        model = email_models.GeneralFeedbackEmailReplyToIdModel.get(
            user_id, reference_dict['thread_id'])
        reply_to_id = model.reply_to_id

        subject = 'New Oppia message in "%s"' % thread.subject
        email_manager.send_instant_feedback_message_email(
            user_id,
            message.author_id,
            message.text,
            subject,
            exploration.title,
            reference_dict['entity_id'],
            thread.subject,
            reply_to_id=reply_to_id)
        self.render_json({})
コード例 #3
0
ファイル: tasks.py プロジェクト: testMrinal/oppia
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        reference_dict = payload['reference_dict']

        message = feedback_services.get_message(reference_dict['thread_id'],
                                                reference_dict['message_id'])
        exploration = exp_fetchers.get_exploration_by_id(
            reference_dict['entity_id'])
        thread = feedback_services.get_thread(reference_dict['thread_id'])
        feedback_thread_reply_info = (
            email_services.get_feedback_thread_reply_info_by_user_and_thread(
                user_id, reference_dict['thread_id']))
        if feedback_thread_reply_info is None:
            raise self.InvalidInputException(
                'Feedback thread for current user and thread_id does not exist'
            )

        subject = 'New Oppia message in "%s"' % thread.subject
        email_manager.send_instant_feedback_message_email(
            user_id,
            message.author_id,
            message.text,
            subject,
            exploration.title,
            reference_dict['entity_id'],
            thread.subject,
            reply_to_id=feedback_thread_reply_info.reply_to_id)
        self.render_json({})
コード例 #4
0
ファイル: tasks.py プロジェクト: kevinlee12/oppia
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload["user_id"]
        references = feedback_services.get_feedback_message_references(user_id)
        if not references:
            # Model may not exist if user has already attended to the feedback.
            return

        transaction_services.run_in_transaction(feedback_services.update_feedback_email_retries, user_id)

        messages = {}
        for reference in references:
            message = feedback_services.get_message(reference.exploration_id, reference.thread_id, reference.message_id)

            exploration = exp_services.get_exploration_by_id(reference.exploration_id)

            message_text = message.text
            if len(message_text) > 200:
                message_text = message_text[:200] + "..."

            if exploration.id in messages:
                messages[exploration.id]["messages"].append(message_text)
            else:
                messages[exploration.id] = {"title": exploration.title, "messages": [message_text]}

        email_manager.send_feedback_message_email(user_id, messages)
        transaction_services.run_in_transaction(
            feedback_services.pop_feedback_message_references, user_id, len(references)
        )
コード例 #5
0
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        reference_dict = payload['reference_dict']

        message = feedback_services.get_message(
            reference_dict['exploration_id'], reference_dict['thread_id'],
            reference_dict['message_id'])
        exploration = exp_services.get_exploration_by_id(
            reference_dict['exploration_id'])
        thread = feedback_services.get_thread(
            reference_dict['exploration_id'], reference_dict['thread_id'])

        subject = 'New Oppia message in "%s"' % thread.subject
        email_manager.send_instant_feedback_message_email(
            user_id, message.author_id, message.text, subject,
            exploration.title, reference_dict['exploration_id'], thread.subject)
コード例 #6
0
ファイル: tasks.py プロジェクト: ysmilde/oppia
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        reference_dict = payload['reference_dict']
        old_status = payload['old_status']
        new_status = payload['new_status']

        message = feedback_services.get_message(
            reference_dict['thread_id'], reference_dict['message_id'])
        exploration = exp_fetchers.get_exploration_by_id(
            reference_dict['entity_id'])
        thread = feedback_services.get_thread(reference_dict['thread_id'])

        text = 'changed status from %s to %s' % (old_status, new_status)
        subject = 'Oppia thread status change: "%s"' % thread.subject
        email_manager.send_instant_feedback_message_email(
            user_id, message.author_id, text, subject, exploration.title,
            reference_dict['entity_id'], thread.subject)
コード例 #7
0
    def map(item):
        if item.subject != FeedbackSubjectOneOffJob.DEFAULT_SUBJECT:
            return

        first_message = feedback_services.get_message(item.id, 0)

        if not first_message.text:
            return

        if len(first_message.text) > constants.FEEDBACK_SUBJECT_MAX_CHAR_LIMIT:
            updated_subject = first_message.text[:constants.
                                                 FEEDBACK_SUBJECT_MAX_CHAR_LIMIT]

            if ' ' in updated_subject:
                updated_subject = ' '.join(updated_subject.split(' ')[:-1])

            item.subject = updated_subject + '...'
        else:
            item.subject = first_message.text
        item.put(update_last_updated_time=False)
コード例 #8
0
ファイル: tasks.py プロジェクト: abhijit5893/oppia
    def post(self):
        payload = json.loads(self.request.body)
        user_id = payload['user_id']
        reference_dict = payload['reference_dict']
        old_status = payload['old_status']
        new_status = payload['new_status']

        message = feedback_services.get_message(
            reference_dict['exploration_id'], reference_dict['thread_id'],
            reference_dict['message_id'])
        exploration = exp_services.get_exploration_by_id(
            reference_dict['exploration_id'])
        thread = feedback_services.get_thread(
            reference_dict['exploration_id'], reference_dict['thread_id'])

        text = 'changed status from %s to %s' % (old_status, new_status)
        subject = 'Oppia thread status change: "%s"' % thread.subject
        email_manager.send_instant_feedback_message_email(
            user_id, message.author_id, text, subject, exploration.title,
            reference_dict['exploration_id'], thread.subject)