def send_internship_score_encoding_recaps(period):
    organizations, specialties = _get_effective_internships_data(period)
    active_user_allocations = _get_active_user_allocations(
        organizations, specialties)

    for allocation in active_user_allocations:
        affectations = InternshipStudentAffectationStat.objects.filter(
            period=period,
            speciality=allocation.specialty,
            organization=allocation.organization).select_related(
                'score',
                'student__person').order_by('student__person__last_name')
        message_content = message_config.create_message_content(
            html_template_ref='internship_end_period_recap_html',
            txt_template_ref='internship_end_period_recap_txt',
            tables=[],
            receivers=[
                message_config.create_receiver(allocation.master.person_id,
                                               allocation.master.person.email,
                                               None)
            ],
            template_base_data={
                'apds':
                ['{}'.format(index) for index in range(1, APD_NUMBER + 1)],
                'allocation': allocation,
                'affectations': affectations,
                'period': period.name,
                'link': settings.INTERNSHIP_SCORE_ENCODING_URL
            },
            subject_data={'period': period.name})
        send_messages(message_content=message_content)
Esempio n. 2
0
 def test_build_and_send_messages_called_once_with_one_receiver(
         self, mock_get_all_lang_templates, mock_build_and_send_message):
     mock_get_all_lang_templates.return_value = 'template_html', 'template_txt'
     receiver = PersonFactory()
     receivers = [
         message_config.create_receiver(receiver.id, receiver.email, None)
     ]
     msg_content = message_config.create_message_content(
         'template_html', 'template_txt', [], receivers, {}, {})
     send_message.send_messages(msg_content)
     self.assertEqual(mock_build_and_send_message.call_count, 1)
Esempio n. 3
0
def send_email(template_references, receivers, data, connected_user=None):
    message_content = message_config.create_message_content(
        template_references['html'],
        template_references['txt'],
        [],
        receivers,
        data['template'],
        data['subject'],
        data.get('attachment', None)
    )
    message_service.send_messages(
        message_content=message_content,
        connected_user=connected_user
    )
def send_score_validated_email(score):
    message_content = message_config.create_message_content(
        html_template_ref='internship_score_validated_email_html',
        txt_template_ref='internship_score_validated_email_txt',
        tables=[],
        receivers=[
            message_config.create_receiver(
                score.student_affectation.student.person_id,
                score.student_affectation.student.person.email, None)
        ],
        template_base_data={
            'period': score.student_affectation.period.name,
            'link': settings.INTERNSHIP_SCORE_ENCODING_URL
        },
        subject_data={'period': score.student_affectation.period.name})
    send_messages(message_content=message_content)
Esempio n. 5
0
def send_mail_activation(request, activation_code, applicant,
                         template_reference):
    logger.info('Sending mail activation to : {} '.format(
        applicant.user.email))
    message_content = {
        'html_template_ref': '{0}_html'.format(template_reference),
        'txt_template_ref': '{0}_txt'.format(template_reference)
    }
    receivers = []
    receiver = {
        'receiver_email': applicant.user.email,
        'receiver_id': applicant.id
    }
    receivers.append(receiver)
    message_content['receivers'] = receivers
    activation_link = "{0}://{1}/admission/admission/user/{2}/activation".format(
        request.scheme, request.get_host(), activation_code)
    data = {
        'title':
        title(applicant.gender),
        'academic_year':
        academic_year.current_academic_year(),
        'activation_link':
        activation_link,
        'signature':
        render_to_string(
            'messaging/html_email_signature.html', {
                'logo_mail_signature_url': LOGO_EMAIL_SIGNATURE_URL,
                'logo_osis_url': LOGO_OSIS_URL
            })
    }

    message_content['template_base_data'] = data

    return send_message.send_messages(message_content)
