Self hosted FLOSS fitness/workout, nutrition and weight tracker
Correctly attribute images and ingredients
Roland Geiderdce520980540
diff --git a/wger/core/models/license.py b/wger/core/models/license.pyindex 01b78b53f..524da1324 100644--- a/wger/core/models/license.py+++ b/wger/core/models/license.py@@ -35,7 +35,10 @@ class License(models.Model):)"""Full name"""- short_name = models.CharField(max_length=15, verbose_name=_('Short name, e.g. CC-BY-SA 3'))+ short_name = models.CharField(+ max_length=15,+ verbose_name=_('Short name, e.g. CC-BY-SA 3'),+ )"""Short name, e.g. CC-BY-SA 3"""url = models.URLField(diff --git a/wger/core/templates/tags/license-sidebar.html b/wger/core/templates/tags/license-sidebar.htmldeleted file mode 100644index 010dcf82c..000000000--- a/wger/core/templates/tags/license-sidebar.html+++ /dev/null@@ -1,15 +0,0 @@-{% load i18n static %}--<h4>{% translate "Free license" %}</h4>-<p>- {% translate "This content is available under the following license:" %}- <strong>{{license}}</strong>- {% if author %}- – {{author}}- {% endif %}-- {% if license.url %}- <br>- <a rel="license" href="{{license.url}}">{% translate "Click here for more information" %}</a>- {% endif %}-</p>diff --git a/wger/core/templatetags/wger_extras.py b/wger/core/templatetags/wger_extras.pyindex ce3bb0533..bd46200b3 100644--- a/wger/core/templatetags/wger_extras.py+++ b/wger/core/templatetags/wger_extras.py@@ -118,15 +118,6 @@ def react_static():return {}[email protected]_tag('tags/license-sidebar.html')-def license_sidebar(license, author=None):- """- Renders the license notice for exercises- """-- return {'license': license, 'author': author}--@register.inclusion_tag('tags/muscles.html')def render_muscles(muscles=None, muscles_sec=None):"""diff --git a/wger/exercises/migrations/0024_license_information.py b/wger/exercises/migrations/0024_license_information.pyindex ff0c6959c..008a59a2f 100644--- a/wger/exercises/migrations/0024_license_information.py+++ b/wger/exercises/migrations/0024_license_information.py@@ -44,7 +44,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -83,7 +83,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -122,7 +122,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available'),),@@ -161,7 +161,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -200,7 +200,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -239,7 +239,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -278,7 +278,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -317,7 +317,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),diff --git a/wger/nutrition/migrations/0014_license_information.py b/wger/nutrition/migrations/0014_license_information.pyindex ae2631893..38e4e49e6 100644--- a/wger/nutrition/migrations/0014_license_information.py+++ b/wger/nutrition/migrations/0014_license_information.py@@ -44,7 +44,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),@@ -83,7 +83,7 @@ class Migration(migrations.Migration):name='license_title',field=models.CharField(blank=True,- max_length=100,+ max_length=200,verbose_name='The original title of this object, if available',),),diff --git a/wger/nutrition/templates/ingredient/view.html b/wger/nutrition/templates/ingredient/view.htmlindex bde992611..d3cf65541 100644--- a/wger/nutrition/templates/ingredient/view.html+++ b/wger/nutrition/templates/ingredient/view.html@@ -154,22 +154,13 @@ the search.{% endblocktranslate %}</table></div>+{{ ingredient.attribution_link|safe }}{% endblock %}{% block sidebar %}-{% if ingredient.status == ingredient.INGREDIENT_STATUS_ACCEPTED %}-<div class="alert" style="margin-top:1em;">-<h4>{% translate "User submitted ingredient" %}</h4>-{% with username=ingredient.user.username %}-<p>{% blocktranslate %}This exercise was submitted by <strong>{{username}}</strong>.{% endblocktranslate %}-{% endwith %}-</div>-{% endif %}--{% if perms.nutrition.delete_ingredient %}<h4>{% translate "Weight units" %}</h4><p>@@ -211,8 +202,8 @@ the search.{% endblocktranslate %}<a href="{{ ingredient.off_link }}"><img src="{{ image.image.url }}" class="img-fluid"></a>+ {{ image.attribution_link|safe }}{% endif %}-{% license_sidebar ingredient.license ingredient.license_author %}{% endblock %}diff --git a/wger/utils/models.py b/wger/utils/models.pyindex cf38de2e3..a1ad06f02 100644--- a/wger/utils/models.py+++ b/wger/utils/models.py@@ -49,7 +49,7 @@ class AbstractLicenseModel(models.Model):license_title = models.CharField(verbose_name=_('The original title of this object, if available'),- max_length=100,+ max_length=200,blank=True,)@@ -88,9 +88,12 @@ class AbstractLicenseModel(models.Model):def attribution_link(self):out = ''- if self.license_title:+ if self.license_object_url:+ out += f'<a href="{self.license_object_url}">{self.license_title}</a>'+ else:out += self.license_title+ out += ' by 'if self.license_author_url:out += f'<a href="{self.license_author_url}">{self.license_author}</a>'else:@@ -98,9 +101,9 @@ class AbstractLicenseModel(models.Model):out += f' is licensed under <a href="{self.license.url}">{self.license.short_name}</a>'- if self.license_source_url:- out += f'/ A derivative work from <a href="{self.license_source_url}">the original ' \- f'work</a>'+ if self.license_derivative_source_url:+ out += f'/ A derivative work from <a href="{self.license_derivative_source_url}">the ' \+ f'original work</a>'return out