[cc-commits] [SCM] cc.api: (branch master) updated. 260f881eacda54c879bafb34468972d59c095c7d
git version control
git at a7.creativecommons.org
Wed Nov 17 18:13:52 EST 2010
The branch, master has been updated
via 260f881eacda54c879bafb34468972d59c095c7d (commit)
from 8fc2781f16776bcf9ef88aa537b960ece8cd65ae (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 -----------------------------------------------------------------
commit 260f881eacda54c879bafb34468972d59c095c7d
Author: JED3 <john at creativecommons.org>
Date: Wed Nov 17 15:12:46 2010 -0800
Work info paramters for the mark license class
-----------------------------------------------------------------------
Summary of changes (followed by patch):
cc/api/support.py | 67 ++++++++++++++++++++++-------------------
cc/api/tests/test_license.py | 28 +++++++++++++++++-
docs/readme_staging.rst | 32 +++++++++++++++-----
3 files changed, 87 insertions(+), 40 deletions(-)
diff --git a/cc/api/support.py b/cc/api/support.py
index 692716c..098ede5 100644
--- a/cc/api/support.py
+++ b/cc/api/support.py
@@ -47,35 +47,40 @@ FORMATTERS = {
'publicdomain': PublicDomainHTMLFormatter,
}
-HTML_FORMATTER_KEYS = [
- ('attribution_name', 'attribution_name'),
- ('creator', 'attribution_name'),
- ('holder', 'attribution_name'),
-
- ('attribution_url', 'attribution_url'),
- ('work-url', 'attribution_url'),
-
- ('title', 'work_title'),
- ('source-url', 'source_work'),
- ('type', 'format'),
- ('more_permissions_url', 'more_permissions_url'),
-
- ]
-
-CC0_FORMATTER_KEYS = [
- ('title', 'work_title'),
-
- ('attribution_name', 'name'),
- ('creator', 'name'),
- ('name', 'name'),
-
- ('attribution_url', 'actor_href'),
- ('actor_href', 'actor_href'),
-
- ('territory', 'work_jurisdiction'),
+FORMATTER_KEYS = {
+ 'standard': [
+ ('attribution_name', 'attribution_name'),
+ ('creator', 'attribution_name'),
+ ('holder', 'attribution_name'),
+ ('attribution_url', 'attribution_url'),
+ ('work-url', 'attribution_url'),
+ ('title', 'work_title'),
+ ('source-url', 'source_work'),
+ ('type', 'format'),
+ ('more_permissions_url', 'more_permissions_url'),
+ ],
+ 'zero': [
+ ('title', 'work_title'),
+ ('attribution_name', 'name'),
+ ('creator', 'name'),
+ ('name', 'name'),
+ ('attribution_url', 'actor_href'),
+ ('actor_href', 'actor_href'),
+ ('territory', 'work_jurisdiction'),
+ ],
+ 'mark': [
+ ('title', 'work_title'),
+ ('attribution_name', 'author_title'),
+ ('name', 'author_title'),
+ ('author_title', 'author_title'),
+ ('attribution_url', 'author_href'),
+ ('author_url', 'author_href'),
+ ('curator_title', 'curator_title'),
+ ('curator_url', 'curator_href'),
+ ('waive_rights','waive_cc0'),
+ ],
+ }
- ]
-
def validate_answers(selector, answers):
""" Takes an xml string `answers` and ensures that
all of the required questions have values for the given
@@ -159,9 +164,9 @@ def build_work_dict(license, answers=None):
work_info = answers.xpath('/answers/work-info')[0]
- formatter_keys = (license.license_class == 'zero' and \
- CC0_FORMATTER_KEYS or HTML_FORMATTER_KEYS)
-
+ formatter_keys = FORMATTER_KEYS.get(license.license_class,
+ FORMATTER_KEYS['standard'])
+
# iterate through the dict in order of key precedence
mapping = defaultdict(list)
for k,v in formatter_keys:
diff --git a/cc/api/tests/test_license.py b/cc/api/tests/test_license.py
index 38e81cc..0245dab 100644
--- a/cc/api/tests/test_license.py
+++ b/cc/api/tests/test_license.py
@@ -198,7 +198,15 @@ class TestLicenseWorkInfo(TestApi):
'name': 'Testing',
'territory': 'US',
}
-
+ _mark_fields = {
+ 'title': 'Testing Title',
+ 'curator_title': 'Curator',
+ 'curator_url': 'http://curator.com/',
+ 'author_title': 'Author',
+ 'author_url': 'http://author.com/',
+ 'waive_rights': '1',
+ }
+
_answers = '<answers><locale>en</locale><license-standard>' + \
'<commercial>y</commercial>' + \
'<derivatives>y</derivatives>' + \
@@ -206,6 +214,7 @@ class TestLicenseWorkInfo(TestApi):
'</license-standard>%s</answers>'
_cc0_answers = '<answers><license-zero />%s</answers>'
+ _mark_answers = '<answers><license-mark />%s</answers>'
def _work_info_string(self, fields):
root = "<work-info>"
@@ -264,6 +273,23 @@ class TestLicenseWorkInfo(TestApi):
# issue and get should be identical
assert i.body == g.body
+ work_infos = self._permute_workinfo(self._mark_fields.keys(), self._mark_fields)
+ for workinfo in work_infos:
+ wi = self._work_info_string(
+ dict([ (f, self._mark_fields[f]) for f in workinfo ]))
+ i = self.app.post('/license/mark/issue',
+ params={'answers':self._mark_answers % wi})
+ g = self.app.get('/license/mark/get?' + urlencode(workinfo))
+ for f in workinfo:
+ # assert field is present in issue response
+ assert self._mark_fields[f] in i.body, '%s=%s not in issue results.'% \
+ (f, self._mark_fields[f])
+ # assert field is present in get response
+ assert self._mark_fields[f] in g.body, '%s=%s not in get results.' % \
+ (f, self._mark_fields[f])
+ # issue and get should be identical
+ assert i.body == g.body
+
def test_invalid_work_jurisdiction(self):
""" cc.license will KeyError when an invalid work_jurisidction is passed to
the CC0 formatter. """
diff --git a/docs/readme_staging.rst b/docs/readme_staging.rst
index ece5ca0..f53e0a7 100644
--- a/docs/readme_staging.rst
+++ b/docs/readme_staging.rst
@@ -234,21 +234,37 @@ Providing work information
+---------------+------------------------+--------------------+---------------------------------+
| | Your name | dct:title | attribution_name, creator, |
| | | | name |
- | +------------------------+--------------------+---------------------------------+
- | zero | Your URL | dct:publisher | attribution_url, actor_href |
+ | zero, +------------------------+--------------------+---------------------------------+
+ | publicdomain | Your URL | dct:publisher | attribution_url, actor_href |
| +------------------------+--------------------+---------------------------------+
| | Title of work | dct:title | title |
| +------------------------+--------------------+---------------------------------+
| | Territory | vcard:Country | territory |
+---------------+------------------------+--------------------+---------------------------------+
+ | | Work name | dct:title | title |
+ | +------------------------+--------------------+---------------------------------+
+ | | Author name | dct:title of | author_title, attribution_name, |
+ | | | dct:creator | name |
+ | +------------------------+--------------------+---------------------------------+
+ | | Author URL | dct:creator | author_url, attribution_url |
+ | mark +------------------------+--------------------+---------------------------------+
+ | | Identifying Individual | dct:title of | curator_title |
+ | | or Organization name | dct:publisher | |
+ | +------------------------+--------------------+---------------------------------+
+ | | Identifying Individual | dct:publisher | curator_url |
+ | | or Organization URL | | |
+ | +------------------------+--------------------+---------------------------------+
+ | | Waive incidental rights| cc:license | waive_rights |
+ +---------------+------------------------+--------------------+---------------------------------+
The "Additional Information" column represents fields that are made available
- via the license choosers at http://creativecommons.org/choose/ and
- http://creativecommons.org/choose/zero. These fields will have an effect on how
- the resulting License RDFa is structured. The work-info elements are listed in
- order of searching priority, i.e. in determining a value for RDFa inclusion,
- a work-info element will override the elements that follow it in the valid elements
- list.
+ via the license choosers at http://creativecommons.org/choose/,
+ http://creativecommons.org/choose/zero/, and http://creativecommons.org/choose/mark/.
+ These fields will have an effect on how the resulting License RDFa is structured.
+ The work-info elements are listed in order of searching priority, i.e. in determining
+ a value for RDFa inclusion, a work-info element will override the elements that
+ follow it in the valid elements list.
+
Additional work-info details
----------------------------
hooks/post-receive
--
cc.api:
More information about the cc-commits
mailing list