From: Aaron Williamson Date: Thu, 19 Jan 2012 02:07:55 +0000 (-0500) Subject: Moved get_license_data to mixin.py, added license to sql media model, added translati... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=17c23e15e4c2dc120eaa3357e59ee8fdba55bf9e;p=mediagoblin.git Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template. --- diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 5145289e..b0fecad3 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -28,7 +28,7 @@ real objects. """ from mediagoblin.auth import lib as auth_lib -from mediagoblin.tools import common +from mediagoblin.tools import common, licenses class UserMixin(object): @@ -90,3 +90,7 @@ class MediaEntryMixin(object): """ 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] diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py index a95cde7d..56ed7dcf 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, licenses +from mediagoblin.tools import url from mediagoblin.db.mixin import UserMixin, MediaEntryMixin ################### @@ -252,10 +252,6 @@ 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/db/sql/models.py b/mediagoblin/db/sql/models.py index 91092f33..e07963ca 100644 --- a/mediagoblin/db/sql/models.py +++ b/mediagoblin/db/sql/models.py @@ -64,6 +64,7 @@ class MediaEntry(Base, MediaEntryMixin): description_html = Column(UnicodeText) # ?? media_type = Column(Unicode, nullable=False) state = Column(Unicode, nullable=False) # or use sqlalchemy.types.Enum? + license = Column(Unicode, nullable=False) fail_error = Column(Unicode) fail_metadata = Column(UnicodeText) diff --git a/mediagoblin/templates/mediagoblin/utils/license.html b/mediagoblin/templates/mediagoblin/utils/license.html index 31481018..056c356e 100644 --- a/mediagoblin/templates/mediagoblin/utils/license.html +++ b/mediagoblin/templates/mediagoblin/utils/license.html @@ -17,10 +17,10 @@ #} {% block license_content -%} - License: - {% if media['license'] %} - {{ media.get_license_data()['abbreviation'] }} + {% trans %}License:{% endtrans %} + {% if media.license %} + {{ media.get_license_data().abbreviation }} {% else %} - All rights reserved + {% trans %}All rights reserved{% endtrans %} {% endif %} {% endblock %}