diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..acbd03c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,96 @@ +version: 2.0 + +common: &common + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - v2-deps- + - run: + name: install dependencies + command: pip install --user tox + - run: + name: run tox + command: ~/.local/bin/tox + - run: + name: upload coverage report + command: | + if [[ "$UPLOAD_COVERAGE" != 0 ]]; then + PATH=$HOME/.local/bin:$PATH + pip install --user codecov + coverage xml + ~/.local/bin/codecov --required -X search gcov pycov -f coverage.xml --flags $CIRCLE_JOB + fi + - save_cache: + paths: + - .tox + - ~/.cache/pip + - ~/.local + - ./eggs + key: v2-deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + +jobs: + lint: + <<: *common + docker: + - image: circleci/python:3.6.1 + environment: + - TOXENV=checkqa + - UPLOAD_COVERAGE=0 + py27dj111: + <<: *common + docker: + - image: circleci/python:2.7 + environment: + TOXENV=py27-dj111 + py34dj111: + <<: *common + docker: + - image: circleci/python:3.4 + environment: + TOXENV=py34-dj111 + py34dj20: + <<: *common + docker: + - image: circleci/python:3.4 + environment: + TOXENV=py34-dj20 + py35dj111: + <<: *common + docker: + - image: circleci/python:3.5 + environment: + TOXENV=py35-dj111 + py35dj20: + <<: *common + docker: + - image: circleci/python:3.5 + environment: + TOXENV=py35-dj20 + py36dj111: + <<: *common + docker: + - image: circleci/python:3.6 + environment: + TOXENV=py36-dj111 + py36dj20: + <<: *common + docker: + - image: circleci/python:3.6 + environment: + TOXENV=py36-dj20 + +workflows: + version: 2 + test: + jobs: + - lint + - py27dj111 + - py34dj111 + - py34dj20 + - py35dj111 + - py35dj20 + - py36dj111 + - py36dj20 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 544df4f..90463c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,45 @@ -build -dist -.coverage -.tox MANIFEST -*.pyc -*.egg-info -*.egg +.DS_Store + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ docs/_build/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +*.eggs +.python-version + +# Pipfile +Pipfile +Pipfile.lock + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# IDEs +.idea/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 27ba2ce..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -sudo: false -language: python -python: - - "2.7" - - "3.3" - - "3.4" - - "3.5" -env: - - DJANGO=1.8 - - DJANGO=1.9 - - DJANGO=master -matrix: - exclude: - - python: "3.3" - env: DJANGO=1.9 - - python: "3.3" - env: DJANGO=master -install: - - pip install tox coveralls -script: - - tox -e py${TRAVIS_PYTHON_VERSION//[.]/}-$DJANGO -after_success: - - coveralls diff --git a/AUTHORS b/AUTHORS index 5ed0ebd..1460ac1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,3 +2,4 @@ Patrick Altman James Tauber Anna Ossowski Graham Ullrich +Katherine "Kati" Michel diff --git a/README.md b/README.md index b2d3683..8dcb023 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,195 @@ +![](http://pinaxproject.com/pinax-design/patches/pinax-testimonials.svg) + # Pinax Testimonials -[![](http://slack.pinaxproject.com/badge.svg)](http://slack.pinaxproject.com/) -[![](https://img.shields.io/travis/pinax/pinax-testimonials.svg)](https://travis-ci.org/pinax/pinax-testimonials) -[![](https://img.shields.io/coveralls/pinax/pinax-testimonials.svg)](https://coveralls.io/r/pinax/pinax-testimonials) -[![](https://img.shields.io/pypi/dm/pinax-testimonials.svg)](https://pypi.python.org/pypi/pinax-testimonials/) [![](https://img.shields.io/pypi/v/pinax-testimonials.svg)](https://pypi.python.org/pypi/pinax-testimonials/) + +[![CircleCi](https://img.shields.io/circleci/project/github/pinax/pinax-testimonials.svg)](https://circleci.com/gh/pinax/pinax-testimonials) +[![Codecov](https://img.shields.io/codecov/c/github/pinax/pinax-testimonials.svg)](https://codecov.io/gh/pinax/pinax-testimonials) +[![](https://img.shields.io/github/contributors/pinax/pinax-testimonials.svg)](https://github.com/pinax/pinax-testimonials/graphs/contributors) +[![](https://img.shields.io/github/issues-pr/pinax/pinax-testimonials.svg)](https://github.com/pinax/pinax-testimonials/pulls) +[![](https://img.shields.io/github/issues-pr-closed/pinax/pinax-testimonials.svg)](https://github.com/pinax/pinax-testimonials/pulls?q=is%3Apr+is%3Aclosed) + +[![](http://slack.pinaxproject.com/badge.svg)](http://slack.pinaxproject.com/) [![](https://img.shields.io/badge/license-MIT-blue.svg)](https://pypi.python.org/pypi/pinax-testimonials/) -## Pinax +## Table of Contents + +* [About Pinax](#about-pinax) +* [Overview](#overview) + * [Supported Django and Python versions](#supported-django-and-python-versions) +* [Documentation](#documentation) + * [Installation](#installation) + * [Usage](#usage) +* [Change Log](#change-log) +* [Contribute](#contribute) +* [Code of Conduct](#code-of-conduct) +* [Connect with Pinax](#connect-with-pinax) +* [License](#license) -[Pinax](http://pinaxproject.com/pinax/) is an open-source platform built on the -Django Web Framework. It is an ecosystem of reusable Django apps, themes, and -starter project templates. +## About Pinax + +Pinax is an open-source platform built on the Django Web Framework. It is an ecosystem of reusable +Django apps, themes, and starter project templates. This collection can be found at http://pinaxproject.com. -This app is part of the Pinax ecosystem and is designed for use both with and -independently of other Pinax apps. ## pinax-testimonials +### Overview + `pinax-testimonials` is a well tested, documented, and proven solution for any site wanting to display testimonials. Testimonials contain text by an author with an optional organization affiliation. For display, testimonials are retrieved randomly or most recent first. -## Getting Started and Documentation -Follow steps outlined in [Pinax Testimonials Documentation](https://github.com/pinax/pinax-testimonials/blob/master/docs/index.md). +#### Supported Django and Python versions -## Contribute +Django \ Python | 2.7 | 3.4 | 3.5 | 3.6 +--------------- | --- | --- | --- | --- +1.11 | * | * | * | * +2.0 | | * | * | * + + +## Documentation + +### Installation + +To install pinax-testimonials: + + pip install pinax-testimonials + +Add `pinax-testimonials` to your `INSTALLED_APPS` setting: + + INSTALLED_APPS = ( + ... + "pinax.testimonials", + ... + ) + +### Usage + +In your template where you want to display testimonials there are three ways you +can use template tags to add active testimonials to your page. + +First, load the template tags: + + {% load pinax_testimonials_tags %} + +For random testimonials: + + {% random_testimonials as quotes %} + +For testimonials ordered by the date they were added: + + {% testimonials as quotes %} + +For show all testimonials by ordered the date:, just remove number parameter, like this: + + {% testimonials as quotes %} + +If you just want a single random testimonial you can use: + + {% random_testimonial as quote %} + +And there is an example that how you can show the testimonials, you can do something like this: + + {% testimonials as quotes %} + {% for quote in quotes %} +

