Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb authored Aug 9, 2022
2 parents f31a9ae + 114a154 commit bc05f97
Show file tree
Hide file tree
Showing 49 changed files with 1,084 additions and 618 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
push:
tags:
- '*'

jobs:
build:
if: github.repository == 'jazzband/django-avatar'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
- name: Build package
run: |
python setup.py --version
python setup.py sdist --format=gztar bdist_wheel
twine check dist/*
- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: jazzband
password: ${{ secrets.JAZZBAND_RELEASE_KEY }}
repository_url: https://jazzband.co/projects/django-avatar/upload
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test
on: [push, pull_request]
jobs:
Build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: 3.6
django-version: 3.2
- python-version: 3.7
django-version: 3.2
- python-version: 3.8
django-version: 3.2
- python-version: 3.9
django-version: 3.2
- python-version: '3.10'
django-version: 3.2
- python-version: 3.8
django-version: 4.0
- python-version: 3.9
django-version: 4.0
- python-version: '3.10'
django-version: 4.0
- python-version: 3.8
django-version: 4.1
- python-version: 3.9
django-version: 4.1
- python-version: '3.10'
django-version: 4.1
steps:
- uses: actions/checkout@v3
- name: 'Set up Python ${{ matrix.python-version }}'
uses: actions/setup-python@v3
with:
python-version: '${{ matrix.python-version }}'
cache: 'pip'
- name: Install dependencies
run: |
pip install -e .
pip install -r tests/requirements.txt
pip install "Django~=${{ matrix.django-version }}.0" .
- name: Run Tests
run: |
echo "$(python --version) / Django $(django-admin --version)"
export DJANGO_SETTINGS_MODULE=tests.settings
export PYTHONPATH=.
coverage run --source=avatar `which django-admin` test tests
coverage report
coverage xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs/_build
htmlcov/
*.sqlite3
test_proj/media
.python-version
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: "5.10.1"
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
args: [--target-version=py310]

- repo: https://github.com/pycqa/flake8
rev: '5.0.4'
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-tidy-imports
- flake8-print
args: [--max-line-length=120]
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
=========

* 5.0.0 (January 4, 2019)
* Added Django 2.1, 2.2, and 3.0 support.
* Added Python 3.7 and 3.8 support.
* Removed Python 1.9 and 1.10 support.
* Fixed bug where avatars couldn't be deleted if file was already deleted.

* 4.1.0 (December 20, 2017)
* Added Django 2.0 support.
* Added ``avatar_deleted`` signal.
* Ensure thumbnails are the correct orientation.

* 4.0.0 (May 27, 2017)
* **Backwards incompatible:** Added ``AVATAR_PROVIDERS`` setting. Avatar providers are classes that return an avatar URL for a given user.
* Added ``verbose_name`` to ``Avatar`` model fields.
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[![Jazzband](https://jazzband.co/static/img/jazzband.svg)](https://jazzband.co/)

This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines).
3 changes: 1 addition & 2 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
This application was originally written by Eric Florenzano.
It is now maintained by Grant McConnaughey and a league of awesome contributors.

See the full list here: https://github.com/grantmcconnaughey/django-avatar/graphs/contributors
See the full list here: https://github.com/jazzband/django-avatar/graphs/contributors
1 change: 0 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

18 changes: 0 additions & 18 deletions Makefile

This file was deleted.

30 changes: 18 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
django-avatar
=============

.. image:: https://jazzband.co/static/img/badge.png
:target: https://jazzband.co/
:alt: Jazzband

.. image:: https://img.shields.io/pypi/pyversions/django-avatar.svg
:target: https://pypi.org/project/django-avatar/
:alt: Supported Python versions

.. image:: https://img.shields.io/pypi/djversions/django-avatar.svg
:target: https://pypi.org/project/django-avatar/
:alt: Supported Django versions

.. image:: https://github.com/jazzband/django-avatar/actions/workflows/test.yml/badge.svg
:target: https://github.com/jazzband/django-avatar/actions/workflows/test.yml

.. image:: https://codecov.io/gh/jazzband/django-avatar/branch/main/graph/badge.svg?token=BO1e4kkgtq
:target: https://codecov.io/gh/jazzband/django-avatar

.. image:: https://badge.fury.io/py/django-avatar.svg
:target: https://badge.fury.io/py/django-avatar
:alt: PyPI badge
Expand All @@ -10,18 +28,6 @@ django-avatar
:target: http://django-avatar.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://travis-ci.org/grantmcconnaughey/django-avatar.svg?branch=master
:target: https://travis-ci.org/grantmcconnaughey/django-avatar
:alt: Travis CI Build Status

.. image:: https://coveralls.io/repos/grantmcconnaughey/django-avatar/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/grantmcconnaughey/django-avatar?branch=master
:alt: Coverage

.. image:: https://lintly.com/gh/grantmcconnaughey/django-avatar/badge.svg
:target: https://lintly.com/gh/grantmcconnaughey/django-avatar/
:alt: Lintly

Django-avatar is a reusable application for handling user avatars. It has the
ability to default to Gravatar if no avatar is found for a certain user.
Django-avatar automatically generates thumbnails and stores them to your default
Expand Down
2 changes: 1 addition & 1 deletion avatar/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '4.0.0'
__version__ = "5.0.0"
31 changes: 17 additions & 14 deletions avatar/admin.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils import six
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _

from avatar.models import Avatar
from avatar.signals import avatar_updated
from avatar.utils import get_user_model


class AvatarAdmin(admin.ModelAdmin):
list_display = ('get_avatar', 'user', 'primary', "date_uploaded")
list_filter = ('primary',)
search_fields = ('user__%s' % getattr(get_user_model(), 'USERNAME_FIELD', 'username'),)
list_display = ("get_avatar", "user", "primary", "date_uploaded")
list_filter = ("primary",)
search_fields = (
"user__%s" % getattr(get_user_model(), "USERNAME_FIELD", "username"),
)
list_per_page = 50

def get_avatar(self, avatar_in):
context = dict({
'user': avatar_in.user,
'url': avatar_in.avatar.url,
'alt': six.text_type(avatar_in.user),
'size': 80,
})
return render_to_string('avatar/avatar_tag.html', context)

get_avatar.short_description = _('Avatar')
context = dict(
{
"user": avatar_in.user,
"url": avatar_in.avatar.url,
"alt": str(avatar_in.user),
"size": 80,
}
)
return render_to_string("avatar/avatar_tag.html", context)

get_avatar.short_description = _("Avatar")
get_avatar.allow_tags = True

def save_model(self, request, obj, form, change):
Expand Down
6 changes: 6 additions & 0 deletions avatar/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class Config(AppConfig):
name = "avatar"
default_auto_field = "django.db.models.AutoField"
32 changes: 16 additions & 16 deletions avatar/conf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from appconf import AppConf
from django.conf import settings
from PIL import Image

from appconf import AppConf


class AvatarConf(AppConf):
DEFAULT_SIZE = 80
RESIZE_METHOD = Image.ANTIALIAS
STORAGE_DIR = 'avatars'
PATH_HANDLER = 'avatar.models.avatar_path_handler'
GRAVATAR_BASE_URL = 'https://www.gravatar.com/avatar/'
GRAVATAR_FIELD = 'email'
STORAGE_DIR = "avatars"
PATH_HANDLER = "avatar.models.avatar_path_handler"
GRAVATAR_BASE_URL = "https://www.gravatar.com/avatar/"
GRAVATAR_FIELD = "email"
GRAVATAR_DEFAULT = None
AVATAR_GRAVATAR_FORCEDEFAULT = False
DEFAULT_URL = 'avatar/img/default.jpg'
DEFAULT_URL = "avatar/img/default.jpg"
MAX_AVATARS_PER_USER = 42
MAX_SIZE = 1024 * 1024
THUMB_FORMAT = 'JPEG'
THUMB_FORMAT = "JPEG"
THUMB_QUALITY = 85
HASH_FILENAMES = False
HASH_USERDIRNAMES = False
Expand All @@ -29,15 +28,16 @@ class AvatarConf(AppConf):
FACEBOOK_GET_ID = None
CACHE_ENABLED = True
RANDOMIZE_HASHES = False
ADD_TEMPLATE = ''
CHANGE_TEMPLATE = ''
DELETE_TEMPLATE = ''
ADD_TEMPLATE = ""
CHANGE_TEMPLATE = ""
DELETE_TEMPLATE = ""
PROVIDERS = (
'avatar.providers.PrimaryAvatarProvider',
'avatar.providers.GravatarAvatarProvider',
'avatar.providers.DefaultAvatarProvider',
"avatar.providers.PrimaryAvatarProvider",
"avatar.providers.GravatarAvatarProvider",
"avatar.providers.DefaultAvatarProvider",
)

def configure_auto_generate_avatar_sizes(self, value):
return value or getattr(settings, 'AVATAR_AUTO_GENERATE_SIZES',
(self.DEFAULT_SIZE,))
return value or getattr(
settings, "AVATAR_AUTO_GENERATE_SIZES", (self.DEFAULT_SIZE,)
)
Loading

0 comments on commit bc05f97

Please sign in to comment.