[cc-commits] [SCM] cc.engine: License chooser, public domain chooser, deeds (branch i18noverhaul) updated. b09aadfb1887f3b64366ae097a287e0c7ab59e16

Gitosis User git at gandi0.creativecommons.org
Fri Jan 13 17:44:11 EST 2012


The branch, i18noverhaul has been updated
       via  b09aadfb1887f3b64366ae097a287e0c7ab59e16 (commit)
       via  903d85a87a4551277c3b1b2145e47776c9dda9d3 (commit)
       via  723e4be63b54a015fda80e1a87a18ec199007d1d (commit)
       via  9de8c826bf7eac8da78c7493483358fc97d15dbb (commit)
       via  99b52d506c53384bc87e85d4b9c0b9b51809efb0 (commit)
       via  3fd160008aec0ca260b4eb8f02bfb7ea2be2c96a (commit)
       via  e483934d036534a6eb8045ba570f17ab9627bf6c (commit)
       via  99a650e0f61deaee4c86496c47862504d11daad2 (commit)
       via  d34ca9e3d048c23af5b4d956f921c05ab6dee210 (commit)
       via  a37583ee30145e01ccf70f4c58686612cff58c91 (commit)
       via  5e9ee44ddf0a74aefb9f9d4d3ea3b6eaa246e1a7 (commit)
       via  e54e0dccd6a0c5c8c7970d23a66f04f68eda8b05 (commit)
       via  37e95e2ae084895194aa61fe91a71fee703d0830 (commit)
       via  6c95218db9202024f2767b04497644db9d595acb (commit)
       via  0efb141a92e2cdbf57ab52375f5d0a151c3735af (commit)
       via  8a38eccdd76fe291405cfeebde7989267c88b61f (commit)
       via  39080e5798720dc6f242aba339b13dafc07b73e5 (commit)
       via  ae1d454bcabfb70e8adf88908dd63f4a5d389756 (commit)
       via  27426b8d49d3ddce9f3553325c3efe0591136ddc (commit)
       via  aba430c2d4b3b981f785cf3e99e5ccec9b2607a2 (commit)
       via  d298bef62046687d39f7473001070930518a5e9b (commit)
       via  f4357a2fa831cb82184e4253998a356f83cf7bcf (commit)
       via  27a4eac95e689ffd7c82d6b0c8b503de9998e7c4 (commit)
       via  e1f072e665afeba2f287b3718e2b3ccbbae08fcd (commit)
       via  523a433022aed96d1878a1f6157c78003a1bd743 (commit)
       via  c4cc3414d68dd5c609fd1d80f028608192c024df (commit)
       via  f8e0d8089acce1beb9afd18b1d07d6183f00c4aa (commit)
       via  f0a62e0483454200f1d7c5850935d7750bd66f5e (commit)
       via  34cf7dc96d68687f41917823e21670f1cd465c60 (commit)
       via  b1ce2994aa06ce7b1f80e3a3672b8f7f7d90f1c3 (commit)
       via  bc4dfaa33b4f919c0c2ba6e6ecb5834b488975fb (commit)
       via  4f673bfd53ff39c6339a376e71b52ac106e88a91 (commit)
       via  b5d702c339002875b6e42bcf272d8988074ae689 (commit)
       via  09d4a530ef0b73e5494dc0f47c9e206de05e333b (commit)
       via  b23cb58e2922f4472be6eaafe789153154a24562 (commit)
       via  7fff0e02eab31c37df9571765e17b7f77a38752c (commit)
       via  d5156adc90d07693e65eb0c0585c27b511bfd4c1 (commit)
       via  3e024389f0232a2f0101fb9b489116d01373575a (commit)
       via  fc23f49cf070425b24475ca3c62583d93a72ae72 (commit)
       via  d630c71fc79a39379464b15dc1e0747e0f2e21a8 (commit)
       via  57a0cebcfecb5db2ed05b0e5a4eefa88d71718c1 (commit)
       via  9715af7aa6c25fcfbdb8634e8cb5e973b0cd59ab (commit)
      from  106df0de8f99ee28fd969d2fd9ac14e0d2ccedc6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes (followed by patch):
 cc/engine/app.py                                   |    2 +-
 cc/engine/chooser/views.py                         |   34 +++++++-
 cc/engine/chooser/xmp_template.py                  |   53 ++------------
 cc/engine/templates/chooser_pages/metadata.xmp     |   80 ++++++++++++++++++++
 cc/engine/templates/licenses/standard_deed.html    |    1 -
 cc/engine/templates/licenses/zero_deed.html        |    2 +-
 cc/engine/templates/macros_templates/deed.html     |   14 +++-
 cc/engine/templates/macros_templates/engine.html   |   26 ++++++-
 .../templates/macros_templates/pdtool_deed.html    |   10 ++-
 cc/engine/tests/test_util.py                       |    7 ++-
 cc/engine/tests/view_tests.json                    |   39 +++++++++-
 cc/engine/util.py                                  |   32 ++++----
 12 files changed, 218 insertions(+), 82 deletions(-)
 create mode 100644 cc/engine/templates/chooser_pages/metadata.xmp