Esempio n. 6
0
def send_mail_after_the_learning_unit_year_deletion(managers, acronym,
                                                    academic_year, msg_list):
    """
    Send email to the program managers after deletions made on a learning_unit_year or partials or classes
    :param acronym: the deleted learning unit
    :param academic_year: starting academic year at which the deletion must start (can be None if it is a learning_unit)
    :param msg_list : the list of the messages detailing the deletion
    :return An error message if the template is not in the database
    """

    # TODO : At the moment, there is no link between managers and learning_units. So here is an empty list.
    #Later on, we will have to call a function like 'get_managers(learning_unit_year)' instead.
    #Something like this :
    #managers = learning_unit_year.get_managers_of_learning_unit_year(learning_unit_year)

    html_template_ref = 'learning_unit_year_deletion_html'
    txt_template_ref = 'learning_unit_year_deletion_txt'
    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    suject_data = {'learning_unit_acronym': acronym}
    template_base_data = {
        'learning_unit_acronym': acronym,
        'academic_year': academic_year,
        'msg_list': msg_list,
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, suject_data, None)
    return message_service.send_messages(message_content)
Esempio n. 7
0
def send_mail_before_annual_procedure_of_automatic_postponement(
        end_academic_year, luys_to_postpone, luys_already_existing,
        luys_ending_this_year):
    html_template_ref = 'luy_before_auto_postponement_html'
    txt_template_ref = 'luy_before_auto_postponement_txt'

    permission = Permission.objects.filter(
        codename='can_receive_emails_about_automatic_postponement')
    managers = Person.objects.filter(Q(user__groups__permissions=permission) | Q(user__user_permissions=permission))\
        .distinct()

    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    template_base_data = {
        'academic_year': current_academic_year().year,
        'end_academic_year': end_academic_year.year,
        'luys_to_postpone': luys_to_postpone.count(),
        'luys_already_existing': luys_already_existing.count(),
        'luys_ending_this_year': luys_ending_this_year.count(),
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, None, None)
    return message_service.send_messages(message_content)
Esempio n. 8
0
def send_mail_after_annual_procedure_of_automatic_postponement_of_egy(
        end_academic_year, egys_postponed, egys_already_existing,
        egys_ending_this_year, egys_with_errors):
    html_template_ref = 'egy_after_auto_postponement_html'
    txt_template_ref = 'egy_after_auto_postponement_txt'

    permission = Permission.objects.filter(
        codename='can_receive_emails_about_automatic_postponement')
    managers = Person.objects.filter(Q(user__groups__permissions=permission) | Q(user__user_permissions=permission)) \
        .distinct()

    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    template_base_data = {
        'academic_year': end_academic_year.past().year,
        'end_academic_year': end_academic_year.year,
        'egys_postponed': len(egys_postponed),
        'egys_already_existing': len(egys_already_existing),
        'egys_ending_this_year': len(egys_ending_this_year),
        'egys_with_errors': egys_with_errors
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, None, None)
    return message_service.send_messages(message_content)
Esempio n. 9
0
def send_message(person,
                 html_template_ref,
                 txt_template_ref,
                 assistant=None,
                 role=None,
                 entity=None):
    procedure_dates = settings.get_settings()
    receivers = [
        message_config.create_receiver(person.id, person.email,
                                       person.language)
    ]
    template_base_data = {
        'start_date': procedure_dates.assistants_contract_end_starting_date,
        'end_date': procedure_dates.assistants_contract_end_ending_date,
        'first_name': person.first_name,
        'last_name': person.last_name,
        'roles': reviewer_role,
        'gender': person.gender
    }
    if assistant:
        template_base_data['assistant'] = assistant.person
    if role:
        template_base_data['role'] = role
    if entity:
        template_base_data['entity'] = entity
    subject_data = None
    table = None
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, table, receivers,
        template_base_data, subject_data)
    return message_service.send_messages(message_content)
