示例#1
0
文件: views.py 项目: wanshot/trdist
def _notify_sender(form_data, request):
    content = render_to_string('email/contact_general.txt',
                               {'data': form_data},
                               context_instance=RequestContext(request))
    subject = render_to_string('email/contact_general_subject.txt',
                               {'data': form_data},
                               context_instance=RequestContext(request))
    subject = subject.replace("\n", "")
    mail = EmailMessage(
        subject=subject,
        body=content,
        from_email=settings.SERVER_EMAIL,
        to=[form_data['email']],
    )
    mail.send()
    request_data = {
        'ip': get_request_addr_or_ip(request),
        'ua': get_request_ua(request),
    }
    admin_content = render_to_string('email/contact_general.txt', {
        'data': form_data,
        'request_data': request_data,
        'user': request.user,
    },
                                     context_instance=RequestContext(request))
    subject = 'admin' + subject
    admin_mail = EmailMessage(
        subject=subject,
        body=admin_content,
        from_email=settings.SERVER_EMAIL,
        to=[settings.CONTACT_EMAIL],
    )
    admin_mail.send()
示例#2
0
文件: views.py 项目: wanshot/trdist
def _add_download_log(document, form, user, company, request):
    p = user.myuserprofile
    log = DocumentDownloadLog(
        # Document
        document_id=document.id,
        document_title=document.title,
        # Company
        company=company,
        # MyUser
        user_id=user.id,
        email=user.email,
        # MyUserProfile
        last_name=p.last_name,
        first_name=p.first_name,
        last_name_kana=p.last_name_kana,
        first_name_kana=p.first_name_kana,
        company_name=p.company_name,
        tel=p.tel,
        fax=p.fax,
        post_number=p.post_number,
        prefecture=p.get_prefecture_display(),
        address=p.address,
        site_url=p.site_url,
        department=p.department,
        position=p.position,
        position_class=p.get_position_class_display(),
        business_type=p.get_business_type_display(),
        job_content=p.get_job_content_display(),
        firm_size=p.get_firm_size_display(),
        yearly_sales=p.get_yearly_sales_display(),
        discretion=p.get_discretion_display(),
        # DonwloadForm
        stage=dict(form.fields['stage'].choices)[
            int(form.cleaned_data['stage'])
        ],
        # request
        ip=get_request_addr_or_ip(request),
        ua=get_request_ua(request),
    )
    log.save()
    return log
示例#3
0
文件: views.py 项目: wanshot/trdist
def _notify_sender(form_data, request):
    content = render_to_string(
        "email/contact_general.txt", {"data": form_data}, context_instance=RequestContext(request)
    )
    subject = render_to_string(
        "email/contact_general_subject.txt", {"data": form_data}, context_instance=RequestContext(request)
    )
    subject = subject.replace("\n", "")
    mail = EmailMessage(subject=subject, body=content, from_email=settings.SERVER_EMAIL, to=[form_data["email"]])
    mail.send()
    request_data = {"ip": get_request_addr_or_ip(request), "ua": get_request_ua(request)}
    admin_content = render_to_string(
        "email/contact_general.txt",
        {"data": form_data, "request_data": request_data, "user": request.user},
        context_instance=RequestContext(request),
    )
    subject = "admin" + subject
    admin_mail = EmailMessage(
        subject=subject, body=admin_content, from_email=settings.SERVER_EMAIL, to=[settings.CONTACT_EMAIL]
    )
    admin_mail.send()
示例#4
0
文件: views.py 项目: wanshot/trdist
def _add_entry_log(seminar, form, user, company, request):
    p = user.myuserprofile
    log = SeminarEntryLog(
        # Seminar
        seminar_id=seminar.id,
        seminar_title=seminar.title,
        seminar_type=dict(TYPE_CHOICE)[seminar.type],
        # Company
        company=company,
        # MyUser
        user_id=user.id,
        email=user.email,
        # MyUserProfile
        last_name=p.last_name,
        first_name=p.first_name,
        last_name_kana=p.last_name_kana,
        first_name_kana=p.first_name_kana,
        company_name=p.company_name,
        tel=p.tel,
        fax=p.fax,
        post_number=p.post_number,
        prefecture=p.get_prefecture_display(),
        address=p.address,
        site_url=p.site_url,
        department=p.department,
        position=p.position,
        position_class=p.get_position_class_display(),
        business_type=p.get_business_type_display(),
        job_content=p.get_job_content_display(),
        firm_size=p.get_firm_size_display(),
        yearly_sales=p.get_yearly_sales_display(),
        discretion=p.get_discretion_display(),
        # DonwloadForm
        note=form.cleaned_data['note'],
        # request
        ip=get_request_addr_or_ip(request),
        ua=get_request_ua(request),
    )
    log.save()
    return log
示例#5
0
def _add_download_log(document, form, user, company, request):
    p = user.myuserprofile
    log = DocumentDownloadLog(
        # Document
        document_id=document.id,
        document_title=document.title,
        # Company
        company=company,
        # MyUser
        user_id=user.id,
        email=user.email,
        # MyUserProfile
        last_name=p.last_name,
        first_name=p.first_name,
        last_name_kana=p.last_name_kana,
        first_name_kana=p.first_name_kana,
        company_name=p.company_name,
        tel=p.tel,
        fax=p.fax,
        post_number=p.post_number,
        prefecture=p.get_prefecture_display(),
        address=p.address,
        site_url=p.site_url,
        department=p.department,
        position=p.position,
        position_class=p.get_position_class_display(),
        business_type=p.get_business_type_display(),
        job_content=p.get_job_content_display(),
        firm_size=p.get_firm_size_display(),
        yearly_sales=p.get_yearly_sales_display(),
        discretion=p.get_discretion_display(),
        # DonwloadForm
        stage=dict(form.fields['stage'].choices)[int(
            form.cleaned_data['stage'])],
        # request
        ip=get_request_addr_or_ip(request),
        ua=get_request_ua(request),
    )
    log.save()
    return log