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."
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"
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
# =============
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:
{% block add_css %}{% endblock %}
</head>
<body>
-
+<!--#include file='/pozor.html'-->
<div id="tabs-nav">
<a href="{% url 'catalogue_document_list' %}">
'image_mass_edit', name='catalogue_image_mass_edit'),
url(r'^track/(?P<slug>[^/]*)/$', PublishTrackFeed()),
+ url(r'^active/$', 'active_users_list', name='active_users_list'),
)
+from collections import defaultdict
from datetime import datetime, date, timedelta
import logging
import os
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,
+ })
+
+
# 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
def clean_source_url(self):
def normalize_html(html):
+ return html
return re.sub('[\t\n]', '', html)
url = self.cleaned_data['source_url']
html = normalize_html(urlopen(url).read().decode('utf-8'))
except:
raise forms.ValidationError('Error reading page.')
- match = re.search(r'<a href="([^"]*)" rel="license cc:license">Some rights reserved</a>', html)
+ match = re.search(r'<a href="([^"]*)"[^>]* rel="license ', html)
try:
assert match
license_url = match.group(1)
except AssertionError:
raise forms.ValidationError('Error reading license name.')
- m = re.search(r'"ownername":"([^"]*)', html)
+ m = re.search(r'<a[^>]* 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'<h1[^>]*>(.*?)</h1>', html)
+ m = re.search(r'<h1[^>]*>(.*?)</h1>', 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'<div id="allsizes-photo">\s*<img src="([^"]*)"', html)
- if m:
- self.cleaned_data['download_url'] = m.group(1)
- else:
+ m = re.search(r'modelExport: (\{.*\})', html)
+ try:
+ assert m
+ self.cleaned_data['download_url'] = 'https:' + json.loads(m.group(1))['photo-models'][0]['sizes']['o']['url']
+ except (AssertionError, ValueError, IndexError, KeyError):
raise forms.ValidationError('Error reading image URL.')
return base_url
def thumbnail(relpath):
try:
return default.backend.get_thumbnail(relpath, "x50").url
- except IOError:
+ except (IOError, ValueError):
# That's not an image. No thumb.
return None
"<akap_dialog>--- "]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""],
["\\s+", " "], ["(,,)\\s+", "$1"], ["\\s+(\")", "$1"], ["([^\\.])(\\s*)</p",
"$1.$2</p"], ["([\\.:;!\\?])([^\\s\\\\])", "$1 $2"], ["([^\\s])\\s+([\\.:;!\\?])",
- "$1$2"], ["\\s+,([^,])", ",$1"], ["([^,]),([^\\s\\\\,])", "$1, $2"],
- ["([A-Za-z])0", "$1o"], ["(\\. )0([A-Za-z])", "$1O$2"], [" 0([A-Za-z])", " o$1"],
- ["([A-Za-z])1", "$1l"], ["(\\. )1([A-Za-z])", "$1L$2"], [" 1([A-Za-z])", " l$1"]]}]]'
+ "$1$2"], ["\\s+,([^,])", ",$1"], ["([^,]),([^\\s\\\\,])", "$1, $2"], ["([A-Za-z])0",
+ "$1o"], ["(\\. )0([A-Za-z])", "$1O$2"], [" 0([A-Za-z])", " o$1"], ["([A-Za-z])1",
+ "$1l"], ["(\\. )1([A-Za-z])", "$1L$2"], [" 1([A-Za-z])", " l$1"]]}]]'
scriptlet: macro
slug: basic_correction
tooltip: "Wykonuj\u0119 podstawow\u0105 korekt\u0119 tekstu."
tooltip: "Wstawia ko\u0144cowy znacznik ci\u0119cia cz\u0119\u015Bci"
model: toolbar.button
pk: 107
+- fields:
+ accesskey: ''
+ group: [11]
+ label: etap
+ link: ''
+ params: '{"tag": "developmentStage"}'
+ scriptlet: insert_tag
+ slug: etap
+ tooltip: "wymaga uwsp\xF3\u0142czesnienia: 0.3"
+ model: toolbar.button
+ pk: 108
- fields: {code: '-'}
model: toolbar.scriptlet
pk: autotag
var vname = arguments[0];
var base_path = "/images";
- if (vname == "ajax_document_text") {
- return base_path + "/text/" + arguments[1] + "/";
- }
+ if (vname == "ajax_document_text")
+ return base_path + "/text/" + arguments[1] + "/";
+
if (vname == "ajax_document_revert") {
return base_path + "/revert/" + arguments[1] + '/';
$.ajax({
method: "GET",
url: reverse("ajax_document_text", self.id),
- data: {"commit": self.commit},
+ data: {"revision": self.revision},
dataType: 'json',
success: function(data) {
var changed = false;
- if (self.text === null || self.commit !== data.commit) {
+ if (self.text === null || self.revision !== data.revision) {
self.text = data.text;
if (self.text === '') {
self.text = '<picture></picture>';
}
self.revision = data.revision;
- self.commit = data.commit;
+// self.commit = data.commit;
changed = true;
self.triggerDocumentChanged();
};
if (data.text) {
self.text = data.text;
self.revision = data.revision;
- self.commit = data.commit;
+// self.commit = data.commit;
changed = true;
self.triggerDocumentChanged();
};
<!-- version: {{ APP_VERSION }} -->
<div id="content">{% block maincontent %} {% endblock %}</div>
</div>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
{% block extrabody %}{% endblock %}
</body>
</html>