-i https://py.mdrn.pl/simple/
# django
-Django==3.2.16
+Django==4.0.8
fnpdjango==0.6
docutils==0.16
django-extensions==3.2.1
djangorestframework==3.13.1
djangorestframework-xml==2.0.0
-django-admin-ordering==0.14.0
+django-admin-ordering==0.16
django-countries==7.3.2
# A version compatible with Django 2.2+, with long help text and editable max_length.
polib==1.1.1
-pytz==2022.2.1
-
-django-honeypot==1.0.2
+django-honeypot==1.0.3
python-fb==0.2
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django import template
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.safestring import mark_safe
from ajaxable.utils import placeholdized
return mark_safe(template % {
'errors': field.errors,
'input': field,
- 'label': ('*' if field.field.required else '') + force_text(field.label),
- 'helptext': force_text(field.help_text),
+ 'label': ('*' if field.field.required else '') + force_str(field.label),
+ 'helptext': force_str(field.help_text),
})
#
from functools import wraps
import json
+from urllib.parse import quote_plus
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import render
-from django.utils.encoding import force_text
+from django.utils.encoding import force_str
from django.utils.functional import Promise
-from django.utils.http import urlquote_plus
from django.utils.translation import gettext_lazy as _
from django.views.decorators.vary import vary_on_headers
from honeypot.decorators import verify_honeypot_value
+from wolnelektury.utils import is_ajax
class LazyEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, Promise):
- return force_text(o)
+ return force_str(o)
return o
def require_login(request):
"""Return 403 if request is AJAX. Redirect to login page if not."""
- if request.is_ajax():
+ if is_ajax(request):
return HttpResponseForbidden('Not logged in')
return HttpResponseRedirect('/uzytkownicy/zaloguj') # next?=request.build_full_path())
}
if add_args:
response_data.update(add_args)
- if not request.is_ajax() and response_data['redirect']:
- return HttpResponseRedirect(urlquote_plus(
+ if not is_ajax(request) and response_data['redirect']:
+ return HttpResponseRedirect(quote_plus(
response_data['redirect'], safe='/?=&'))
- elif request.is_ajax():
+ elif is_ajax(request):
# Form was sent with errors. Send them back.
if self.form_prefix:
errors = {}
response_data = {'success': False, 'errors': errors}
else:
response_data = None
- if request.is_ajax():
+ if is_ajax(request):
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 is_ajax(request):
return require_login(request)
form = self.form_class(*form_args, **form_kwargs)
response_data = None
title = self.title
- if request.is_ajax():
+ if is_ajax(request):
template = self.template
else:
template = self.full_template
def redirect_or_refresh(self, request, path, message=None):
"""If the form is AJAX, refresh the page. If not, go to `path`."""
- if request.is_ajax():
+ if is_ajax(request):
output = "<script>window.location.reload()</script>"
if message:
output = "<div class='normal-text'>" + message + "</div>" + output
from collections import OrderedDict
import random
import re
+from urllib.parse import quote_plus
from django.conf import settings
from django.template.loader import render_to_string
from django.urls import reverse
from django.db.models import Q, QuerySet
from django.contrib.auth.decorators import login_required, user_passes_test
-from django.utils.http import urlquote_plus
from django.utils import translation
from django.utils.translation import gettext as _, gettext_lazy
from django.views.decorators.cache import never_cache
url = book.zip_audiobooks(media_format)
else:
raise Http404('No format specified for zip package')
- return HttpResponseRedirect(urlquote_plus(settings.MEDIA_URL + url, safe='/?='))
+ return HttpResponseRedirect(quote_plus(settings.MEDIA_URL + url, safe='/?='))
class CustomPDFFormView(AjaxableFormView):
from django.urls import reverse
from django.db import models
from django import template
-from django.utils.timezone import now
+from django.utils.timezone import now, utc
from django.utils.translation import gettext_lazy as _, ngettext, gettext, get_language
from django_countries.fields import CountryField
-from pytz import utc
from catalogue.utils import get_random_hash
from messaging.states import Level
from reporting.utils import render_to_pdf
return agreement_approval_url(schedule.amount, schedule.key, app=app)
def pay(self, request, schedule):
- from datetime import date, timedelta, datetime
- from pytz import utc
- tomorrow = datetime(*(date.today() + timedelta(2)).timetuple()[:3], tzinfo=utc)
+ from datetime import date, timedelta, datetime, timezone
+ tomorrow = datetime(*(date.today() + timedelta(2)).timetuple()[:3], tzinfo=timezone.utc)
any_active = False
for ba in schedule.billingagreement_set.all():
active = ba.check_agreement()
from datetime import date, datetime, timedelta
from decimal import Decimal
import paypalrestsdk
-import pytz
from django.contrib.sites.models import Site
from django.urls import reverse
from django.utils import timezone
plan_id = create_plan(amount)
else:
plan_id = plan.plan_id
- start = (timezone.now() + timedelta(0, 3600*24)).astimezone(pytz.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
+ start = (timezone.now() + timedelta(0, 3600*24)).astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
billing_agreement = paypalrestsdk.BillingAgreement({
"name": "Subskrypcja klubu WL",
"description": "Stałe wsparcie Wolnych Lektur kwotą %s złotych" % amount,
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
import datetime
-import pytz
from django.conf import settings
from django import template
from django.utils import timezone
"""
if day_end:
date += datetime.timedelta(1)
- localtime = datetime.datetime.combine(date, datetime.time(0, 0))
- return timezone.utc.normalize(
- pytz.timezone(settings.TIME_ZONE).localize(localtime)
- )
+
+ localtime = datetime.datetime.combine(date, datetime.time(0, 0), timezone.get_current_timezone())
+ return timezone.localtime(localtime, timezone.utc)
@register.filter
#
from django import forms
from django.forms.utils import flatatt
-from django.utils.encoding import smart_text
+from django.utils.encoding import smart_str
from django.utils.safestring import mark_safe
from json import dumps
final_attrs = self.build_attrs(self.attrs, attrs)
final_attrs["name"] = name
if value:
- final_attrs['value'] = smart_text(value)
+ final_attrs['value'] = smart_str(value)
if 'id' not in self.attrs:
final_attrs['id'] = 'id_%s' % name
from catalogue.models import Book
from social import forms
+from wolnelektury.utils import is_ajax
# ====================
book.like(request.user)
- if request.is_ajax():
+ if is_ajax(request):
return JsonResponse({"success": True, "msg": "ok", "like": True})
else:
return redirect(book)
book.unlike(request.user)
- if request.is_ajax():
+ if is_ajax(request):
return JsonResponse({"success": True, "msg": "ok", "like": False})
else:
return redirect(book)
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from django.views.decorators.cache import never_cache
+from wolnelektury.utils import is_ajax
@never_cache
file_url = None
waiting = get_object_or_404(WaitedFile, path=path)
- if request.is_ajax():
+ if is_ajax(request):
return HttpResponse(file_url)
else:
return render(request, "waiter/wait.html", {
from io import BytesIO
import json
import os
-import pytz
import re
from django.conf import settings
from django.core.mail import send_mail
from django.http import HttpResponse
from django.template.loader import render_to_string
-from django.utils import timezone
from django.utils.translation import get_language
from django.conf import settings
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
-tz = pytz.timezone(settings.TIME_ZONE)
-
-
-def localtime_to_utc(localtime):
- return timezone.utc.normalize(
- tz.localize(localtime)
- )
-
-
def utc_for_js(dt):
return dt.strftime('%Y/%m/%d %H:%M:%S UTC')
return queryset.filter(self.q)
elif self.value() == 'no':
return queryset.exclude(self.q)
+
+
+def is_ajax(request):
+ return request.headers.get('x-requested-with') == 'XMLHttpRequest'
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from datetime import date, datetime
+from urllib.parse import quote_plus
import feedparser
from allauth.socialaccount.views import SignupView
from django.core.cache import cache
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
-from django.utils.http import urlquote_plus
from django.utils.translation import gettext_lazy as _
from django.views.decorators.cache import never_cache
@never_cache
def logout_then_redirect(request):
auth.logout(request)
- return HttpResponseRedirect(urlquote_plus(request.GET.get('next', '/'), safe='/?='))
+ return HttpResponseRedirect(quote_plus(request.GET.get('next', '/'), safe='/?='))
@never_cache