diff --git a/cc/engine/app.py b/cc/engine/app.py
index bf5d50f..e63db38 100644
--- a/cc/engine/app.py
+++ b/cc/engine/app.py
@@ -2,7 +2,7 @@ import sys
 import urllib
 
 import routes
-from webob import Request, Response, exc
+from webob import Request, exc
 
 from cc.engine import routing, staticdirect, util
 
diff --git a/cc/engine/chooser/views.py b/cc/engine/chooser/views.py
index 53065b0..8b7b7b2 100644
--- a/cc/engine/chooser/views.py
+++ b/cc/engine/chooser/views.py
@@ -7,7 +7,7 @@ from webob import Response, exc
 
 from cc.engine import util
 from cc.engine.decorators import RestrictHttpMethods
-from cc.engine.chooser.xmp_template import license_xmp_template
+import cc.engine.chooser.xmp_template as xmp_template
 from cc.license._lib.functions import get_selector_jurisdictions
 from cc.i18n.gettext_i18n import ugettext_for_locale
 from cc.i18n import mappers
@@ -382,12 +382,38 @@ def choose_xmp_view(request):
     license = _issue_license(request_form)
     target_lang = util.get_target_lang_from_request(request)
 
-    xmp_data = license_xmp_template(
-        request_form, license, target_lang)
+    def attrib_or_none(field_name):
+        return request_form.get(field_name, u'').strip() or None
+
+    context = xmp_template.get_xmp_info(request_form, license, target_lang)
+    context["default_lang"] = target_lang
+    context["work_title"] = attrib_or_none("field_worktitle")
+    context["attrib_name"] = attrib_or_none("field_attribute_to_name")
+    context["attrib_url"] = attrib_or_none("field_attribute_to_url")
+    context["permissions_url"] = attrib_or_none("field_morepermissionsurl")
+    context["licenses"] = [{
+            "lang" : "x-default",
+            "notice" : context["notice"]
+            }, {
+            "lang" : target_lang,
+            "notice" : context["notice"]
+            }]
+    del context["notice"]
+    if target_lang != 'en':
+        xmp_info_en =  xmp_template.get_xmp_info(request_form, license, 'en')
+        context["licenses"] .append({
+                "lang" : 'en',
+                "notice" : xmp_info_en["notice"]
+                })
+
+    xmp_data = util.render_template(
+        request, target_lang,
+        'chooser_pages/metadata.xmp',
+        context)
 
     return Response(
         xmp_data,
-        content_type='application/xmp; charset=UTF-8',
+#        content_type='application/xmp; charset=UTF-8',
         charset='UTF-8',
         content_disposition='attachment; filename="CC_%s.xmp' % (
             license.title().strip().replace(' ', '_')))
diff --git a/cc/engine/chooser/xmp_template.py b/cc/engine/chooser/xmp_template.py
index 001089c..a56703b 100644
--- a/cc/engine/chooser/xmp_template.py
+++ b/cc/engine/chooser/xmp_template.py
@@ -1,4 +1,3 @@
-import string
 import re
 
 from cc.i18n.gettext_i18n import ugettext_for_locale
