fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
040285e
)
Fixes
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 1 Oct 2019 08:56:32 +0000
(10:56 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 1 Oct 2019 08:56:32 +0000
(10:56 +0200)
requirements/requirements.txt
patch
|
blob
|
history
src/apiclient/__init__.py
patch
|
blob
|
history
src/catalogue/models/book.py
patch
|
blob
|
history
src/catalogue/models/image.py
patch
|
blob
|
history
src/catalogue/templates/catalogue/active_users_list.html
patch
|
blob
|
history
src/catalogue/templatetags/book_list.py
patch
|
blob
|
history
src/catalogue/views.py
patch
|
blob
|
history
src/fileupload/views.py
patch
|
blob
|
history
diff --git
a/requirements/requirements.txt
b/requirements/requirements.txt
index
6bbdf22
..
09a9877
100644
(file)
--- a/
requirements/requirements.txt
+++ b/
requirements/requirements.txt
@@
-8,7
+8,7
@@
oauth2
httplib2 # oauth2 dependency
python-slugify
httplib2 # oauth2 dependency
python-slugify
-librarian==1.7.
1
+librarian==1.7.
6
## Django
Django==1.11.20
## Django
Django==1.11.20
diff --git
a/src/apiclient/__init__.py
b/src/apiclient/__init__.py
index
56ecb96
..
5eee2fd
100644
(file)
--- a/
src/apiclient/__init__.py
+++ b/
src/apiclient/__init__.py
@@
-1,7
+1,6
@@
-import urllib
-
import json
import oauth2
import json
import oauth2
+from urllib.parse import urlencode
from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL, BETA_API_URL
from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL, BETA_API_URL
@@
-30,7
+29,7
@@
def api_call(user, path, data=None, beta=False):
client = oauth2.Client(wl_consumer, token)
if data is not None:
data = json.dumps(data)
client = oauth2.Client(wl_consumer, token)
if data is not None:
data = json.dumps(data)
- data = url
lib.url
encode({"data": data})
+ data = urlencode({"data": data})
resp, content = client.request(
"%s%s" % (api_url, path),
method="POST",
resp, content = client.request(
"%s%s" % (api_url, path),
method="POST",
diff --git
a/src/catalogue/models/book.py
b/src/catalogue/models/book.py
index
229b3d0
..
a846f6e
100755
(executable)
--- a/
src/catalogue/models/book.py
+++ b/
src/catalogue/models/book.py
@@
-1,5
+1,3
@@
-# -*- coding: utf-8 -*-
-#
# 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.
#
@@
-95,7
+93,7
@@
class Book(models.Model):
# =======================
def accessible(self, request):
# =======================
def accessible(self, request):
- return self.public or request.user.is_authenticated
()
+ return self.public or request.user.is_authenticated
@classmethod
@transaction.atomic
@classmethod
@transaction.atomic
diff --git
a/src/catalogue/models/image.py
b/src/catalogue/models/image.py
index
8cadcec
..
dbe1c04
100755
(executable)
--- a/
src/catalogue/models/image.py
+++ b/
src/catalogue/models/image.py
@@
-1,5
+1,3
@@
-# -*- coding: utf-8 -*-
-#
# 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.
#
@@
-101,7
+99,7
@@
class Image(dvcs_models.Document):
return None
def accessible(self, request):
return None
def accessible(self, request):
- return self.public or request.user.is_authenticated
()
+ return self.public or request.user.is_authenticated
def is_new_publishable(self):
change = self.publishable()
def is_new_publishable(self):
change = self.publishable()
diff --git
a/src/catalogue/templates/catalogue/active_users_list.html
b/src/catalogue/templates/catalogue/active_users_list.html
index
f711b60
..
3741b41
100755
(executable)
--- a/
src/catalogue/templates/catalogue/active_users_list.html
+++ b/
src/catalogue/templates/catalogue/active_users_list.html
@@
-8,7
+8,7
@@
{% block content %}
<h1>
{% block content %}
<h1>
- {% trans "
Active users since" %} {{ since
}}
+ {% trans "
Users active in the year" %} {{ year
}}
</h1>
<ul>
</h1>
<ul>
diff --git
a/src/catalogue/templatetags/book_list.py
b/src/catalogue/templatetags/book_list.py
index
b9130a8
..
b492433
100755
(executable)
--- a/
src/catalogue/templatetags/book_list.py
+++ b/
src/catalogue/templatetags/book_list.py
@@
-1,5
+1,3
@@
-from __future__ import absolute_import
-
from re import split
from django.db.models import Q, Count
from django import template
from re import split
from django.db.models import Q, Count
from django import template
@@
-98,7
+96,7
@@
def document_list_filter(request, **kwargs):
chunks = chunks.order_by('book__title', 'book', 'number')
chunks = chunks.order_by('book__title', 'book', 'number')
- if not request.user.is_authenticated
()
:
+ if not request.user.is_authenticated:
chunks = chunks.filter(book__public=True)
state = arg_or_GET('status')
chunks = chunks.filter(book__public=True)
state = arg_or_GET('status')
@@
-160,7
+158,7
@@
def image_list_filter(request, **kwargs):
images = Image.objects.all().select_related('user', 'stage', 'project')
images = Image.objects.all().select_related('user', 'stage', 'project')
- if not request.user.is_authenticated
()
:
+ if not request.user.is_authenticated:
images = images.filter(public=True)
state = arg_or_GET('status')
images = images.filter(public=True)
state = arg_or_GET('status')
diff --git
a/src/catalogue/views.py
b/src/catalogue/views.py
index
1497be0
..
ab1f821
100644
(file)
--- a/
src/catalogue/views.py
+++ b/
src/catalogue/views.py
@@
-1,4
+1,3
@@
-# -*- coding: utf-8 -*-
from collections import defaultdict
from datetime import datetime, date, timedelta
import logging
from collections import defaultdict
from datetime import datetime, date, timedelta
import logging
@@
-112,7
+111,7
@@
def create_missing(request, slug=None):
form = forms.DocumentCreateForm(request.POST, request.FILES)
if form.is_valid():
form = forms.DocumentCreateForm(request.POST, request.FILES)
if form.is_valid():
- if request.user.is_authenticated
()
:
+ if request.user.is_authenticated:
creator = request.user
else:
creator = None
creator = request.user
else:
creator = None
@@
-148,7
+147,7
@@
def upload(request):
if form.is_valid():
from slugify import slugify
if form.is_valid():
from slugify import slugify
- if request.user.is_authenticated
()
:
+ if request.user.is_authenticated:
creator = request.user
else:
creator = None
creator = request.user
else:
creator = None
@@
-395,7
+394,7
@@
def chunk_add(request, slug, chunk):
if request.method == "POST":
form = forms.ChunkAddForm(request.POST, instance=doc)
if form.is_valid():
if request.method == "POST":
form = forms.ChunkAddForm(request.POST, instance=doc)
if form.is_valid():
- if request.user.is_authenticated
()
:
+ if request.user.is_authenticated:
creator = request.user
else:
creator = None
creator = request.user
else:
creator = None
@@
-461,8
+460,8
@@
def chunk_edit(request, slug, chunk):
@login_required
@require_POST
def chunk_mass_edit(request):
@login_required
@require_POST
def chunk_mass_edit(request):
- ids =
map(int, filter(lambda i: i.strip()!='', request.POST.get('ids').split(',')))
- chunks =
map(lambda i: Chunk.objects.get(id=i), ids
)
+ ids =
[int(i) for i in request.POST.get('ids').split(',') if i.strip()]
+ chunks =
list(Chunk.objects.filter(id__in=ids)
)
stage = request.POST.get('stage')
if stage:
stage = request.POST.get('stage')
if stage:
@@
-624,13
+623,13
@@
class GalleryView(UploadView):
def active_users_list(request):
def active_users_list(request):
-
since = date(date.today().year, 1, 1
)
+
year = int(request.GET.get('y', date.today().year)
)
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(
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(
+ created_at__
year=year
).order_by(
'author', 'author_email', 'author_name').values(
'author', 'author_name', 'author_email').annotate(
c=Count('author'), ce=Count('author_email')).distinct():
'author', 'author_email', 'author_name').values(
'author', 'author_name', 'author_email').annotate(
c=Count('author'), ce=Count('author_email')).distinct():
@@
-638,7
+637,7
@@
def active_users_list(request):
by_user[c['author']] += c['c']
else:
by_email[c['author_email']] += c['ce']
by_user[c['author']] += c['c']
else:
by_email[c['author_email']] += c['ce']
- if
c['author_name']
.strip():
+ if
(c['author_name'] or '')
.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[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]
@@
-650,7
+649,7
@@
def active_users_list(request):
active_users.sort(key=lambda x: -x[2])
return render(request, 'catalogue/active_users_list.html', {
'users': active_users,
active_users.sort(key=lambda x: -x[2])
return render(request, 'catalogue/active_users_list.html', {
'users': active_users,
- '
since': since
,
+ '
year': year
,
})
})
diff --git
a/src/fileupload/views.py
b/src/fileupload/views.py
index
3e6b999
..
eb7959c
100644
(file)
--- a/
src/fileupload/views.py
+++ b/
src/fileupload/views.py
@@
-129,7
+129,7
@@
class UploadView(FormView):
os.makedirs(path)
data = []
for f in flist:
os.makedirs(path)
data = []
for f in flist:
- with open(self.get_safe_path(f.name), 'w') as destination:
+ with open(self.get_safe_path(f.name), 'w
b
') as destination:
for chunk in f.chunks():
destination.write(chunk)
data.append({
for chunk in f.chunks():
destination.write(chunk)
data.append({