Esempio n. 10
0
def send_mail_before_annual_procedure_of_automatic_postponement_of_egy(
        statistics_context: dict):
    html_template_ref = 'egy_before_auto_postponement_html'
    txt_template_ref = 'egy_before_auto_postponement_txt'

    permission = Permission.objects.filter(
        codename='can_receive_emails_about_automatic_postponement')
    managers = Person.objects.filter(Q(user__groups__permissions=permission) | Q(user__user_permissions=permission)) \
        .distinct()
    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    template_base_data = {
        'academic_year':
        statistics_context['max_academic_year_to_postpone'].past().year,
        'end_academic_year':
        statistics_context['max_academic_year_to_postpone'].year,

        # Use len instead of count() (it's buggy when a queryset is built with a difference())
        'egys_to_postpone':
        len(statistics_context['to_duplicate']),
        'egys_already_existing':
        statistics_context['already_duplicated'].count(),
        'egys_ending_this_year':
        statistics_context['ending_on_max_academic_year'].count(),
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, None, None)
    return message_service.send_messages(message_content)
Esempio n. 11
0
def send_mail_after_scores_submission(persons, learning_unit_name, submitted_enrollments, all_encoded):
    """
    Send an email to all the teachers after the scores submission for a learning unit
    :param persons: The list of the teachers of the leaning unit
    :param learning_unit_name: The name of the learning unit for which scores were submitted
    :param submitted_enrollments : The list of newly sibmitted enrollments
    :param all_encoded : Tell if all the scores are encoded and submitted
    :return An error message if the template is not in the database
    """

    html_template_ref = 'assessments_scores_submission_html'
    txt_template_ref = 'assessments_scores_submission_txt'
    receivers = [message_config.create_receiver(person.id, person.email, person.language) for person in persons]
    suject_data = {'learning_unit_name': learning_unit_name}
    template_base_data = {'learning_unit_name': learning_unit_name,
                          'encoding_status':    _('encoding_status_ended') if all_encoded
                          else _('encoding_status_notended')
                          }
    header_txt = ['acronym', 'session_title', 'registration_number', 'lastname', 'firstname', 'score', 'documentation']
    submitted_enrollments_data = [
        (
            enrollment.learning_unit_enrollment.offer_enrollment.offer_year.acronym,
            enrollment.session_exam.number_session,
            enrollment.learning_unit_enrollment.offer_enrollment.student.registration_id,
            enrollment.learning_unit_enrollment.offer_enrollment.student.person.last_name,
            enrollment.learning_unit_enrollment.offer_enrollment.student.person.first_name,
            enrollment.score_final,
            _(enrollment.justification_final) if enrollment.justification_final else None,
        ) for enrollment in submitted_enrollments]
    table = message_config.create_table('submitted_enrollments', header_txt, submitted_enrollments_data)

    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, [table], receivers,
                                                            template_base_data, suject_data)
    return message_service.send_messages(message_content)
Esempio n. 12
0
def send_mail_after_academic_calendar_changes(academic_calendar,
                                              offer_year_calendar,
                                              programm_managers):
    """
    Send an email to all the programme manager after changes has been made on a offer_year_calendar with customized
    = True
    :param academic_calendar:
    :param offer_year_calendar:
    :param programm_managers:
    :return un error message if the template does not exists.
    """

    html_template_ref = 'academic_calendar_changes_html'
    txt_template_ref = 'academic_calendar_changes_txt'
    receivers = [
        message_config.create_receiver(manager.person.id, manager.person.email,
                                       manager.person.language)
        for manager in programm_managers
    ]
    suject_data = {
        'offer_year': str(offer_year_calendar.offer_year.acronym),
        'academic_calendar': str(academic_calendar)
    }
    template_base_data = {
        'offer_year_title': offer_year_calendar.offer_year.title,
        'offer_year_acronym': offer_year_calendar.offer_year.acronym,
        'academic_calendar': str(academic_calendar),
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, suject_data)

    return message_service.send_messages(message_content)
