From: Jan Szejko Date: Wed, 16 Mar 2016 14:37:41 +0000 (+0100) Subject: local changes from server X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/143ac9b891b8223386830835709377166564af8f?hp=-c local changes from server --- 143ac9b891b8223386830835709377166564af8f diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po index 67f10ef8..53b753b1 100644 --- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/apps/catalogue/locale/pl/LC_MESSAGES/django.po @@ -145,7 +145,7 @@ msgstr "obraz" msgid "images" msgstr "obrazy" -#: models/image.py:75 +#: models/image.py:79 msgid "There is no publishable revision" msgstr "Żadna wersja nie została oznaczona do publikacji." @@ -203,6 +203,14 @@ msgstr "zapis publikacji obrazu" msgid "image publish records" msgstr "zapisy publikacji obrazów" +#: templates/catalogue/active_users_list.html:5 +msgid "Active users" +msgstr "Aktywni użytkownicy" + +#: templates/catalogue/active_users_list.html:11 +msgid "Active users since" +msgstr "Użytkownicy aktywni od" + #: templates/catalogue/activity.html:6 templates/catalogue/activity.html:12 #: templatetags/catalogue.py:29 msgid "Activity" diff --git a/apps/catalogue/models/image.py b/apps/catalogue/models/image.py index fffa4b38..8f044d3e 100755 --- a/apps/catalogue/models/image.py +++ b/apps/catalogue/models/image.py @@ -48,10 +48,14 @@ class Image(dvcs_models.Document): return ("catalogue_image", [self.slug]) def correct_about(self): - return "http://%s%s" % ( + return ["http://%s%s" % ( Site.objects.get_current().domain, self.get_absolute_url() - ) + ), + "http://%s%s" % ( + 'obrazy.redakcja.wolnelektury.pl', + self.get_absolute_url() + )] # State & cache # ============= @@ -86,8 +90,8 @@ class Image(dvcs_models.Document): raise AssertionError(_('Invalid Dublin Core') + ': ' + str(e)) valid_about = self.correct_about() - assert picture.picture_info.about == valid_about, \ - _("rdf:about is not") + " " + valid_about + assert picture.picture_info.about in valid_about, \ + _("rdf:about is not") + " " + valid_about[0] def publishable_error(self): try: diff --git a/apps/catalogue/templates/catalogue/base.html b/apps/catalogue/templates/catalogue/base.html index 466abe9e..c169f941 100644 --- a/apps/catalogue/templates/catalogue/base.html +++ b/apps/catalogue/templates/catalogue/base.html @@ -10,7 +10,7 @@ {% block add_css %}{% endblock %} - +
diff --git a/apps/catalogue/urls.py b/apps/catalogue/urls.py index a09dd120..7989d2ad 100644 --- a/apps/catalogue/urls.py +++ b/apps/catalogue/urls.py @@ -55,4 +55,5 @@ urlpatterns = patterns('catalogue.views', 'image_mass_edit', name='catalogue_image_mass_edit'), url(r'^track/(?P[^/]*)/$', PublishTrackFeed()), + url(r'^active/$', 'active_users_list', name='active_users_list'), ) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 84cc0972..b30297cd 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -1,3 +1,4 @@ +from collections import defaultdict from datetime import datetime, date, timedelta import logging import os @@ -599,3 +600,36 @@ class GalleryView(UploadView): def get_directory(self): return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery) + + +def active_users_list(request): + since = date(date.today().year, 1, 1) + by_user = defaultdict(lambda: 0) + by_email = defaultdict(lambda: 0) + names_by_email = defaultdict(set) + for change_model in (Chunk.change_model, Image.change_model): + for c in change_model.objects.filter( + created_at__gte=since).order_by( + 'author', 'author_email', 'author_name').values( + 'author', 'author_name', 'author_email').annotate( + c=Count('author'), ce=Count('author_email')).distinct(): + if c['author']: + by_user[c['author']] += c['c'] + else: + by_email[c['author_email']] += c['ce'] + if c['author_name'].strip(): + names_by_email[c['author_email']].add(c['author_name']) + for user in User.objects.filter(pk__in=by_user): + by_email[user.email] += by_user[user.pk] + names_by_email[user.email].add("%s %s" % (user.first_name, user.last_name)) + + active_users = [] + for email, count in by_email.items(): + active_users.append((email, names_by_email[email], count)) + active_users.sort(key=lambda x: -x[2]) + return render(request, 'catalogue/active_users_list.html', { + 'users': active_users, + 'since': since, + }) + + diff --git a/apps/cover/forms.py b/apps/cover/forms.py index e6ffdff4..e4c949c8 100755 --- a/apps/cover/forms.py +++ b/apps/cover/forms.py @@ -3,6 +3,7 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +import json import re from urllib2 import urlopen from django import forms @@ -62,6 +63,7 @@ class FlickrForm(forms.Form): def clean_source_url(self): def normalize_html(html): + return html return re.sub('[\t\n]', '', html) url = self.cleaned_data['source_url'] @@ -75,7 +77,7 @@ class FlickrForm(forms.Form): html = normalize_html(urlopen(url).read().decode('utf-8')) except: raise forms.ValidationError('Error reading page.') - match = re.search(r'Some rights reserved', html) + match = re.search(r']* rel="license ', html) try: assert match license_url = match.group(1) @@ -87,22 +89,21 @@ class FlickrForm(forms.Form): except AssertionError: raise forms.ValidationError('Error reading license name.') - m = re.search(r'"ownername":"([^"]*)', html) + m = re.search(r']* class="owner-name [^>]*>([^<]*)<', html) if m: self.cleaned_data['author'] = "%s@Flickr" % m.group(1) else: raise forms.ValidationError('Error reading author name.') - m = re.search(r']*>(.*?)', html) + m = re.search(r']*>(.*?)', html, re.S) if not m: raise forms.ValidationError('Error reading image title.') - self.cleaned_data['title'] = m.group(1) + self.cleaned_data['title'] = m.group(1).strip() - url_size = base_url + "sizes/o/" - html = normalize_html(urlopen(url_size).read().decode('utf-8')) - m = re.search(r'
\s*--- "]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+", "$1"], ["\\s+(\")", "$1"], ["([^\\.])(\\s*)
{% block maincontent %} {% endblock %}
- + {% block extrabody %}{% endblock %}