% {'url': same_source.first().get_absolute_url()}))
return source_url
+ clean_cut_top = lambda self: self.cleaned_data.get('cut_top') or 0
+ clean_cut_bottom = lambda self: self.cleaned_data.get('cut_bottom') or 0
+ clean_cut_left = lambda self: self.cleaned_data.get('cut_left') or 0
+ clean_cut_right = lambda self: self.cleaned_data.get('cut_right') or 0
+
def clean(self):
cleaned_data = super(ImageAddForm, self).clean()
download_url = cleaned_data.get('download_url', None)
"""
file_name = url.rsplit('/', 1)[-1].rsplit(':', 1)[-1]
d = json.loads(URLOpener().open('https://commons.wikimedia.org/w/api.php?action=query&titles=File:{}&prop=imageinfo&iiprop=url|user|extmetadata&iimetadataversion=latest&format=json'.format(file_name)).read().decode('utf-8'))
+
d = list(d['query']['pages'].values())[0]['imageinfo'][0]
ext = d['extmetadata']
'author': d['user'],
'source_url': d['descriptionurl'],
'download_url': d['url'],
- 'license_url': ext['LicenseUrl']['value'],
+ 'license_url': ext.get('LicenseUrl', {}).get('value', ''),
'license_name': ext['LicenseShortName']['value'],
}
-
+
+ if meta['license_name'] == 'Public domain':
+ meta['license_name'] = 'domena publiczna'
+ meta['license_url'] = 'https://pl.wikipedia.org/wiki/Domena_publiczna'
+
+
return meta
def get_mnw_data(url):
"""
- >>> get_mnw_data('https://cyfrowe.mnw.art.pl/pl/katalog/794032')
- {'title': 'Pejzaż z podwójnym świerkiem', 'author': 'nieznany, Altdorfer, Albrecht (ca 1480-1538)', 'source_url': 'https://cyfrowe.mnw.art.pl/pl/katalog/794032', 'download_url': 'https://cyfrowe-cdn.mnw.art.pl/upload/multimedia/49/58/49583b3e9b23e2d25f372fe6021ae220.jpg', 'license_url': 'https://pl.wikipedia.org/wiki/Domena_publiczna', 'license_name': 'DOMENA PUBLICZNA'}
-
+ >>> get_mnw_data('https://cyfrowe.mnw.art.pl/pl/katalog/511078')
+ {'title': 'Chłopka (Baba ukraińska)', 'author': 'Krzyżanowski, Konrad (1872-1922)', 'source_url': 'https://cyfrowe.mnw.art.pl/pl/katalog/511078', 'download_url': 'https://cyfrowe-cdn.mnw.art.pl/upload/multimedia/32/60/3260ae1704cc530cc62befa9b7d58cbd.jpg', 'license_url': 'https://pl.wikipedia.org/wiki/Domena_publiczna', 'license_name': 'domena publiczna'}
"""
nr = url.rsplit('/', 1)[-1]
d = list(
license_name = d['copyrights.0.name']
if license_name == 'DOMENA PUBLICZNA':
license_name = 'domena publiczna'
- license_url = ''
+ license_url = 'https://pl.wikipedia.org/wiki/Domena_publiczna'
return {
'title': d['title'],
@active_tab('cover')
def image_list(request):
return render(request, "cover/image_list.html", {
- 'object_list': Image.objects.all(),
+ 'object_list': Image.objects.all().order_by('-id'),
'can_add': request.user.has_perm('cover.add_image'),
})