Пример #1
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)
Пример #2
0
def settings_edit(request):
    """Use to edit app settings."""
    global_settings = settings.get_settings()
    if global_settings:
        form = SettingsForm(initial={
            'starting_date':
            global_settings.starting_date,
            'ending_date':
            global_settings.ending_date,
            'assistants_starting_date':
            global_settings.assistants_starting_date,
            'assistants_ending_date':
            global_settings.assistants_ending_date,
            'assistants_contract_end_starting_date':
            global_settings.assistants_contract_end_starting_date,
            'assistants_contract_end_ending_date':
            global_settings.assistants_contract_end_ending_date
        },
                            prefix="set",
                            instance=global_settings)
    else:
        form = SettingsForm(prefix="set", instance=global_settings)
    year = academic_year.current_academic_year().year
    return layout.render(request, 'settings.html', {
        'year': year,
        'form': form,
    })
Пример #3
0
def settings_save(request):
    global_settings = settings.get_settings()
    form = SettingsForm(data=request.POST, instance=global_settings, prefix='set')
    if form.is_valid():
        form.save()
        return settings_edit(request)
    else:
        year = academic_year.current_academic_year().year
        return layout.render(request, 'settings.html', {'year': year,
                                                        'form': form})
Пример #4
0
def settings_save(request):
    global_settings = settings.get_settings()
    form = SettingsForm(data=request.POST,
                        instance=global_settings,
                        prefix='set')
    if form.is_valid():
        form.save()
        return settings_edit(request)
    else:
        year = academic_year.starting_academic_year().year
        return render(request, 'settings.html', {'year': year, 'form': form})
Пример #5
0
def settings_edit(request):
    """Use to edit app settings."""
    global_settings = settings.get_settings()
    if global_settings:
        form = SettingsForm(
            initial={'starting_date': global_settings.starting_date,
                     'ending_date': global_settings.ending_date,
                     'assistants_starting_date': global_settings.assistants_starting_date,
                     'assistants_ending_date': global_settings.assistants_ending_date,
                     'assistants_contract_end_starting_date': global_settings.assistants_contract_end_starting_date,
                     'assistants_contract_end_ending_date': global_settings.assistants_contract_end_ending_date
                     }, prefix="set", instance=global_settings)
    else:
        form = SettingsForm(prefix="set", instance=global_settings)
    year = academic_year.current_academic_year().year
    return layout.render(request, 'settings.html', {'year': year,
                                                    'form': form,
                                                    })
Пример #6
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)
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)