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
"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.
- fail_error: path to the exception raised
- fail_metadata:
+
"""
__collection__ = 'media_entries'
'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
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):
"""
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(
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(
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
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,
media['description_html'] = cleaned_markdown_conversion(
media['description'])
+ media['license'] = (
+ unicode(request.POST.get('license'))
+ or '')
+
media['slug'] = unicode(request.POST['slug'])
media.save()
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'))
tags = wtforms.TextField(
_('Tags'),
[tag_length_validator])
+ license = wtforms.SelectField(
+ _('License'),
+ choices=licenses_as_choices())
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']
{% 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/>