local changes from server
authorJan Szejko <j-sz@o2.pl>
Wed, 16 Mar 2016 14:37:41 +0000 (15:37 +0100)
committerJan Szejko <j-sz@o2.pl>
Wed, 16 Mar 2016 14:38:28 +0000 (15:38 +0100)
apps/catalogue/locale/pl/LC_MESSAGES/django.po
apps/catalogue/models/image.py
apps/catalogue/templates/catalogue/base.html
apps/catalogue/urls.py
apps/catalogue/views.py
apps/cover/forms.py
apps/fileupload/views.py
apps/toolbar/fixtures/initial_toolbar.yaml
redakcja/static/js/wiki_img/wikiapi.js
redakcja/templates/base.html

index 67f10ef..53b753b 100644 (file)
@@ -145,7 +145,7 @@ msgstr "obraz"
 msgid "images"
 msgstr "obrazy"
 
 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 "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"
 
 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"
 #: templates/catalogue/activity.html:6 templates/catalogue/activity.html:12
 #: templatetags/catalogue.py:29
 msgid "Activity"
index fffa4b3..8f044d3 100755 (executable)
@@ -48,10 +48,14 @@ class Image(dvcs_models.Document):
         return ("catalogue_image", [self.slug])
 
     def correct_about(self):
         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()
             Site.objects.get_current().domain,
             self.get_absolute_url()
-        )
+            ),
+            "http://%s%s" % (
+                'obrazy.redakcja.wolnelektury.pl',
+                self.get_absolute_url()
+            )]
 
     # State & cache
     # =============
 
     # State & cache
     # =============
@@ -86,8 +90,8 @@ class Image(dvcs_models.Document):
             raise AssertionError(_('Invalid Dublin Core') + ': ' + str(e))
 
         valid_about = self.correct_about()
             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:
 
     def publishable_error(self):
         try:
index 466abe9..c169f94 100644 (file)
@@ -10,7 +10,7 @@
     {% block add_css %}{% endblock %}
 </head>
 <body>
     {% block add_css %}{% endblock %}
 </head>
 <body>
-
+<!--#include file='/pozor.html'-->
 <div id="tabs-nav">
 
     <a href="{% url 'catalogue_document_list' %}">
 <div id="tabs-nav">
 
     <a href="{% url 'catalogue_document_list' %}">
index a09dd12..7989d2a 100644 (file)
@@ -55,4 +55,5 @@ urlpatterns = patterns('catalogue.views',
         'image_mass_edit', name='catalogue_image_mass_edit'),
 
     url(r'^track/(?P<slug>[^/]*)/$', PublishTrackFeed()),
         'image_mass_edit', name='catalogue_image_mass_edit'),
 
     url(r'^track/(?P<slug>[^/]*)/$', PublishTrackFeed()),
+    url(r'^active/$', 'active_users_list', name='active_users_list'),
 )
 )
index 84cc097..b30297c 100644 (file)
@@ -1,3 +1,4 @@
+from collections import defaultdict
 from datetime import datetime, date, timedelta
 import logging
 import os
 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 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,
+    })
+
+
index e6ffdff..e4c949c 100755 (executable)
@@ -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.
 #
 # 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
 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):
 
     def clean_source_url(self):
         def normalize_html(html):
+            return html
             return re.sub('[\t\n]', '', html)
     
         url = self.cleaned_data['source_url']
             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.')
             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)
         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.')
 
         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.')
 
         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.')
         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
             raise forms.ValidationError('Error reading image URL.')
         return base_url
index 25112e6..a2025fe 100644 (file)
@@ -20,7 +20,7 @@ else:
     def thumbnail(relpath):
         try:
             return default.backend.get_thumbnail(relpath, "x50").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
 
             # That's not an image. No thumb.
             return None
 
index 539236f..52799ff 100644 (file)
@@ -75,9 +75,9 @@
             "<akap_dialog>--- "]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""],
             ["\\s+", " "], ["(,,)\\s+", "$1"], ["\\s+(\")", "$1"], ["([^\\.])(\\s*)</p",
             "$1.$2</p"], ["([\\.:;!\\?])([^\\s\\\\])", "$1 $2"], ["([^\\s])\\s+([\\.:;!\\?])",
             "<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."
         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
         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
 -   fields: {code: '-'}
     model: toolbar.scriptlet
     pk: autotag
index cac7e48..377e4f9 100644 (file)
@@ -17,9 +17,9 @@
                var vname = arguments[0];
                var base_path = "/images";
 
                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] + '/';
 
         if (vname == "ajax_document_revert") {
             return base_path + "/revert/" + arguments[1] + '/';
                $.ajax({
                        method: "GET",
                        url: reverse("ajax_document_text", self.id),
                $.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;
 
                        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.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();
                                };
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
-                    self.commit = data.commit;
+//                    self.commit = data.commit;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
index 595007d..65174e4 100644 (file)
@@ -21,7 +21,7 @@
                <!-- version: {{ APP_VERSION }} -->
         <div id="content">{% block maincontent %} {% endblock %}</div>
         </div>
                <!-- 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>
     {% block extrabody %}{% endblock %}
     </body>
 </html>