Пример #1
0
def work_email_send(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST
    email_addr = request_form.get("to_email", "")
    license_name = request_form.get("license_name")
    license_html = request_form.get("license_html")

    util.send_license_info_email(license_name, license_html, email_addr, target_lang)

    context = _base_context(request, target_lang)
    context["request_form"] = request_form

    return util.render_to_response(request, target_lang, "chooser_pages/emailhtml.html", context)
Пример #2
0
def work_email_send(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST
    email_addr = request_form.get('to_email', '')
    license_name = request_form.get('license_name')
    license_html = request_form.get('license_html')

    util.send_license_info_email(license_name, license_html, email_addr,
                                 target_lang)

    context = _base_context(request, target_lang)
    context['request_form'] = request_form

    return util.render_to_response(request, target_lang,
                                   'chooser_pages/emailhtml.html', context)
Пример #3
0
def work_email_send(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST
    email_addr = request_form.get('to_email', '')
    license_name = request_form.get('license_name')
    license_html = request_form.get('license_html')

    util.send_license_info_email(
        license_name, license_html,
        email_addr, target_lang)

    context = _base_context(request, target_lang)
    context['request_form'] = request_form

    return util.render_to_response(
        request, target_lang,
        'chooser_pages/emailhtml.html', context)
Пример #4
0
def test_send_license_info_email():
    util._clear_test_inboxes()

    util.send_license_info_email(
        'Creative Commons Very-Silly License 5.8',
        SILLY_LICENSE_HTML,
        '*****@*****.**', 'en')

    assert len(util.EMAIL_TEST_INBOX) == 1
    message = util.EMAIL_TEST_INBOX.pop()
    assert message['From'] == "*****@*****.**"
    assert message['To'] == "*****@*****.**"
    assert message['Subject'] == "Your Creative Commons License Information"
    
    normal_payload = """Thank you for using a Creative Commons legal tool for your work.

You have selected Creative Commons Very-Silly License 5.8.
You should include a reference to this on the web page that includes
the work in question.

Here is the suggested HTML:

This work available under a
<a href="http://example.org/goes/nowhere">very silly license</a>.

Tips for marking your work can be found at
http://wiki.creativecommons.org/Marking.  Information on the supplied HTML and
metadata can be found at http://wiki.creativecommons.org/CC_REL.

This email and tech support has been brought to you by the nonprofit folks at
Creative Commons. CC relies on donations to provide you with licenses and
services like this. Please consider a donation to our annual fund:
https://creativecommons.net/donate.

Thank you!
Creative Commons Support
[email protected]"""
    campaign_payload = """Thank you for using a Creative Commons legal tool for your work.\n\nYou have selected Creative Commons Very-Silly License 5.8.\nYou should include a reference to this on the web page that includes\nthe work in question.\n\nHere is the suggested HTML:\n\nThis work available under a\n<a href="http://example.org/goes/nowhere">very silly license</a>.\n\nTips for marking your work can be found at\nhttp://wiki.creativecommons.org/Marking.  Information on the supplied HTML and\nmetadata can be found at http://wiki.creativecommons.org/CC_REL.\n\nThis email and tech support has been brought to you by the nonprofit folks at\nCreative Commons. CC relies on donations to provide you with licenses and\nservices like this. Please consider a donation to our annual fund:\nhttps://creativecommons.net/donate.\n\nThank you!\nCreative Commons Support\[email protected]"""

    assert message.get_payload() in [normal_payload, campaign_payload]
Пример #5
0
def test_send_license_info_email():
    util._clear_test_inboxes()

    util.send_license_info_email('Creative Commons Very-Silly License 5.8',
                                 SILLY_LICENSE_HTML,
                                 '*****@*****.**', 'en')

    assert len(util.EMAIL_TEST_INBOX) == 1
    message = util.EMAIL_TEST_INBOX.pop()
    assert message['From'] == "*****@*****.**"
    assert message['To'] == "*****@*****.**"
    assert message['Subject'] == "Your Creative Commons License Information"

    normal_payload = """Thank you for using a Creative Commons legal tool for your work.

You have selected Creative Commons Very-Silly License 5.8.
You should include a reference to this on the web page that includes
the work in question.

Here is the suggested HTML:

This work available under a
<a href="http://example.org/goes/nowhere">very silly license</a>.

Tips for marking your work can be found at
http://wiki.creativecommons.org/Marking.  Information on the supplied HTML and
metadata can be found at http://wiki.creativecommons.org/CC_REL.

This email and tech support has been brought to you by the nonprofit folks at
Creative Commons. CC relies on donations to provide you with licenses and
services like this. Please consider a donation to our annual fund:
https://creativecommons.net/donate.

Thank you!
Creative Commons Support
[email protected]"""
    campaign_payload = """Thank you for using a Creative Commons legal tool for your work.\n\nYou have selected Creative Commons Very-Silly License 5.8.\nYou should include a reference to this on the web page that includes\nthe work in question.\n\nHere is the suggested HTML:\n\nThis work available under a\n<a href="http://example.org/goes/nowhere">very silly license</a>.\n\nTips for marking your work can be found at\nhttp://wiki.creativecommons.org/Marking.  Information on the supplied HTML and\nmetadata can be found at http://wiki.creativecommons.org/CC_REL.\n\nThis email and tech support has been brought to you by the nonprofit folks at\nCreative Commons. CC relies on donations to provide you with licenses and\nservices like this. Please consider a donation to our annual fund:\nhttps://creativecommons.net/donate.\n\nThank you!\nCreative Commons Support\[email protected]"""

    assert message.get_payload() in [normal_payload, campaign_payload]
Пример #6
0
def cc0_results(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## Do we confirm, understand and accept the conditions of cc0?
    confirm = request_form.get('confirm', False)
    understand = request_form.get('understand', False)
    accept = request_form.get('waiver-affirm', False) and \
        request_form.get('waiver-decline', True)

    can_issue = (confirm and understand and accept)

    ## RDFA generation
    cc0_license = cc.license.by_code('CC0')
    license_html = CC0_HTML_FORMATTER.format(cc0_license, request_form,
                                             target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            cc0_license.title(target_lang), license_html, email_addr,
            target_lang)

    context = _base_context(request, target_lang)
    context.update({
        'request_form':
        request_form,
        'can_issue':
        can_issue,
        'rdfa':
        license_html,
        'email_requested':
        bool(email_addr),
        'email_addr':
        email_addr,
        'requested_send_updates':
        request_form.get('send_updates', False),
        'successful_send':
        successful_send
    })

    return util.render_to_response(request, target_lang,
                                   'chooser_pages/zero/results.html', context)
Пример #7
0
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code('mark')
    license_html = PDMARK_HTML_FORMATTER.format(license, request_form,
                                                target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html, email_addr, target_lang)

    context = _base_context(request, target_lang)
    context.update({
        'request_form':
        request_form,
        'rdfa':
        license_html,
        'email_requested':
        bool(email_addr),
        'email_addr':
        email_addr,
        'successful_send':
        successful_send,
        'requested_send_updates':
        request_form.get('send_updates', False)
    })

    return util.render_to_response(request, target_lang,
                                   'chooser_pages/pdmark/results.html',
                                   context)
Пример #8
0
def cc0_results(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## Do we confirm, understand and accept the conditions of cc0?
    confirm = request_form.get('confirm', False)
    understand = request_form.get('understand', False)
    accept = request_form.get('waiver-affirm', False) and \
        request_form.get('waiver-decline', True)

    can_issue = (confirm and understand and accept)

    ## RDFA generation
    cc0_license = cc.license.by_code('CC0')
    license_html = CC0_HTML_FORMATTER.format(
        cc0_license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            cc0_license.title(target_lang), license_html,
            email_addr, target_lang)

    context = _base_context(request, target_lang)
    context.update({
            'request_form': request_form,
            'can_issue': can_issue,
            'rdfa': license_html,
            'email_requested': bool(email_addr),
            'email_addr': email_addr,
            'requested_send_updates': request_form.get('send_updates', False),
            'successful_send': successful_send})

    return util.render_to_response(
        request, target_lang,
        'chooser_pages/zero/results.html', context)
Пример #9
0
def cc0_results(request):
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## Do we confirm, understand and accept the conditions of cc0?
    confirm = request_form.get("confirm", False)
    understand = request_form.get("understand", False)
    accept = request_form.get("waiver-affirm", False) and request_form.get("waiver-decline", True)

    can_issue = confirm and understand and accept

    ## RDFA generation
    cc0_license = cc.license.by_code("CC0")
    license_html = CC0_HTML_FORMATTER.format(cc0_license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get("email")
    successful_send = False
    if email_addr and request.method == "POST":
        successful_send = util.send_license_info_email(
            cc0_license.title(target_lang), license_html, email_addr, target_lang
        )

    context = _base_context(request, target_lang)
    context.update(
        {
            "request_form": request_form,
            "can_issue": can_issue,
            "rdfa": license_html,
            "email_requested": bool(email_addr),
            "email_addr": email_addr,
            "requested_send_updates": request_form.get("send_updates", False),
            "successful_send": successful_send,
        }
    )

    return util.render_to_response(request, target_lang, "chooser_pages/zero/results.html", context)
Пример #10
0
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code('mark')
    license_html = PDMARK_HTML_FORMATTER.format(
        license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get('email')
    successful_send = False
    if email_addr and request.method == 'POST':
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html,
            email_addr, target_lang)

    context = _base_context(request, target_lang)
    context.update({
            'request_form': request_form,
            'rdfa': license_html,
            'email_requested': bool(email_addr),
            'email_addr': email_addr,
            'successful_send': successful_send,
            'requested_send_updates': request_form.get('send_updates', False)})

    return util.render_to_response(
        request, target_lang,
        'chooser_pages/pdmark/results.html', context)
Пример #11
0
def pdmark_results(request):
    """
    Results page for the Public Domain Mark chooser.

    Includes the user's RDFa copy-paste html.
    Also handles email sending if the user requests it.
    """
    target_lang = util.get_target_lang_from_request(request)

    request_form = request.GET or request.POST

    ## RDFA generation
    license = cc.license.by_code("mark")
    license_html = PDMARK_HTML_FORMATTER.format(license, request_form, target_lang).strip()

    ## Did the user request an email?
    email_addr = request_form.get("email")
    successful_send = False
    if email_addr and request.method == "POST":
        successful_send = util.send_license_info_email(
            license.title(target_lang), license_html, email_addr, target_lang
        )

    context = _base_context(request, target_lang)
    context.update(
        {
            "request_form": request_form,
            "rdfa": license_html,
            "email_requested": bool(email_addr),
            "email_addr": email_addr,
            "successful_send": successful_send,
            "requested_send_updates": request_form.get("send_updates", False),
        }
    )

    return util.render_to_response(request, target_lang, "chooser_pages/pdmark/results.html", context)