diff options
author | Aaron Williamson <aaron@copiesofcopies.org> | 2012-01-17 00:33:55 -0500 |
---|---|---|
committer | Aaron Williamson <aaron@copiesofcopies.org> | 2012-01-17 00:33:55 -0500 |
commit | 25b48323a86a1036112f2f33c889d5d12d5dee9c (patch) | |
tree | 99c61b9054fc631cb79c360c0ed0dc204b3fa496 | |
parent | 98308e61b627ccfa461ad11966ff236d974762e7 (diff) | |
download | mediagoblin-25b48323a86a1036112f2f33c889d5d12d5dee9c.tar.lz mediagoblin-25b48323a86a1036112f2f33c889d5d12d5dee9c.tar.xz mediagoblin-25b48323a86a1036112f2f33c889d5d12d5dee9c.zip |
First crack at basic license support.
-rw-r--r-- | mediagoblin/db/models.py | 9 | ||||
-rw-r--r-- | mediagoblin/edit/forms.py | 5 | ||||
-rw-r--r-- | mediagoblin/edit/views.py | 8 | ||||
-rw-r--r-- | mediagoblin/submit/forms.py | 5 | ||||
-rw-r--r-- | mediagoblin/submit/views.py | 4 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/user_pages/media.html | 2 |
6 files changed, 30 insertions, 3 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 0f5174cc..e085840e 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -24,6 +24,7 @@ from mediagoblin.db import migrations from mediagoblin.db.util import ASCENDING, DESCENDING, ObjectId from mediagoblin.tools.pagination import Pagination from mediagoblin.tools import url, common +from mediagoblin.tools import licenses ################### # Custom validators @@ -158,6 +159,8 @@ class MediaEntry(Document): "unprocessed": uploaded but needs to go through processing for display "processed": processed and able to be displayed + - license: URI for entry'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. @@ -174,6 +177,7 @@ class MediaEntry(Document): - fail_error: path to the exception raised - fail_metadata: + """ __collection__ = 'media_entries' @@ -189,6 +193,7 @@ class MediaEntry(Document): 'plugin_data': dict, # plugins can dump stuff here. 'tags': [dict], 'state': unicode, + 'license': unicode, # License URI # For now let's assume there can only be one main file queued # at a time @@ -304,6 +309,10 @@ class MediaEntry(Document): if self['fail_error']: return common.import_component(self['fail_error']) + def get_license_data(self): + """Return license dict for requested license""" + return licenses.SUPPORTED_LICENSES[self['license']] + class MediaComment(Document): """ diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py index 7e71722c..3d1d9fd4 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( @@ -33,7 +34,9 @@ class EditForm(wtforms.Form): description=_( "The title part of this media's URL. " "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 a6ddb553..f92eabac 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -34,6 +34,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 @@ -45,7 +46,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, @@ -71,6 +73,10 @@ 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() diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py index 25d6e304..be85b9a9 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')) @@ -31,3 +31,6 @@ class SubmitStartForm(wtforms.Form): tags = wtforms.TextField( _('Tags'), [tag_length_validator]) + license = wtforms.SelectField( + _('License'), + choices=licenses_as_choices()) diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index 7134235e..ecfa9943 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -60,6 +60,10 @@ def submit_start(request): entry['description'] = unicode(request.POST.get('description')) entry['description_html'] = cleaned_markdown_conversion( entry['description']) + + entry['license'] = ( + unicode(request.POST.get('license')) + or '') entry['media_type'] = u'image' # heh entry['uploader'] = request.user['_id'] diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 11fa72cf..efbd7e53 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -171,6 +171,8 @@ {% if media.tags %} {% include "mediagoblin/utils/tags.html" %} {% endif %} + + {% include "mediagoblin/utils/license.html" %} </div> {% else %} <p>{% trans %}Sorry, no such media found.{% endtrans %}<p/> |