Esempio n. 13
0
def _send_mail_action_learning_unit_proposal(manager, tuple_proposals_results,
                                             html_template_ref,
                                             txt_template_ref, operation,
                                             research_criteria):
    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
    ]
    suject_data = {}
    template_base_data = {
        "first_name": manager.first_name,
        "last_name": manager.last_name
    }
    attachment = (
        "report.xlsx",
        build_proposal_report_attachment(manager, tuple_proposals_results,
                                         operation, research_criteria),
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
    message_content = message_config.create_message_content(
        html_template_ref,
        txt_template_ref,
        None,
        receivers,
        template_base_data,
        suject_data,
        attachment=attachment)
    return message_service.send_messages(message_content)
Esempio n. 14
0
    def test_send_messages(self):
        count_messages_before_send = len(
            message_history.MessageHistory.objects.all())
        receivers = self.__make_receivers()
        tables = (self.__make_table(), )
        template_base_data = {
            'learning_unit_name': 'DROI1100',
        }
        subject_data = {}
        message_content = create_message_content(
            'assessments_scores_submission_html',
            'assessments_scores_submission_txt', tables, receivers,
            template_base_data, subject_data)
        message_error = send_message.send_messages(
            message_content=message_content,
            connected_user=self.connected_user)
        self.assertIsNone(message_error, 'No message error should be sent')
        count_messages_after_send_again = len(
            message_history.MessageHistory.objects.all())
        self.assertTrue(
            count_messages_after_send_again == count_messages_before_send + 5,
            '5 messages should have been sent')

        content_no_html_ref = create_message_content(
            None, 'assessments_scores_submission_txt', tables, receivers,
            template_base_data, subject_data)
        message_error = send_message.send_messages(
            message_content=content_no_html_ref,
            connected_user=self.connected_user)
        self.assertIsNotNone(message_error, 'A message error should be sent')

        content_no_receivers = create_message_content(
            'assessments_scores_submission_html',
            'assessments_scores_submission_txt', tables, None,
            template_base_data, subject_data)
        message_error = send_message.send_messages(
            message_content=content_no_receivers,
            connected_user=self.connected_user)
        self.assertIsNotNone(message_error, 'A message error should be sent')

        content_wrong_html_ref = create_message_content(
            'unknown_template_html', 'assessments_scores_submission_txt',
            tables, receivers, template_base_data, subject_data)
        message_error = send_message.send_messages(
            message_content=content_wrong_html_ref,
            connected_user=self.connected_user)
        self.assertIsNotNone(message_error, 'A message error should be sent')
Esempio n. 15
0
def send_mail_for_educational_information_update(teachers, learning_units_years):
    html_template_ref = EDUCATIONAL_INFORMATION_UPDATE_HTML
    txt_template_ref = EDUCATIONAL_INFORMATION_UPDATE_TXT
    receivers = [message_config.create_receiver(teacher.id, teacher.email, teacher.language) for teacher in teachers]
    template_base_data = {'learning_unit_years': learning_units_years}

    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, None, receivers,
                                                            template_base_data, {}, None)
    return message_service.send_messages(message_content)
Esempio n. 16
0
def send_email(dissert, template_ref, receivers):
    receivers = generate_receivers(receivers)
    html_template_ref = template_ref + '_html'
    txt_template_ref = template_ref + '_txt'
    suject_data = None
    template_base_data = get_base_template(dissert)
    tables = None
    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, tables, receivers,
                                                            template_base_data, suject_data)
    return message_service.send_messages(message_content)
def send_score_encoding_recap(data, connected_user):
    student_info = InternshipStudentInformation.objects.get(
        person__id=data['person_id'], cohort__id=data['cohort_id'])
    message_content = message_config.create_message_content(
        html_template_ref='internship_score_encoding_recap_email_html',
        txt_template_ref='internship_score_encoding_recap_email_txt',
        tables=[],
        receivers=[
            message_config.create_receiver(student_info.person_id,
                                           student_info.email, None)
        ],
        template_base_data={
            'today': data['today'],
            'periods': data['periods'],
            'ordered_periods': data['ordered_periods']
        },
        subject_data={})
    send_messages(message_content=message_content,
                  connected_user=connected_user)
