aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/mongo/models.py9
-rw-r--r--mediagoblin/edit/forms.py5
-rw-r--r--mediagoblin/edit/views.py9
-rw-r--r--mediagoblin/submit/forms.py5
-rw-r--r--mediagoblin/submit/views.py4
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media.html2
-rw-r--r--mediagoblin/templates/mediagoblin/utils/license.html26
-rw-r--r--mediagoblin/tools/licenses.py62
8 files changed, 118 insertions, 4 deletions
diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py
index 906d2849..a95cde7d 100644
--- a/mediagoblin/db/mongo/models.py
+++ b/mediagoblin/db/mongo/models.py
@@ -22,7 +22,7 @@ from mediagoblin import mg_globals
from mediagoblin.db.mongo import migrations
from mediagoblin.db.mongo.util import ASCENDING, DESCENDING, ObjectId
from mediagoblin.tools.pagination import Pagination
-from mediagoblin.tools import url
+from mediagoblin.tools import url, licenses
from mediagoblin.db.mixin import UserMixin, MediaEntryMixin
###################
@@ -151,6 +151,8 @@ class MediaEntry(Document, MediaEntryMixin):
"unprocessed": uploaded but needs to go through processing for display
"processed": processed and able to be displayed
+ - license: URI for media's license.
+
- queued_media_file: storage interface style filepath describing a file
queued for processing. This is stored in the mg_globals.queue_store
storage system.
@@ -183,6 +185,7 @@ class MediaEntry(Document, MediaEntryMixin):
'plugin_data': dict, # plugins can dump stuff here.
'tags': [dict],
'state': unicode,
+ 'license': unicode,
# For now let's assume there can only be one main file queued
# at a time
@@ -249,6 +252,10 @@ class MediaEntry(Document, MediaEntryMixin):
for media in cursor:
return media.url_for_self(urlgen)
+ def get_license_data(self):
+ """Return license dict for requested license"""
+ return licenses.SUPPORTED_LICENSES[self['license']]
+
@property
def get_uploader(self):
return self.db.User.find_one({'_id': self.uploader})
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py
index 5c191fba..d49b9b28 100644
--- a/mediagoblin/edit/forms.py
+++ b/mediagoblin/edit/forms.py
@@ -18,6 +18,7 @@ import wtforms
from mediagoblin.tools.text import tag_length_validator, TOO_LONG_TAG_WARNING
from mediagoblin.tools.translate import fake_ugettext_passthrough as _
+from mediagoblin.tools.licenses import licenses_as_choices
class EditForm(wtforms.Form):
title = wtforms.TextField(
@@ -39,7 +40,9 @@ class EditForm(wtforms.Form):
description=_(
"The title part of this media's address. "
"You usually don't need to change this."))
-
+ license = wtforms.SelectField(
+ _('License'),
+ choices=licenses_as_choices())
class EditProfileForm(wtforms.Form):
bio = wtforms.TextAreaField(
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index ec748028..a3b269d8 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -35,6 +35,7 @@ from mediagoblin.tools.translate import pass_to_ugettext as _
from mediagoblin.tools.text import (
clean_html, convert_to_tag_list_of_dicts,
media_tags_as_string, cleaned_markdown_conversion)
+from mediagoblin.tools.licenses import SUPPORTED_LICENSES
@get_user_media_entry
@require_active_login
@@ -46,7 +47,8 @@ def edit_media(request, media):
title=media.title,
slug=media.slug,
description=media.description,
- tags=media_tags_as_string(media.tags))
+ tags=media_tags_as_string(media.tags),
+ license=media.license))
form = forms.EditForm(
request.POST,
@@ -72,7 +74,12 @@ def edit_media(request, media):
media.description_html = cleaned_markdown_conversion(
media.description)
+ media.license = (
+ unicode(request.POST.get('license'))
+ or '')
+
media.slug = unicode(request.POST['slug'])
+
media.save()
return exc.HTTPFound(
diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index 7ef3638f..08234822 100644
--- a/mediagoblin/submit/forms.py
+++ b/mediagoblin/submit/forms.py
@@ -19,7 +19,7 @@ import wtforms
from mediagoblin.tools.text import tag_length_validator
from mediagoblin.tools.translate import fake_ugettext_passthrough as _
-
+from mediagoblin.tools.licenses import licenses_as_choices
class SubmitStartForm(wtforms.Form):
file = wtforms.FileField(_('File'))
@@ -36,3 +36,6 @@ class SubmitStartForm(wtforms.Form):
[tag_length_validator],
description=_(
"Separate tags by commas."))
+ license = wtforms.SelectField(
+ _('License'),
+ choices=licenses_as_choices())
diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py
index 33868785..b91fdb8d 100644
--- a/mediagoblin/submit/views.py
+++ b/mediagoblin/submit/views.py
@@ -69,6 +69,10 @@ def submit_start(request):
entry.description_html = cleaned_markdown_conversion(
entry.description)
+ entry['license'] = (
+ unicode(request.POST.get('license'))
+ or '')
+
entry.uploader = request.user._id
# Process the user's folksonomy "tags"
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html
index 865a94ab..cbe26cbf 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media.html
@@ -170,5 +170,7 @@
{% if media.tags %}
{% include "mediagoblin/utils/tags.html" %}
{% endif %}
+
+ {% include "mediagoblin/utils/license.html" %}
</div>
{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/utils/license.html b/mediagoblin/templates/mediagoblin/utils/license.html
new file mode 100644
index 00000000..31481018
--- /dev/null
+++ b/mediagoblin/templates/mediagoblin/utils/license.html
@@ -0,0 +1,26 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#}
+
+{% block license_content -%}
+ License:
+ {% if media['license'] %}
+ <a href="{{ media['license'] }}">{{ media.get_license_data()['abbreviation'] }}</a>
+ {% else %}
+ All rights reserved
+ {% endif %}
+{% endblock %}
diff --git a/mediagoblin/tools/licenses.py b/mediagoblin/tools/licenses.py
new file mode 100644
index 00000000..cb137fa8
--- /dev/null
+++ b/mediagoblin/tools/licenses.py
@@ -0,0 +1,62 @@
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+SUPPORTED_LICENSES = {
+ "": {
+ "name": "No license specified",
+ "abbreviation": "All rights reserved"
+ },
+ "http://creativecommons.org/licenses/by/3.0/": {
+ "name": "Creative Commons Attribution Unported 3.0",
+ "abbreviation": "CC BY 3.0"
+ },
+ "http://creativecommons.org/licenses/by-sa/3.0": {
+ "name": "Creative Commons Attribution-ShareAlike Unported 3.0",
+ "abbreviation": "CC BY-SA 3.0"
+ },
+ "http://creativecommons.org/licenses/by-nd/3.0": {
+ "name": "Creative Commons Attribution-NoDerivs 3.0 Unported",
+ "abbreviation": "CC BY-ND 3.0"
+ },
+ "http://creativecommons.org/licenses/by-nc/3.0": {
+ "name": "Creative Commons Attribution-NonCommercial Unported 3.0",
+ "abbreviation": "CC BY-NC 3.0"
+ },
+ "http://creativecommons.org/licenses/by-nc-sa/3.0": {
+ "name": "Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported",
+ "abbreviation": "CC BY-NC-SA 3.0"
+ },
+ "http://creativecommons.org/licenses/by-nc-nd/3.0": {
+ "name": "Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported",
+ "abbreviation": "CC BY-NC-ND 3.0"
+ },
+ "http://creativecommons.org/publicdomain/zero/1.0/": {
+ "name": "Creative Commons CC0 1.0 Universal",
+ "abbreviation": "CC0 1.0"
+ },
+ "http://creativecommons.org/publicdomain/mark/1.0/": {
+ "name": "Public Domain",
+ "abbreviation": "Public Domain"
+ },
+}
+
+def licenses_as_choices():
+ license_list = []
+
+ for uri, data in SUPPORTED_LICENSES.items():
+ license_list.append((uri, data["abbreviation"]))
+
+ return license_list