@@ -58,15 +57,14 @@ def get_xmp_info(request_form, license, locale):
             notice = ""
 
         i18n_work = ugettext('work')
-        work_notice_template = string.Template(
-            ugettext(
+        work_notice_template = ugettext(
                 u'This %(work_type)s is licensed under a '
                 u'<a rel="license" href="%(license_url)s">Creative Commons '
-                u'%(license_name)s License</a>.'))
-        work_notice = work_notice_template.substitute(
-            {'license_name': license.title(locale_to_lower_lower(locale)),
-             'license_url': license.uri,
-             'work_type': i18n_work})
+                u'%(license_name)s License</a>.')
+        work_notice = work_notice_template % {
+            'license_name': license.title(locale_to_lower_lower(locale)),
+            'license_url': license.uri,
+            'work_type': i18n_work}
 
         notice = notice + work_notice
 
@@ -78,42 +76,3 @@ def get_xmp_info(request_form, license, locale):
         'license_url':license.uri,
         'license':license,
         'work_url':work_url}
-
-
-def license_xmp_template(request_form, license, locale):
-    xmp_info = get_xmp_info(request_form, license, locale)
-    xmp_output = u""
-    
-    # assemble the XMP
-    xmp_output += u"""<?xpacket begin='' id=''?><x:xmpmeta xmlns:x='adobe:ns:meta/'>
-    <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
-
-     <rdf:Description rdf:about=''
-      xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
-      <xapRights:Marked>%(copyrighted)s</xapRights:Marked>""" % xmp_info
-
-    if xmp_info['work_url'] != None:
-        xmp_output += """  <xapRights:WebStatement rdf:resource='%(work_url)s'/>""" % xmp_info
-        
-    xmp_output += """ </rdf:Description>
-
-     <rdf:Description rdf:about=''
-      xmlns:dc='http://purl.org/dc/elements/1.1/'>
-      <dc:rights>
-       <rdf:Alt>
-        <rdf:li xml:lang='x-default' >%(notice)s</rdf:li>
-       </rdf:Alt>
-      </dc:rights>
-     </rdf:Description>
-
-     <rdf:Description rdf:about=''
-      xmlns:cc='http://creativecommons.org/ns#'>
-      <cc:license rdf:resource='%(license_url)s'/>
-     </rdf:Description>
-
-    </rdf:RDF>
-    </x:xmpmeta>
-    <?xpacket end='r'?>
-    """ % xmp_info
-
-    return xmp_output
diff --git a/cc/engine/templates/chooser_pages/metadata.xmp b/cc/engine/templates/chooser_pages/metadata.xmp
new file mode 100644
index 0000000..f698d95
--- /dev/null
+++ b/cc/engine/templates/chooser_pages/metadata.xmp
@@ -0,0 +1,80 @@
+<?xpacket begin='' id=''?>
+<x:xmpmeta xmlns:x='adobe:ns:meta/'>
+  <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+    {% if copyrighted -%}
+    <rdf:Description rdf:about=''
+		     xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
+      <xapRights:Marked>{{ copyrighted }}</xapRights:Marked>
+    </rdf:Description>
+    {% endif %}
+
+    {%- if work_url -%}
+    <rdf:Description rdf:about=''
+		     xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
+      <xapRights:WebStatement rdf:resource='{{ work_url }}'/>
+    </rdf:Description>
+    {% endif %}
+
+    {%- if attrib_url -%}
+    <rdf:Description rdf:about=''
+		     xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>
+      <xapRights:WebStatement rdf:resource='{{ attrib_url }}'/>
+    </rdf:Description>
+    {% endif %}
+
+    {%- if licenses -%}
+    <rdf:Description rdf:about=''
+		     xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'
+		     >
+      <xapRights:UsageTerms>
+	<rdf:Alt>
+	  {% for info in licenses -%}
+	  <rdf:li xml:lang='{{ info.lang }}' >{{ info.notice }}</rdf:li>
+	  {% endfor -%}
+	</rdf:Alt>
+      </xapRights:UsageTerms>
+    </rdf:Description>
+    {% endif %}
+    
+    {%- if work_title -%}
+    <rdf:Description rdf:about=''
+		     xmlns:dc='http://purl.org/dc/elements/1.1/'>
+      <dc:title>
+	<rdf:Alt>
+	  <rdf:li xml:lang='x-default'>{{ work_title }}</rdf:li>
+	  <rdf:li xml:lang='{{ default_lang }}'>{{ work_title }}</rdf:li>
+	</rdf:Alt>
+      </dc:title>
+    </rdf:Description>
+    {% endif %}
+
+    {#-
+     # The following two descriptions contains elements in the cc namespace.
+     # As of the time of writting, there is not a practical use case that
+     # comes to mind to test against.  So, at best, the entries are only 
+     # conceptually valid.
+    -#}
+
+    {%- if license_url -%}
+    <rdf:Description rdf:about=''
+      xmlns:cc='http://creativecommons.org/ns#'>
+      <cc:license rdf:resource='{{ license_url }}'/>
+    </rdf:Description>
+    {% endif %}
+
+    {%- if attrib_name -%}
+    <rdf:Description rdf:about=''
+      xmlns:cc='http://creativecommons.org/ns#'>
+      <cc:attributionName>{{ attrib_name }}</cc:attributionName>
+    </rdf:Description>
+    {% endif %}
+
+    {%- if permissions_url -%}
+    <rdf:Description rdf:about=''
+      xmlns:cc='http://creativecommons.org/ns#'>
+      <cc:morePermissions rdf:resource='{{ permissions_url }}'/>
+    </rdf:Description>
+    {%- endif %}
+  </rdf:RDF>
+</x:xmpmeta>
+<?xpacket end='r'?>
\ No newline at end of file
diff --git a/cc/engine/templates/licenses/standard_deed.html b/cc/engine/templates/licenses/standard_deed.html
index b51d1f0..029be77 100644
--- a/cc/engine/templates/licenses/standard_deed.html
+++ b/cc/engine/templates/licenses/standard_deed.html
@@ -164,7 +164,6 @@
               {{ cctrans(locale, "deed.moralrights-remix.us")|safe }}
             </li>
           {% endif %}
-          </span>
 
           <li>
             {{ cctrans(locale, "deed.publicity_rights")|safe }}
diff --git a/cc/engine/templates/licenses/zero_deed.html b/cc/engine/templates/licenses/zero_deed.html
index 91c6299..ac0b1c6 100644
--- a/cc/engine/templates/licenses/zero_deed.html
+++ b/cc/engine/templates/licenses/zero_deed.html
@@ -23,7 +23,7 @@
     <h3>{{ cctrans(locale, "deed.zero.no_copyright")|safe }}</h3>
     <div id="librepd">
       <a href="http://freedomdefined.org/">
-        <img src="/images/deed/seal.png" border="0" 
+        <img src="/images/deed/seal.png"
              alt="{{ cctrans(locale, 'This license is acceptable for Free Cultural Works.')|safe }}" />
       </a>
     </div>
diff --git a/cc/engine/templates/macros_templates/deed.html b/cc/engine/templates/macros_templates/deed.html
index 69b6897..6347943 100644
--- a/cc/engine/templates/macros_templates/deed.html
+++ b/cc/engine/templates/macros_templates/deed.html
@@ -1,11 +1,13 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:cc="http://creativecommons.org/ns#"
       xmlns:dc="http://purl.org/dc/elements/1.1/"
       xmlns:dct="http://purl.org/dc/terms/"
       xmlns:frbr="http://purl.org/vocab/frbr/core#"
-      lang="{{ target_lang }}">
+      xml:lang="{{ target_lang }}">
   <head about="{{ license.uri }}">
+    <meta http-equiv="Content-Type" 
+	  content="application/xhtml+xml; charset=utf-8" />
     <title>
       {%- block title -%}
         Creative Commons &mdash; {{ license.title(target_lang) }}
@@ -140,7 +142,7 @@
       <p>
         {% if not license.deprecated %}
           {% block use_this_license %}
-            <a id="get_this" href="/choose/results-one?license_code={{ license_code_quoted }}&jurisdiction={{ license.jurisdiction.code }}&version={{ license.version }}&lang={{ target_lang }}"
+            <a id="get_this" href="/choose/results-one?license_code={{ license_code_quoted }}&amp;jurisdiction={{ license.jurisdiction.code }}&amp;version={{ license.version }}&amp;lang={{ target_lang }}"
                >{{ cctrans(locale, "deed.use_this_license")|safe }}</a>
           {% endblock %}
         {% endif %}
@@ -149,6 +151,7 @@
     </div>
 
     <script type="text/javascript">
+//<![CDATA[
       var _gaq = _gaq || [];
       _gaq.push(['_setAccount', 'UA-2010376-1']);
       _gaq.push(['_trackPageview']);
@@ -158,9 +161,12 @@
         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
       })();