Esempio n. 18
0
def send_mail_after_the_learning_unit_year_deletion(managers, acronym, academic_year, msg_list):
    html_template_ref = 'learning_unit_year_deletion_html'
    txt_template_ref = 'learning_unit_year_deletion_txt'
    receivers = [message_config.create_receiver(manager.id, manager.email, manager.language) for manager in managers]
    suject_data = {'learning_unit_acronym': acronym}
    template_base_data = {'learning_unit_acronym': acronym,
                          'academic_year': academic_year,
                          'msg_list':msg_list,
                          }
    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, None, receivers,
                                                            template_base_data, suject_data, None)
    return message_service.send_messages(message_content)
def send_email(dissert, template_ref, receivers):
    receivers = generate_receivers(receivers)
    html_template_ref = template_ref + '_html'
    txt_template_ref = template_ref + '_txt'
    suject_data = get_subject_template(dissert)
    if template_ref is not 'dissertation_to_commission_list':
        template_base_data = get_base_template(dissert)
    else:
        template_base_data = get_commission_template(dissert)
    tables = None
    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, tables, receivers,
                                                            template_base_data, suject_data)
    return message_service.send_messages(message_content)
Esempio n. 20
0
def send_message_after_all_encoded_by_manager(persons, enrollments,
                                              learning_unit_acronym,
                                              offer_acronym):
    """
    Send a message to all tutor from a learning unit when all scores are submitted by program manager
    :param persons: The list of the tutor (person) of the learning unit
    :param enrollments: The enrollments that are encoded and submitted
    :param learning_unit_acronym The learning unit encoded
    :param offer_acronym: The offer which is managed
    :return: A message if an error occured, None if it's ok
    """

    html_template_ref = 'assessments_all_scores_by_pgm_manager_html'
    txt_template_ref = 'assessments_all_scores_by_pgm_manager_txt'
    receivers = [
        message_config.create_receiver(person.id, person.email,
                                       person.language) for person in persons
    ]
    suject_data = {
        'learning_unit_acronym': learning_unit_acronym,
        'offer_acronym': offer_acronym
    }
    template_base_data = {
        'learning_unit_acronym': learning_unit_acronym,
        'offer_acronym': offer_acronym,
    }
    enrollments_data = [(
        enrollment.learning_unit_enrollment.offer_enrollment.offer_year.
        acronym,
        enrollment.session_exam.number_session,
        enrollment.learning_unit_enrollment.offer_enrollment.student.
        registration_id,
        enrollment.learning_unit_enrollment.offer_enrollment.student.person.
        last_name,
        enrollment.learning_unit_enrollment.offer_enrollment.student.person.
        first_name,
        enrollment.score_final,
        enrollment.justification_final
        if enrollment.justification_final else None,
    ) for enrollment in enrollments]
    enrollments_headers = ('acronym', 'session_title', 'registration_number',
                           'lastname', 'firstname', 'score', 'justification')
    table = message_config.create_table('enrollments',
                                        enrollments_headers,
                                        enrollments_data,
                                        data_translatable=['justification'])
    attachment = build_scores_sheet_attachment(enrollments)
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, [table], receivers,
        template_base_data, suject_data, attachment)
    return message_service.send_messages(message_content)
Esempio n. 21
0
def _send_mail_after_learning_unit_proposal_action(managers, proposals,
                                                   html_template_ref,
                                                   txt_template_ref):
    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    suject_data = {}
    template_base_data = {'proposals': proposals}
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, suject_data, None)
    return message_service.send_messages(message_content)
