Exemplo n.º 1
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)
Exemplo n.º 2
0
def generate_receivers(receivers):
    return [
        message_config.create_receiver(receiver.person.id,
                                       receiver.person.email,
                                       receiver.person.language)
        for receiver in receivers
    ]
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
def generate_receivers(*receivers):
    receivers_tab = []
    for receiver in receivers:
        receivers_tab.append(message_config.create_receiver(receiver.person.id,
                                                            receiver.person.email,
                                                            receiver.person.language))
    return receivers_tab
Exemplo n.º 8
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)
Exemplo n.º 9
0
def send_mail_before_annual_procedure_of_automatic_postponement_of_luy(
        statistics_context: dict):
    html_template_ref = 'luy_before_auto_postponement_html'
    txt_template_ref = 'luy_before_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'],

        # Use len instead of count() (it's buggy when a queryset is built with a difference())
        'luys_to_postpone':
        len(statistics_context['to_duplicate']),
        'luys_already_existing':
        statistics_context['already_duplicated'].count(),
        'luys_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)
Exemplo n.º 10
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)
Exemplo n.º 11
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)
Exemplo n.º 12
0
def _get_admission_managers_email_receivers(admission):
    if admission.formation.send_notification_emails is False:
        return []

    alternative_email_receivers = admission.formation.get_alternative_notification_email_receivers(
    )
    if alternative_email_receivers:
        return [
            message_config.create_receiver(None, receiver_email, None)
            for receiver_email in alternative_email_receivers
        ]
    else:
        return [
            message_config.create_receiver(manager.id, manager.email,
                                           manager.language)
            for manager in admission.formation.managers.all() if manager.email
        ]
Exemplo n.º 13
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)
Exemplo n.º 14
0
 def test_build_participant_receivers_1_unique_email(self):
     self.admission.email = self.admission.person_information.person.email
     self.admission.save()
     receivers = _build_participant_receivers(self.admission)
     excepted_receivers = [
         message_config.create_receiver(
             self.admission.person_information.person.id,
             self.admission.email, None)
     ]
     self.assertCountEqual(receivers, excepted_receivers)
Exemplo n.º 15
0
def _build_participant_receivers(admission):
    person = admission.person_information.person
    receivers_emails = [
        mail for mail in [person.email, admission.email] if mail
    ]
    unique_receivers_emails = set(receivers_emails)
    receivers = [
        message_config.create_receiver(person.id, mail, None)
        for mail in unique_receivers_emails
    ]
    return receivers
Exemplo n.º 16
0
 def test_build_participant_receivers_2_different_emails(self):
     receivers = _build_participant_receivers(self.admission)
     excepted_receivers = [
         message_config.create_receiver(
             self.admission.person_information.person.id, mail, None)
         for mail in [
             self.admission.email,
             self.admission.person_information.person.email
         ]
     ]
     self.assertCountEqual(receivers, excepted_receivers)
Exemplo n.º 17
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)
Exemplo 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)
Exemplo n.º 19
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)
Exemplo n.º 20
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)
Exemplo n.º 21
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)
Exemplo n.º 22
0
 def test_send_again(self):
     count_messages_before_send_again = len(
         message_history.MessageHistory.objects.all())
     message = message_history.MessageHistory.objects.get(id=1)
     receiver = create_receiver(message.receiver_id,
                                '*****@*****.**', 'fr-BE')
     message = send_again(receiver, message.id)
     self.assertIsNotNone(message,
                          'Message history should have been sent again')
     count_messages_after_send_again = len(
         message_history.MessageHistory.objects.all())
     self.assertTrue(
         count_messages_after_send_again == count_messages_before_send_again
         + 1, 'It should be {} messges in messages history'.format(
             count_messages_before_send_again + 1))
Exemplo n.º 23
0
def save_state_changed_and_send_email(admission, connected_user=None):
    person = admission.person_information.person
    mails = _get_managers_mails(admission.formation)
    condition_of_acceptance, registration_required = None, None
    state_message = get_valid_state_change_message(admission)
    save_and_create_revision(get_revision_messages(state_message), admission, connected_user)
    if admission.state in (SUBMITTED, REGISTRATION_SUBMITTED):
        send_submission_email_to_admission_managers(admission, connected_user)
        send_submission_email_to_participant(admission, connected_user)
        return
    elif admission.state in (ACCEPTED, REJECTED, WAITING, VALIDATED, ACCEPTED_NO_REGISTRATION_REQUIRED):
        condition_of_acceptance, lower_state, registration_required = _get_datas_from_admission(admission)
    else:
        lower_state = 'other'

    send_email(
        template_references={
            'html': 'iufc_participant_state_changed_{}_html'.format(lower_state),
            'txt': 'iufc_participant_state_changed_{}_txt'.format(lower_state),
        },
        data={
            'template': {
                'first_name': admission.person_information.person.first_name,
                'last_name': admission.person_information.person.last_name,
                'formation': admission.formation,
                'state': _(admission.state),
                'reason': admission.state_reason if admission.state_reason else '-',
                'mails': mails,
                'original_state': _(admission._original_state),
                'condition_of_acceptance': condition_of_acceptance,
                'registration_required': registration_required
            },
            'subject': {
                'state': _(admission.state)
            }
        },
        receivers=[
            message_config.create_receiver(
                person.id,
                person.email,
                None
            )
        ],
        connected_user=connected_user
    )

    MAIL['text'] = MAIL_MESSAGE % {'receiver': person.email}
    save_and_create_revision(get_revision_messages(MAIL), admission, connected_user)
Exemplo n.º 24
0
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)
Exemplo n.º 25
0
def send_again(message_history_id):
    """
    send a message from message history again
    :param message_history_id The id of the message history to send again
    :return the sent message

    TO-DO : correction of send_message in osis-common to get the associated receiver , based on id and receiver model

    """
    message_history = message_history_mdl.find_by_id(message_history_id)
    person = person_mdl.find_by_id(message_history.receiver_id)
    if person:
        receiver = message_config.create_receiver(person.id, person.email, person.language)
        return message_service.send_again(receiver, message_history_id)
    else:
        return _('no_receiver_error')
Exemplo n.º 26
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)
Exemplo n.º 27
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)
Exemplo n.º 28
0
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)
Exemplo n.º 29
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)
Exemplo n.º 30
0
def _send_creation_account_email(master, connected_user=None):
    set_password_link = '{}?email={}'.format(
        settings.LDAP_ACCOUNT_CONFIGURATION_URL, master.person.email)

    send_email(template_references={
        'html': 'internship_create_master_account_email_html',
        'txt': 'internship_create_master_account_email_txt',
    },
               data={
                   'template': {
                       'set_password_link':
                       set_password_link,
                       'score_encoding_link':
                       settings.INTERNSHIP_SCORE_ENCODING_URL
                   },
                   'subject': {}
               },
               receivers=[
                   message_config.create_receiver(master.id,
                                                  master.person.email, None)
               ],
               connected_user=connected_user)
Exemplo n.º 31
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)