+//]]>
     </script>
     <script type="text/javascript">
-      document.write("<" + "script type='text/javascript' src='http://scraper.creativecommons.org/apps/deed?url=" + encodeURIComponent(document.referrer) + "&license_uri=" + encodeURIComponent(document.URL) + "&callback=YAHOO.cc.success'" + "><" + "/script>");
+//<![CDATA[
+      document.write("<" + "script type='text/javascript' src='http://scraper.creativecommons.org/apps/deed?url=" + encodeURIComponent(document.referrer) + "&amp;license_uri=" + encodeURIComponent(document.URL) + "&amp;callback=YAHOO.cc.success'" + "><" + "/script>");
+//]]>
     </script>
   </body>
 </html>
diff --git a/cc/engine/templates/macros_templates/engine.html b/cc/engine/templates/macros_templates/engine.html
index 1fc0ede..2fea3dd 100644
--- a/cc/engine/templates/macros_templates/engine.html
+++ b/cc/engine/templates/macros_templates/engine.html
@@ -94,7 +94,7 @@
                   <li><span>Licensors</span></li>
                   <li><a href="http://wiki.creativecommons.org/Before_Licensing">Things to know before licensing</a></li>
                   <li><a href="http://wiki.creativecommons.org/FAQ#Do_I_need_to_sign_something_or_register_to_obtain_a_Creative_Commons_license.3F">Do I need to register my work?</a></li>