Esempio n. 22
0
def send_mail_after_annual_procedure_of_automatic_postponement_of_egy(
        statistics_context: dict, egys_postponed: list,
        egys_with_errors: list):

    html_template_ref = 'egy_after_auto_postponement_html'
    txt_template_ref = 'egy_after_auto_postponement_txt'

    permission = Permission.objects.filter(
        codename='can_receive_emails_about_automatic_postponement')
    managers = Person.objects.filter(Q(user__groups__permissions=permission) | Q(user__user_permissions=permission)) \
        .distinct()

    egys_postponed = [
        edy for edy in egys_postponed if edy.academic_year_id ==
        statistics_context['max_academic_year_to_postpone'].pk
    ]
    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    template_base_data = {
        'academic_year':
        statistics_context['max_academic_year_to_postpone'].past().year,
        'end_academic_year':
        statistics_context['max_academic_year_to_postpone'].year,
        'egys_postponed':
        len(egys_postponed),
        'egys_postponed_qs':
        sorted(egys_postponed, key=__sort_education_group_type),
        'egys_already_existing':
        statistics_context['already_duplicated'].count(),
        'egys_already_existing_qs':
        statistics_context['already_duplicated'].order_by(
            'educationgroupyear__education_group_type__name',
            'educationgroupyear__acronym'),
        'egys_ending_this_year':
        statistics_context['ending_on_max_academic_year'].count(),
        'egys_ending_this_year_qs':
        statistics_context['ending_on_max_academic_year'].order_by(
            'educationgroupyear__education_group_type__name',
            'educationgroupyear__acronym'),
        'egys_with_errors':
        sorted(egys_with_errors)
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, None, None)
    return message_service.send_messages(message_content)
def send_internship_period_encoding_reminder(period):
    organizations, specialties = _get_effective_internships_data(period)
    active_user_allocations = _get_active_user_allocations(
        organizations, specialties)
    deduplicated_active_masters = _get_deduplicated_active_masters(
        active_user_allocations)

    message_content = message_config.create_message_content(
        html_template_ref='internship_end_period_reminder_html',
        txt_template_ref='internship_end_period_reminder_txt',
        tables=[],
        receivers=[
            message_config.create_receiver(master_person_id, master_email,
                                           None)
            for master_person_id, master_email in deduplicated_active_masters
        ],
        template_base_data={
            'period': period.name,
            'link': settings.INTERNSHIP_SCORE_ENCODING_URL
        },
        subject_data={'period': period.name})
    send_messages(message_content=message_content)
    period.reminder_mail_sent = True
    period.save()
Esempio n. 24
0
def send_mail_after_annual_procedure_of_automatic_postponement_of_luy(
        statistics_context: dict, luys_postponed: list,
        luys_with_errors: list):
    html_template_ref = 'luy_after_auto_postponement_html'
    txt_template_ref = 'luy_after_auto_postponement_txt'

    permission = Permission.objects.get(
        codename='can_receive_emails_about_automatic_postponement')
    managers = Person.objects.filter(
        Q(user__groups__permissions=permission)
        | Q(user__user_permissions=permission)).distinct()

    receivers = [
        message_config.create_receiver(manager.id, manager.email,
                                       manager.language)
        for manager in managers
    ]
    template_base_data = {
        'academic_year':
        statistics_context['max_academic_year_to_postpone'].past(),
        'end_academic_year':
        statistics_context['max_academic_year_to_postpone'],
        'luys_postponed':
        len(luys_postponed),
        'luys_postponed_qs':
        sorted(luys_postponed, key=lambda luy: luy.acronym),
        'luys_already_existing':
        statistics_context['already_duplicated'].count(),
        'luys_already_existing_qs':
        statistics_context['already_duplicated'].order_by(
            "learningunityear__acronym"),
        'luys_ending_this_year':
        statistics_context['ending_on_max_academic_year'].count(),
        'luys_ending_this_year_qs':
        statistics_context['ending_on_max_academic_year'].order_by(
            "learningunityear__acronym"),
        'luys_with_errors':
        luys_with_errors
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, None, receivers,
        template_base_data, None, None)
    return message_service.send_messages(message_content)
Esempio n. 25
0
def send_mail_to_teacher_new_dissert(adviser):
    """
    Notify (for the teacher) of a new dissertation project
    """
    html_template_ref = 'dissertation_adviser_new_project_dissertation_html'
    txt_template_ref = 'dissertation_adviser_new_project_dissertation_txt'
    receivers = [
        message_config.create_receiver(adviser.person.id, adviser.person.email,
                                       adviser.person.language)
    ]
    suject_data = None
    template_base_data = {
        'adviser': adviser,
    }
    tables = None
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, tables, receivers,
        template_base_data, suject_data)
    return message_service.send_messages(message_content)
