-i https://py.mdrn.pl/simple/
# django
-Django==1.11.22
+Django==2.0.13
fnpdjango==0.4
django-pipeline==1.6.13
jsmin
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
return response
# do I need to be logged in?
- if self.POST_login and not request.user.is_authenticated():
+ if self.POST_login and not request.user.is_authenticated:
return require_login(request)
form_kwargs['data'] = request.POST
if request.is_ajax():
return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data))
else:
- if self.POST_login and not request.user.is_authenticated() and not request.is_ajax():
+ if self.POST_login and not request.user.is_authenticated and not request.is_ajax():
return require_login(request)
form = self.form_class(*form_args, **form_kwargs)
def view_decorator(func):
def wrapper(request, *args, **kwargs):
return view_or_basicauth(func, request,
- lambda u: u.is_authenticated(),
+ lambda u: u.is_authenticated,
realm, *args, **kwargs)
return wrapper
return view_decorator
def to_representation(self, value):
request = self.context['request']
if not hasattr(request, 'liked_books'):
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
request.liked_books = set(Book.tagged.with_any(request.user.tag_set.all()).values_list('id', flat=True))
else:
request.liked_books = None
fn_type=fn_type,
language=language
)
-
qualifier_objects = []
for qualifier in qualifiers:
obj, created = Qualifier.objects.get_or_create(
'name': FN_QUALIFIERS.get(qualifier, '')
})
qualifier_objects.append(obj)
- note.qualifiers = qualifier_objects
+ note.qualifiers.set(qualifier_objects)
note.notesource_set.create(book=book, anchor=anchor)
Note.objects.filter(notesource=None).delete()
)
def test_book_with_footnote(self):
- book_text = """<utwor>
+ book_text = b"""<utwor>
<opowiadanie>
<akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
<akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
@cache.never_cache
def new_poem(request):
- user = request.user if request.user.is_authenticated() else None
+ user = request.user if request.user.is_authenticated else None
text = Poem.write()
p = Poem(slug=get_random_hash(text), text=text, created_by=user)
p.save()
@cache.never_cache
def poem_from_book(request, slug):
book = get_object_or_404(Book, slug=slug)
- user = request.user if request.user.is_authenticated() else None
+ user = request.user if request.user.is_authenticated else None
text = Poem.write(Continuations.get(book))
p = Poem(slug=get_random_hash(text), text=text, created_by=user)
p.created_from = json.dumps([book.id])
@cache.never_cache
def poem_from_set(request, shelf):
- user = request.user if request.user.is_authenticated() else None
+ user = request.user if request.user.is_authenticated else None
tag = get_object_or_404(Tag, category='set', slug=shelf)
text = Poem.write(Continuations.get(tag))
p = Poem(slug=get_random_hash(text), text=text, created_by=user)
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
def paypal_form(request, app=False):
if request.POST:
- if not request.user.is_authenticated():
+ if not request.user.is_authenticated:
return HttpResponseForbidden()
form = PaypalSubscriptionForm(data=request.POST)
if form.is_valid():
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
self._obj = obj
self._user = user
data = kwargs.setdefault('data', {})
- if 'tags' not in data and user.is_authenticated():
+ if 'tags' not in data and user.is_authenticated:
data['tags'] = ', '.join(
obj.tags.filter(category='set', user=user).exclude(name__in=(None, '')).values_list('name', flat=True))
super(ObjectSetsForm, self).__init__(*args, **kwargs)
@register.simple_tag(takes_context=True)
def book_shelf_tags(context, book_id):
request = context['request']
- if not request.user.is_authenticated():
+ if not request.user.is_authenticated:
return ''
book = Book.objects.get(pk=book_id)
lks = likes(request.user, book, request)
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
def likes(user, work, request=None):
- if not user.is_authenticated():
+ if not user.is_authenticated:
return False
if request is None:
@require_POST
def like_book(request, slug):
- if not request.user.is_authenticated():
+ if not request.user.is_authenticated:
return HttpResponseForbidden('Login required.')
book = get_object_or_404(Book, slug=slug)
@require_POST
def unlike_book(request, slug):
- if not request.user.is_authenticated():
+ if not request.user.is_authenticated:
return HttpResponseForbidden('Login required.')
book = get_object_or_404(Book, slug=slug)
-# -*- coding: utf-8 -*-
import re
from fnpdjango.utils.text import char_map
# Specifies diacritics order.
# Default order is zero, max is 9
char_order = {
- u'ż': 1, u'Ż': 1,
+ 'ż': 1, 'Ż': 1,
}
value = value.lower()
value = re.sub(r'[^a-z0-9~]+', ' ', value)
- return value.encode('ascii', 'ignore')
+ return value.encode('ascii', 'ignore').decode('ascii')
-# -*- coding: utf-8 -*-
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
output = [super(SponsorPageWidget, self).render(name, value, attrs)]
sponsors = [(str(obj), obj.pk, obj.logo.url) for obj in models.Sponsor.objects.all().iterator()]
sponsors_js = ', '.join('{name: "%s", id: %d, image: "%s"}' % sponsor for sponsor in sponsors)
- output.append(u'<script type="text/javascript">addEvent(window, "load", function(e) {')
+ output.append('<script type="text/javascript">$(function(e) {')
# TODO: "id_" is hard-coded here. This should instead use the correct
# API to determine the ID dynamically.
output.append(u'$("#id_%s").sponsorsFooter({sponsors: [%s]}); });</script>\n' % (name, sponsors_js))
description = self.cleaned_data['description']
suggestion = Suggestion(contact=contact, description=description, ip=request.META['REMOTE_ADDR'])
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
suggestion.user = request.user
suggestion.save()
%(description)s''' % {
'site': Site.objects.get_current().domain,
'url': reverse('admin:suggest_suggestion_change', args=[suggestion.id]),
- 'user': str(request.user) if request.user.is_authenticated() else '',
+ 'user': str(request.user) if request.user.is_authenticated else '',
'contact': contact,
'description': description,
}, fail_silently=True)
suggestion = PublishingSuggestion(
contact=contact, books=books,
audiobooks=audiobooks, ip=request.META['REMOTE_ADDR'])
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
suggestion.user = request.user
suggestion.save()
Audiobooki:
%(audiobooks)s''' % {
'url': request.build_absolute_uri(reverse('admin:suggest_suggestion_change', args=[suggestion.id])),
- 'user': str(request.user) if request.user.is_authenticated() else '',
+ 'user': str(request.user) if request.user.is_authenticated else '',
'contact': contact,
'books': books,
'audiobooks': audiobooks,
#
CELERY_BROKER_URL = 'redis://'
-CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
+CELERY_TASK_EAGER_PROPAGATES = True
CELERY_SEND_TASK_ERROR_EMAILS = True
CELERY_ACCEPT_CONTENT = ['pickle']
CELERY_TASK_SERIALIZER = 'pickle'
url(r'^admin/catalogue/book/import$', catalogue.views.import_book, name='import_book'),
url(r'^admin/catalogue/picture/import$', picture.views.import_picture, name='import_picture'),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- url(r'^admin/', include(admin.site.urls)),
+ url(r'^admin/', admin.site.urls),
# API
url(r'^api/', include('api.urls')),
if fun_kwargs or key in fun_params)
kwargs.update(stringify_keys(request_params))
res = None
- if login_required and not request.user.is_authenticated():
+ if login_required and not request.user.is_authenticated:
res = {'result': 'logout'}
if (permission_required and
not request.user.has_perm(permission_required)):
ajax_redirect = True
def __call__(self, request):
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
return self.redirect_or_refresh(
request, '/',
message=_('Already logged in as user %(user)s', ) % {'user': request.user.username})
honeypot = True
def __call__(self, request):
- if request.user.is_authenticated():
+ if request.user.is_authenticated:
return self.redirect_or_refresh(
request, '/',
message=_('Already logged in as user %(user)s', ) % {'user': request.user.username})