-                  <li><a href="http://wiki.creativecommons.org/Marking/">Marking my work</a></li>
+                  <li><a href="http://wiki.creativecommons.org/Marking">Marking my work</a></li>
 
                   <li class="divider"></li>
                   <li><span>Licensees</span></li>
@@ -173,6 +173,24 @@
       </div>
     </header>
 
+
+    <!-- Annual fundraising campaign banner -->
+    <div id="top-banner">
+      <a title="Donate to Creative Commons" href="https://creativecommons.net/donate/?utm_campaign=fall2011&amp;utm_source=ccorg&amp;utm_medium=site_header" id="donate-link"></a>
+      <div class="container">
+        <div class="row">
+          <div class="eleven columns">
+	    <h4><a href="https://creativecommons.net/donate/?utm_campaign=fall2011&amp;utm_source=ccorg&amp;utm_medium=site_header">Donate to Freedom and Sharing: CC’s Annual Campaign</a></h4>
+	  </div>
+	  <div class="three columns omega">
+            <h5><a class="btn" href="https://creativecommons.net/donate/?utm_campaign=fall2011&amp;utm_source=ccorg&amp;utm_medium=site_header">Donate now</a></h5>
+          </div>
+        </div>
+      </div>
+    </div>
+    <!-- Annual fundraising campaign banner -->
+
+
     <div dir="{{ get_ltr_rtl }}" style="{{ is_rtl_align }}" 
          id="main" role="main">
       <div class="container">
@@ -255,7 +273,7 @@
                         Except where otherwise
                         <a class="subfoot" href="/policies#license">noted</a>,
                         content on