Esempio n. 26
0
def send_message(person, html_template_ref, txt_template_ref, assistant=None, role=None, entity=None):
    procedure_dates = settings.get_settings()
    receivers = [message_config.create_receiver(person.id, person.email,
                                                person.language)]
    template_base_data = {'start_date': procedure_dates.assistants_contract_end_starting_date,
                          'end_date': procedure_dates.assistants_contract_end_ending_date,
                          'first_name': person.first_name, 'last_name': person.last_name,
                          'roles': reviewer_role,
                          'gender': person.gender}
    if assistant:
        template_base_data['assistant'] = assistant.person
    if role:
        template_base_data['role'] = role
    if entity:
        template_base_data['entity'] = entity
    subject_data = None
    table = None
    message_content = message_config.create_message_content(html_template_ref, txt_template_ref, table,
                                                            receivers, template_base_data, subject_data)
    return message_service.send_messages(message_content)
Esempio n. 27
0
def send_mail_activation(request, activation_code, applicant, template_reference):
    logger.info('Sending mail activation to : {} '.format(applicant.user.email))
    message_content = {'html_template_ref': '{0}_html'.format(template_reference),
                       'txt_template_ref': '{0}_txt'.format(template_reference)}
    receivers = []
    receiver = {'receiver_email': applicant.user.email,
                'receiver_id': applicant.id}
    receivers.append(receiver)
    message_content['receivers'] = receivers
    activation_link = "{0}://{1}/admission/admission/user/{2}/activation".format(request.scheme,
                                                                                 request.get_host(),
                                                                                 activation_code)
    data = {'title': title(applicant.gender),
            'academic_year': academic_year.current_academic_year(),
            'activation_link': activation_link,
            'signature': render_to_string('messaging/html_email_signature.html',
                                          {'logo_mail_signature_url': LOGO_EMAIL_SIGNATURE_URL,
                                           'logo_osis_url': LOGO_OSIS_URL})}

    message_content['template_base_data'] = data

    return send_message.send_messages(message_content)
Esempio n. 28
0
def send_mail_applications_summary(global_id):
    application_list = get_application_list(global_id)
    if not application_list:
        return _('No application found')
    person = mdl_base.person.find_by_global_id(global_id)

    html_template_ref = 'applications_confirmation_html'
    txt_template_ref = 'applications_confirmation_txt'
    receivers = [
        message_config.create_receiver(person.id, person.email,
                                       person.language)
    ]
    applications = _get_applications_table(application_list)
    table_applications = message_config.create_table(
        'applications', [_('Acronym'), 'Vol. 1', 'Vol. 2'], applications)
    template_base_data = {
        'first_name': person.first_name,
        'last_name': person.last_name,
    }
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, [table_applications], receivers,
        template_base_data, None)
    return message_service.send_messages(message_content)
def send_message(person, html_template_ref, txt_template_ref, assistant=None):
    procedure_dates = settings.get_settings()
    receivers = [
        message_config.create_receiver(person.id, person.email,
                                       person.language)
    ]
    first_ending_year = academic_year.current_academic_year().year + 1
    last_ending_year = first_ending_year + 1
    template_base_data = {
        'start_date': procedure_dates.starting_date,
        'end_date': procedure_dates.ending_date,
        'first_name': person.first_name,
        'last_name': person.last_name,
        'first_ending_year': first_ending_year,
        'last_ending_year': last_ending_year
    }
    if assistant is not None:
        template_base_data['assistant'] = assistant.person
    subject_data = None
    table = None
    message_content = message_config.create_message_content(
        html_template_ref, txt_template_ref, table, receivers,
        template_base_data, subject_data)
    return message_service.send_messages(message_content)