Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
test:
name: Py ${{ matrix.python }} / Django ${{ matrix.django }}
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.9', '3.10', '3.11', '3.12']
django: ['4.2']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade Django~=${{ matrix.django }}
pip install --upgrade pytz
- name: Test build
run: |
python setup.py -q build
- name: Run Tests
run: |
export PYTHONWARNINGS="default"
make test
coverage:
name: Coverage / Py ${{ matrix.python }} / Django ${{ matrix.django }}
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.12']
django: ['4.2']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade Django~=${{ matrix.django }}
pip install --upgrade pytz
pip install --upgrade coveralls
- name: Run Tests
run: |
coverage run --source=. runtests.py
- name: Submit to coveralls
env:
COVERALLS_FLAG_NAME: run-${{ matrix.python }}-${{ matrix.django }}
COVERALLS_PARALLEL: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
coveralls --finish
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

24 changes: 5 additions & 19 deletions infinite_scroll_pagination/serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#-*- coding: utf-8 -*-

import re
import time
from datetime import datetime
from datetime import datetime, timezone as tz

from django.core.paginator import InvalidPage
from django.utils import timezone
Expand All @@ -20,24 +19,14 @@ def _make_aware_maybe(dt):
if not getattr(settings, 'USE_TZ', False):
return dt
if timezone.is_aware(dt):
return dt.astimezone(timezone.utc)
return timezone.make_aware(dt, timezone=timezone.utc)
return dt.astimezone(tz.utc)
return timezone.make_aware(dt, timezone=tz.utc)


def _fromtimestamp(ts):
if not getattr(settings, 'USE_TZ', False):
return datetime.fromtimestamp(ts)
return datetime.utcfromtimestamp(ts)


# py2 only
def _timestamp(dt):
if timezone.is_naive(dt):
return time.mktime((
dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second,
-1, -1, -1)) + dt.microsecond / 1e6
return (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
return datetime.fromtimestamp(ts, tz.utc)


def page_key(raw_page):
Expand Down Expand Up @@ -66,8 +55,5 @@ def to_page_key(value=None, pk=None):
if isinstance(value, (tuple, list)):
(value,) = value
value = _make_aware_maybe(value)
try:
timestamp = value.timestamp()
except AttributeError:
timestamp = _timestamp(value)
timestamp = value.timestamp()
return '{:.6f}-{}'.format(timestamp, pk)
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
ROOT_URLCONF="tests.urls",
DEBUG=False,
SECRET_KEY="qwerty",
)


Expand Down
6 changes: 5 additions & 1 deletion tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
from .models import Article


def is_ajax(request):
return request.headers.get('x-requested-with') == 'XMLHttpRequest'


def pagination_ajax(request):
if not request.is_ajax():
if not is_ajax(request):
return Http404()

try:
Expand Down