Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template.

This commit is contained in:
Aaron Williamson 2012-01-18 21:07:55 -05:00
parent 291e24f397
commit 17c23e15e4
4 changed files with 11 additions and 10 deletions

View File

@ -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]

View File

@ -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})

View File

@ -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)

View File

@ -17,10 +17,10 @@
#}
{% block license_content -%}
License:
{% if media['license'] %}
<a href="{{ media['license'] }}">{{ media.get_license_data()['abbreviation'] }}</a>
{% trans %}License:{% endtrans %}
{% if media.license %}
<a href="{{ media.license }}">{{ media.get_license_data().abbreviation }}</a>
{% else %}
All rights reserved
{% trans %}All rights reserved{% endtrans %}
{% endif %}
{% endblock %}