-                        <span property="cc:attributionName" content="Creative Commons"></span>
+                        <span rel="cc:attributionName" href="Creative Commons"></span>
                         <span property="cc:attributionURL"
                               content="http://creativecommons.org">this site</span>
                         is licensed under a
@@ -295,6 +313,10 @@
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
   <script>window.jQuery || document.write('<script src="/wp-content/themes/creativecommons.org/js/libs/jquery-1.6.2.min.js"><\/script>')</script>
   <!-- scripts concatenated and minified via build script -->
+  <script type="text/javascript">
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! dirty hack !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+j = $;
+  </script>
   <script defer src="/wp-content/themes/creativecommons.org/js/plugins.js"></script>
   <script defer src="/wp-content/themes/creativecommons.org/js/script.js"></script>
   <!-- end scripts -->
diff --git a/cc/engine/templates/macros_templates/pdtool_deed.html b/cc/engine/templates/macros_templates/pdtool_deed.html
index 5bcffd6..bc4c72c 100644
--- a/cc/engine/templates/macros_templates/pdtool_deed.html
+++ b/cc/engine/templates/macros_templates/pdtool_deed.html
@@ -4,8 +4,10 @@
       xmlns:dc="http://purl.org/dc/elements/1.1/" 
       xmlns:dct="http://purl.org/dc/terms/"
       xmlns:frbr="http://purl.org/vocab/frbr/core#"
-      lang="{{ target_lang }}">
+      xml:lang="{{ target_lang }}">
   <head about="{{ license.uri }}">
+    <meta http-equiv="Content-Type" 
+	  content="application/xhtml+xml; charset=utf-8" />
     <title>
       {%- block title -%}
         Creative Commons &mdash; {{ license.title(target_lang) }}
@@ -106,7 +108,7 @@
     </div>
 
     <script type="text/javascript">
-
+      //<![CDATA[
       var _gaq = _gaq || [];
       _gaq.push(['_setAccount', 'UA-2010376-1']);
       _gaq.push(['_trackPageview']);
@@ -116,10 +118,12 @@
         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
       })();
-
+//]]>
     </script>
     <script type="text/javascript">
+      //<![CDATA[
       document.write("<" + "script type='text/javascript' src='http://scraper.creativecommons.org/apps/pddeed?url=" + encodeURIComponent(document.referrer) + "&license_uri=" + encodeURIComponent(document.URL) + "&callback=YAHOO.cc.success'" + "><" + "/script>");
+//]]>
     </script>
   </body>
 </html>
diff --git a/cc/engine/tests/test_util.py b/cc/engine/tests/test_util.py
index 239cb96..aee0119 100644
--- a/cc/engine/tests/test_util.py
+++ b/cc/engine/tests/test_util.py
@@ -137,7 +137,8 @@ def test_send_license_info_email():
     assert message['From'] == "info at creativecommons.org"
     assert message['To'] == "ilovesillylicenses at example.org"
     assert message['Subject'] == "Your Creative Commons License Information"
-    assert message.get_payload() == """Thank you for using a Creative Commons legal tool for your work.
+    
+    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
@@ -160,6 +161,10 @@ https://creativecommons.net/donate.
 Thank you!
 Creative Commons Support
 info at creativecommons.org"""
