From 17c23e15e4c2dc120eaa3357e59ee8fdba55bf9e Mon Sep 17 00:00:00 2001 From: Aaron Williamson Date: Wed, 18 Jan 2012 21:07:55 -0500 Subject: [PATCH] Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template. --- mediagoblin/db/mixin.py | 6 +++++- mediagoblin/db/mongo/models.py | 6 +----- mediagoblin/db/sql/models.py | 1 + mediagoblin/templates/mediagoblin/utils/license.html | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) 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 %} -- 2.25.1