+ {{quote.text}} + {{quote.author}} +

+ {% endfor %} -See [this blog post](http://blog.pinaxproject.com/2016/02/26/recap-february-pinax-hangout/) including a video, or our [How to Contribute](http://pinaxproject.com/pinax/how_to_contribute/) section for an overview on how contributing to Pinax works. For concrete contribution ideas, please see our [Ways to Contribute/What We Need Help With](http://pinaxproject.com/pinax/ways_to_contribute/) section. +Add and manage testimonial quotes via the Django admin. -In case of any questions we recommend you [join our Pinax Slack team](http://slack.pinaxproject.com) and ping us there instead of creating an issue on GitHub. Creating issues on GitHub is of course also valid but we are usually able to help you faster if you ping us in Slack. -We also highly recommend reading our [Open Source and Self-Care blog post](http://blog.pinaxproject.com/2016/01/19/open-source-and-self-care/). +## Change Log +### 2.0.1 + +* Standardize documentation layout +* Drop Django v1.8, v1.10 support + +### 2.0.0 + +* Add Django 2.0 compatibility testing +* Drop Django 1.9 and Python 3.3 support +* Convert CI and coverage to CircleCi and CodeCov +* Add PyPi-compatible long description +* Move documentation to README.md + +### 1.0.5 + +* Update this change log + +### 1.0.4 + +* Documentation updates + +### 1.0.3 + +* Rename templatetags file to match Pinax convention +* Add tests +* Add initial migration +* Update documentation + +### 1.0 + +* Updated template tags to use `assignment_tags` +* Added bulk operations to admin to mark testimonials as active/inactive +* Renamed from `marturian` to `pinax-testimonials` during the donation from Eldarion to Pinax + +### 0.2 + +* Fixed documenation bug +* Added a template tag for fetching a single random quote + +### 0.1.4 + +* Fixed bug introduction with last bug fix. + +### 0.1.3 + +* Fix bug where the random query select would make it hard to use queryset in a template using index accessors. + +### 0.1.2 + +* Fixed a typo in the model name + +### 0.1 + +* initial release + + +## Contribute + +For an overview on how contributing to Pinax works read this [blog post](http://blog.pinaxproject.com/2016/02/26/recap-february-pinax-hangout/) +and watch the included video, or read our [How to Contribute](http://pinaxproject.com/pinax/how_to_contribute/) section. +For concrete contribution ideas, please see our +[Ways to Contribute/What We Need Help With](http://pinaxproject.com/pinax/ways_to_contribute/) section. + +In case of any questions we recommend you join our [Pinax Slack team](http://slack.pinaxproject.com) +and ping us there instead of creating an issue on GitHub. Creating issues on GitHub is of course +also valid but we are usually able to help you faster if you ping us in Slack. + +We also highly recommend reading our blog post on [Open Source and Self-Care](http://blog.pinaxproject.com/2016/01/19/open-source-and-self-care/). ## Code of Conduct -In order to foster a kind, inclusive, and harassment-free community, the Pinax Project has a code of conduct, which can be found here http://pinaxproject.com/pinax/code_of_conduct/. We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you. +In order to foster a kind, inclusive, and harassment-free community, the Pinax Project +has a [code of conduct](http://pinaxproject.com/pinax/code_of_conduct/). +We ask you to treat everyone as a smart human programmer that shares an interest in Python, Django, and Pinax with you. + + +## Connect with Pinax + +For updates and news regarding the Pinax Project, please follow us on Twitter [@pinaxproject](https://twitter.com/pinaxproject) +and check out our [Pinax Project blog](http://blog.pinaxproject.com). -## Pinax Project Blog and Twitter +## License -For updates and news regarding the Pinax Project, please follow us on Twitter at @pinaxproject and check out our blog http://blog.pinaxproject.com. +Copyright (c) 2012-2018 James Tauber and contributors under the [MIT license](https://opensource.org/licenses/MIT). \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md deleted file mode 100644 index dc7d04d..0000000 --- a/docs/changelog.md +++ /dev/null @@ -1,45 +0,0 @@ -# Change Log - -## 1.0.5 - -* Update this change log - -## 1.0.4 - -* Documentation updates - -## 1.0.3 - -* Rename templatetags file to match Pinax convention -* Add tests -* Add initial migration -* Update documentation - -## 1.0 - -* Updated template tags to use `assignment_tags` -* Added bulk operations to admin to mark testimonials as active/inactive -* Renamed from `marturian` to `pinax-testimonials` during the donation from Eldarion to Pinax - -## 0.2 - -* Fixed documenation bug -* Added a template tag for fetching a single random quote - -## 0.1.4 - -* Fixed bug introduction with last bug fix. - -## 0.1.3 - -* Fix bug where the random query select would make it hard to use queryset in a template using index accessors. - - -## 0.1.2 - -* Fixed a typo in the model name - - -## 0.1 - -* initial release diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 2bd4434..0000000 --- a/docs/index.md +++ /dev/null @@ -1,65 +0,0 @@ -# pinax-testimonials - - -!!! note "Pinax Ecosystem" - This app is part of the Pinax ecosystem and is designed for use - both with and independently of other Pinax apps. - - To learn more about Pinax, see - - -## Quickstart - -To install pinax-testimonials: - - pip install pinax-testimonials - -Add `pinax-testimonials` to your `INSTALLED_APPS` setting: - - INSTALLED_APPS = ( - ... - "pinax.testimonials", - ... - ) - -## Usage - -In your template where you want to display testimonials there are three ways you -can use template tags to add active testimonials to your page. - -First, load the template tags: - - {% load pinax_testimonials_tags %} - -For random testimonials: - - {% random_testimonials as quotes %} - - -For testimonials ordered by the date they were added: - - {% testimonials as quotes %} - -For show all testimonials by ordered the date:, just remove number parameter, like this: - - {% testimonials as quotes %} - -If you just want a single random testimonial you can use: - - {% random_testimonial as quote %} - -And there is an example that how you can show the testimonials, you can do something like this: - - {% testimonials as quotes %} - {% for quote in quotes %} -

- {{quote.text}} - {{quote.author}} -

- {% endfor %} - -Add and manage testimonial quotes via the Django admin. - -## Changelog - -See [Changelog](./changelog.md). diff --git a/pinax/testimonials/admin.py b/pinax/testimonials/admin.py index 46e9385..8910fd3 100644 --- a/pinax/testimonials/admin.py +++ b/pinax/testimonials/admin.py @@ -5,11 +5,15 @@ def make_active(modeladmin, request, queryset): queryset.update(active=True) + + make_active.short_description = "Mark as Active" def make_inactive(modeladmin, request, queryset): queryset.update(active=False) + + make_inactive.short_description = "Mark as Inactive" diff --git a/pinax/testimonials/templatetags/pinax_testimonials_tags.py b/pinax/testimonials/templatetags/pinax_testimonials_tags.py index d87881a..913848d 100644 --- a/pinax/testimonials/templatetags/pinax_testimonials_tags.py +++ b/pinax/testimonials/templatetags/pinax_testimonials_tags.py @@ -2,21 +2,20 @@ from ..models import Testimonial - register = template.Library() -@register.assignment_tag +@register.simple_tag def random_testimonials(number): return Testimonial.objects.filter(active=True).order_by("?")[:number] -@register.assignment_tag +@register.simple_tag def random_testimonial(): queryset = Testimonial.objects.filter(active=True).order_by("?") return queryset[0] if queryset else None -@register.assignment_tag +@register.simple_tag def testimonials(number): return Testimonial.objects.filter(active=True).order_by("-added")[:number] diff --git a/pinax/testimonials/tests/models.py b/pinax/testimonials/tests/models.py deleted file mode 100644 index e69de29..0000000 diff --git a/pinax/testimonials/tests/tests.py b/pinax/testimonials/tests/tests.py index e8f0857..8c894f4 100644 --- a/pinax/testimonials/tests/tests.py +++ b/pinax/testimonials/tests/tests.py @@ -1,11 +1,12 @@ from django.test import TestCase from ..models import Testimonial -from ..templatetags.pinax_testimonials_tags import ( - random_testimonials as random_testimonials_tag, - random_testimonial as random_testimonial_tag, - testimonials as testimonials_tag, -) +from ..templatetags.pinax_testimonials_tags import \ + random_testimonial as random_testimonial_tag +from ..templatetags.pinax_testimonials_tags import \ + random_testimonials as random_testimonials_tag +from ..templatetags.pinax_testimonials_tags import \ + testimonials as testimonials_tag class TestTags(TestCase): diff --git a/pinax/testimonials/tests/urls.py b/pinax/testimonials/tests/urls.py deleted file mode 100644 index f495fc0..0000000 --- a/pinax/testimonials/tests/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -try: - from django.conf.urls import patterns, include -except ImportError: - from django.conf.urls.defaults import patterns, include - - -urlpatterns = patterns( - "", - (r"^", include("pinax.testimonials.urls")), -) diff --git a/runtests.py b/runtests.py index bcaf87d..80d30c4 100644 --- a/runtests.py +++ b/runtests.py @@ -22,8 +22,6 @@ } }, SITE_ID=1, - MIDDLEWARE_CLASSES=[], - ROOT_URLCONF="testimonials.tests.urls", SECRET_KEY="notasecret", ) diff --git a/setup.py b/setup.py index a5cb49d..0a95088 100644 --- a/setup.py +++ b/setup.py @@ -1,51 +1,88 @@ -import codecs - -from os import path from setuptools import find_packages, setup +LONG_DESCRIPTION = """ +.. image:: http://pinaxproject.com/pinax-design/patches/blank.svg + :target: https://pypi.python.org/pypi/pinax-testimonials/ + +================= +Pinax Testimonials +================= + +.. image:: https://img.shields.io/pypi/v/pinax-testimonials.svg + :target: https://pypi.python.org/pypi/pinax-testimonials/ +.. image:: https://img.shields.io/badge/license-MIT-blue.svg + :target: https://pypi.python.org/pypi/pinax-testimonials/ + +.. image:: https://img.shields.io/circleci/project/github/pinax/pinax-testimonials.svg + :target: https://circleci.com/gh/pinax/pinax-testimonials +.. image:: https://img.shields.io/codecov/c/github/pinax/pinax-testimonials.svg + :target: https://codecov.io/gh/pinax/pinax-testimonials +.. image:: https://img.shields.io/github/contributors/pinax/pinax-testimonials.svg + :target: https://github.com/pinax/pinax-testimonials/graphs/contributors +.. image:: https://img.shields.io/github/issues-pr/pinax/pinax-testimonials.svg + :target: https://github.com/pinax/pinax-testimonials/pulls +.. image:: https://img.shields.io/github/issues-pr-closed/pinax/pinax-testimonials.svg + :target: https://github.com/pinax/pinax-testimonials/pulls?q=is%3Apr+is%3Aclosed -def read(*parts): - filename = path.join(path.dirname(__file__), *parts) - with codecs.open(filename, encoding="utf-8") as fp: - return fp.read() +.. image:: http://slack.pinaxproject.com/badge.svg + :target: http://slack.pinaxproject.com/ + +``pinax-testimonials`` is a well tested, documented, and proven solution for any site wanting to display testimonials. -try: - from pypandoc import convert - read_md = lambda f: convert(f, "rst").replace("\r","") -except (ImportError, IOError): - print("warning: pypandoc module not found, could not convert Markdown to RST") - read_md = lambda f: read(f) +Supported Django and Python Versions +------------------------------------ ++-----------------+-----+-----+-----+-----+ +| Django \ Python | 2.7 | 3.4 | 3.5 | 3.6 | ++=================+=====+=====+=====+=====+ +| 1.11 | * | * | * | * | ++-----------------+-----+-----+-----+-----+ +| 2.0 | | * | * | * | ++-----------------+-----+-----+-----+-----+ +""" setup( author="Pinax Team", - author_email="developers@pinaxproject.com", + author_email="team@pinaxproject.com", description="a testimonials app", name="pinax-testimonials", - long_description=read_md("README.md"), - version="1.0.5", - url="http://pinax-testimonials.rtfd.org/", + long_description=LONG_DESCRIPTION, + version="2.0.1", + url="http://github.com/pinax/pinax-testimonials/", license="MIT", packages=find_packages(), package_data={ "testimonials": [] }, - install_requires=[ - ], test_suite="runtests.runtests", tests_require=[ + "dj-inmemorystorage>=1.4.0", + "django-appconf>=1.0.1", + "django-test-plus>=1.0.11", + "mock>=1.3.0", + "django-user-accounts>=1.3.1", + "pinax-theme-bootstrap>=7.6.0", + ], + install_requires=[ + "django-appconf>=1.0.1" ], classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", + 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.0', "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', "Topic :: Software Development :: Libraries :: Python Modules", ], - zip_safe=False + zip_safe=False, ) diff --git a/tox.ini b/tox.ini index d7e6828..83d31ad 100644 --- a/tox.ini +++ b/tox.ini @@ -2,27 +2,55 @@ ignore = E265,E501 max-line-length = 100 max-complexity = 10 -exclude = migrations/*,docs/* +exclude = pinax/testimonials/migrations/* +inline-quotes = double + +[isort] +multi_line_output=3 +known_django=django +known_third_party=pinax +sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER +skip_glob=*/pinax/testimonials/migrations/* + +[coverage:run] +source = pinax +omit = pinax/testimonials/conf.py,pinax/testimonials/tests/*,pinax/testimonials/migrations/* +branch = true +data_file = .coverage + +[coverage:report] +omit = pinax/testimonials/conf.py,pinax/testimonials/tests/*,pinax/testimonials/migrations/* +exclude_lines = + coverage: omit +show_missing = True [tox] envlist = - py27-{1.8,1.9,master}, - py33-{1.8}, - py34-{1.8,1.9,master}, - py35-{1.8,1.9,master} + checkqa, + py27-dj{111} + py34-dj{111,20} + py35-dj{111,20} + py36-dj{111,20} [testenv] +passenv = CI CIRCLECI CIRCLE_* deps = - coverage==4.0.2 - flake8==2.5.0 - 1.8: Django>=1.8,<1.9 - 1.9: Django>=1.9,<1.10 + coverage + codecov + dj111: Django>=1.11,<1.12 + dj20: Django<2.1 master: https://github.com/django/django/tarball/master + usedevelop = True -setenv = - LANG=en_US.UTF-8 - LANGUAGE=en_US:en - LC_ALL=en_US.UTF-8 commands = - flake8 pinax coverage run setup.py test + coverage report -m --skip-covered + +[testenv:checkqa] +commands = + flake8 pinax + isort --recursive --check-only --diff pinax -sp tox.ini +deps = + flake8 == 3.4.1 + flake8-quotes == 0.11.0 + isort == 4.2.15