+    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\ninfo at creativecommons.org"""
+
+    assert message.get_payload() in [normal_payload, campaign_payload]
+            
 
 
 def test_subset_dict():
diff --git a/cc/engine/tests/view_tests.json b/cc/engine/tests/view_tests.json
index b075b08..7ff8278 100644
--- a/cc/engine/tests/view_tests.json
+++ b/cc/engine/tests/view_tests.json
@@ -139,11 +139,46 @@
       "Choose which style of button you'd like on your webpage:",
       "src=&#34;http://i.creativecommons.org/l/by/3.0/88x31.png&#34;",
       "Creative Commons Attribution 3.0 Unported License"]},
- {"path": "/choose/xmp",
+
+ {"path": "/choose/metadata.xmp",
   "string_tests": [
-      "<?xpacket begin='' id=''?><x:xmpmeta xmlns:x='adobe:ns:meta/'>",
+      "<?xpacket begin='' id=''?>",
+      "<x:xmpmeta xmlns:x='adobe:ns:meta/'>",
       "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
       "Creative Commons Attribution 3.0 Unported License"]},
+ {"path": "/choose/metadata.xmp?field_worktitle=pictures+of+cats",
+  "string_tests": [
+      "<?xpacket begin='' id=''?>",
+      "<x:xmpmeta xmlns:x='adobe:ns:meta/'>",
+      "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+      "Creative Commons Attribution 3.0 Unported License",
+      "<dc:title>",
+      "<rdf:li xml:lang='x-default'>pictures of cats</rdf:li>"]},
+ {"path": "/choose/metadata.xmp?field_attribute_to_name=Cornelius+Highbrow",
+  "string_tests": [
+      "<?xpacket begin='' id=''?>",
+      "<x:xmpmeta xmlns:x='adobe:ns:meta/'>",
+      "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+      "Creative Commons Attribution 3.0 Unported License",
+      "<cc:attributionName>Cornelius Highbrow</cc:attributionName>"]},
+ {"path": "/choose/metadata.xmp?field_attribute_to_url=http%3A%2F%2Ftest.foo",
+  "string_tests": [
+      "<?xpacket begin='' id=''?>",
+      "<x:xmpmeta xmlns:x='adobe:ns:meta/'>",
+      "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>",
+      "Creative Commons Attribution 3.0 Unported License",
+      "<xapRights:WebStatement rdf:resource='http://test.foo'/>"]},
+ {"path": "/choose/metadata.xmp?lang=es",
+  "string_tests": [
+      "xml:lang='es'",
+      "xml:lang='en'",
+      "licencia Creative Commons Atribuci",
+      "Creative Commons Attribution 3.0 Unported License"]},
+ {"path": "/choose/metadata.xmp?field_morepermissionsurl=http%3A%2F%2Ftest.foo",
+  "string_tests": [
+      "<cc:morePermissions rdf:resource='http://test.foo'/>"
+  ]},
+
  {"path": "/choose/get-html",
   "string_tests": [
       "src=\"http://i.creativecommons.org/l/by/3.0/88x31.png\"",
diff --git a/cc/engine/util.py b/cc/engine/util.py
index 4371fce..500160b 100644
--- a/cc/engine/util.py
+++ b/cc/engine/util.py
@@ -1,4 +1,3 @@
-import csv
 import os
 import pkg_resources
 import string
@@ -606,21 +605,22 @@ def catch_license_versions_from_request(request):
     might exist from the user's request, this utility helps look for
     those.
     """
-    # Look to see if there are other licenses of that code,
-    # possibly of that jurisdiction.
+
+    license_versions = []
+    code = request.matchdict['code']
+    searches = [[code]]
     if request.matchdict.has_key('jurisdiction'):
-        # If licenses of a jurisdiction don't exist, fallback to
-        # just licenses of this code.
-        license_versions = all_possible_license_versions(
-            request.matchdict['code'],
-            request.matchdict['jurisdiction'])
-
-        if not license_versions:
-            license_versions = all_possible_license_versions(
-                request.matchdict['code'])
-    else:
-        # If there's no jurisdiction we'll just look it up by code.
-        license_versions = all_possible_license_versions(
-            request.matchdict['code'])
+        # Look to see if there are other licenses of that code, possibly of
+        # that jurisdiction.  Otherwise, we'll just look it up by code.  Also,
+        # if by jurisdiction fails, by code will be the fallback.
+        searches.insert(0, [code, request.matchdict['jurisdiction']])
+
+    for search_args in searches:
+        license_versions += all_possible_license_versions(*search_args)
+        if code == u'by-nc-nd':
+            other_search = [u'by-nd-nc'] + search_args[1:]
+            license_versions += all_possible_license_versions(*other_search)
+        if license_versions:
+            break
 
     return license_versions


hooks/post-receive
-- 
cc.engine: License chooser, public domain chooser, deeds


More information about the cc-commits mailing list