Skip to content

Commit

Permalink
Merge branch 'master' into feature/retromigrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko Bernardini committed Feb 7, 2022
2 parents 0c8b966 + aafd92c commit d2a1d96
Show file tree
Hide file tree
Showing 50 changed files with 849 additions and 482 deletions.
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 160
exclude =
# There's no value in checking cache directories
__pycache__,
# The miration files are mostly autogenerated, ignore it
camomilla/migrations,

per-file-ignores =
# imported but unused
__init__.py: F401,F403
camomilla/fields.py: F811,C901
max-complexity = 12
27 changes: 27 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
workflow_run:
workflows: [ "Test and Coverage" ]
branches: [ release ]
types:
- completed

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
concurrency: release
name: Release to PYPI 🚀

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

- name: Python Semantic Release
uses: relekang/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repository_username: __token__
repository_password: ${{ secrets.PYPI_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test and Coverage

on:
push:
branches: [ master, release ]
pull_request:
branches: [ master, release ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
max-parallel: 4
matrix:
include:
# Django 2.2
- python-version: "3.6"
django-version: "2.2"
- python-version: "3.7"
django-version: "2.2"
- python-version: "3.8"
django-version: "2.2"
- python-version: "3.9"
django-version: "2.2"
- python-version: "3.10"
django-version: "2.2"
# Django 3.2
# - 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"
name: Test on Python ${{ matrix.python-version }} with Django ${{ matrix.django-version }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }} 🐍
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies 📦
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install Django==${{ matrix.django-version }}
- name: Test with pytest and calculate coverage 🧪
run: |
make test
- name: Upload coverage
uses: codecov/codecov-action@v2
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Changelog

<!--next-version-placeholder-->

## v5.4.2 (2022-01-18)
### Fix
* Fix versioning ([`39b5226`](https://github.com/lotrekagency/camomilla/commit/39b522637ff79c7ff05237d1ad85e1cae26d2a94))
* Added min max range to requirements ([`6841054`](https://github.com/lotrekagency/camomilla/commit/6841054d71c0704919b446eb8ed542d3fb08a873))

## v5.4.1 (2022-01-17)
### Fix
* Loosen the range of requirements package versions ([`96d491b`](https://github.com/lotrekagency/camomilla/commit/96d491b4ff0aba269624eb7a27b1f3cd55946721))

## v5.4.0 (2022-01-13)
### Feature
* **media:** Added mime_type column to media model ([`4771068`](https://github.com/lotrekagency/camomilla/commit/4771068d2e54779a3d6e38ee9b447fb04c73539c))
* **api:** Added search to medias ([`905661d`](https://github.com/lotrekagency/camomilla/commit/905661d874b5ff2e22ea8b508c46d1ccfc70c0e7))
* **media:** Added option to override Media file on update from api to maintain same url ([`8d6371f`](https://github.com/lotrekagency/camomilla/commit/8d6371ff94e460f2e84efde45882d7d192b7cce6))

### Fix
* **media:** Added opetation to db migration to recalc old media with the new mime_type feature ([`a7afd2d`](https://github.com/lotrekagency/camomilla/commit/a7afd2d53ba2b2f27d0d06fb6dba131368fdcc6e))
* **media:** Mime filter parsing works also in folder viewset ([`4149e92`](https://github.com/lotrekagency/camomilla/commit/4149e92e6c67e5f96219f02859a3aaa3f748553d))

## v5.3.0 (2021-12-17)
### Feature
* **api:** Handle multisort on PaginateStackMixin ([`40080f4`](https://github.com/lotrekagency/camomilla/commit/40080f4542c8e0dd4c8b36bb5cf5de6e078c3314))

## v5.2.0 (2021-12-17)


## v5.1.0 (2021-12-17)
### Feature
* Added image properties into media model ([`09cb481`](https://github.com/lotrekagency/camomilla/commit/09cb4818b2e3207eab7a12361f5e273b17edd1d0))
* Option to remove pagination on views ([`3e6fc48`](https://github.com/lotrekagency/camomilla/commit/3e6fc489db8b01f488ffebedd93f614c01d9e8d3))

### Fix
* Fix sqlite compatibility problems ([`4cde4fc`](https://github.com/lotrekagency/camomilla/commit/4cde4fc6c5f0e0b0d76e2020943de6d0bc973a49))
* Fix app name ([`13bb12d`](https://github.com/lotrekagency/camomilla/commit/13bb12d75bc9072a9ff150a7b408157f022c9299))
* Added search field to article viewset ([`1bd4b5f`](https://github.com/lotrekagency/camomilla/commit/1bd4b5f0681885b19bb2043d7622c8b3e77b9689))
* Fix articles and pages serializers requiring RelatedField fields. ([`c4fd330`](https://github.com/lotrekagency/camomilla/commit/c4fd330fb06dc3d49de4100865376a9eedb3f6f6))

## v5.0.3 (2021-10-26)


## v5.0.2 (2021-10-26)

22 changes: 21 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
All right reserved - Lotrèk 2018 - 2019
MIT License

Copyright (c) 2021 Lotrèk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ clean:
@find . -name "__pycache__" -type d | xargs rm -rf

test: clean
@pytest --cov=camomilla -s --cov-report term-missing
@flake8 camomilla
@pytest --cov=camomilla -s --cov-report=xml --cov-report=term-missing

docs: clean
@sphinx-build -b html ./docs camomilla_docs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Camomilla 5.0 alpha
# camomilla cms [![PyPI](https://img.shields.io/pypi/v/django-camomilla-cms?style=flat-square)](https://pypi.org/project/django-camomilla-cms) ![Codecov](https://img.shields.io/codecov/c/github/lotrekagency/camomilla?style=flat-square) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lotrekagency/camomilla/Test,%20Coverage%20and%20Release?style=flat-square) [![GitHub](https://img.shields.io/github/license/lotrekagency/camomilla?style=flat-square)](./LICENSE)

## Install

Expand Down
8 changes: 3 additions & 5 deletions camomilla/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
__version__ = "5.4.2"


def get_core_apps():
return [
'rest_framework',
'rest_framework.authtoken',
'hvad'
]
return ["rest_framework", "rest_framework.authtoken", "hvad"]
42 changes: 26 additions & 16 deletions camomilla/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin

from django.contrib.admin.sites import AlreadyRegistered
from django import forms
from django.http import HttpResponse

Expand All @@ -23,13 +20,14 @@ class UserProfileAdmin(admin.ModelAdmin):

class ArticleAdminForm(TranslatableModelForm):
content = forms.CharField(widget=CKEditorUploadingWidget())

class Meta:
model = Article
exclude = ('slug',)
exclude = ("slug",)


class ArticleAdmin(TranslatableAdmin):
filter_horizontal = ('tags', 'categories')
filter_horizontal = ("tags", "categories")
form = ArticleAdminForm


Expand All @@ -40,12 +38,15 @@ class TagAdmin(TranslatableAdmin):
class CategoryAdmin(TranslatableAdmin):
pass


class MediaFolderAdmin(TranslatableAdmin):
pass


class ContentAdminForm(TranslatableModelForm):
exclude = ('permalink',)
exclude = ("permalink",)
content = forms.CharField(widget=CKEditorUploadingWidget())

class Meta:
model = Content

Expand All @@ -55,23 +56,33 @@ class ContentAdmin(TranslatableAdmin):


class MediaAdmin(TranslatableAdmin):
exclude = ('thumbnail', 'size', 'is_image')
readonly_fields = ('image_preview', 'image_thumb_preview')
list_display = ('__str__', 'name', 'image_thumb_preview',)
exclude = (
"thumbnail",
"size",
"image_props",
)
readonly_fields = ("image_preview", "image_thumb_preview")
list_display = (
"__str__",
"name",
"image_thumb_preview",
)

def response_add(self, request, obj):
if request.GET.get('_popup', ''):
return HttpResponse('''
if request.GET.get("_popup", ""):
return HttpResponse(
"""
<script type="text/javascript">
opener.dismissAddRelatedObjectPopup(window, %s, '%s');
</script>''' % (obj.id, obj.json_repr)
</script>"""
% (obj.id, obj.json_repr)
)
else:
return super(MediaAdmin, self).response_add(request, obj)


class PageAdmin(TranslatableAdmin):
exclude = ('permalink',)
exclude = ("permalink",)


admin.site.register(Article, ArticleAdmin)
Expand All @@ -82,7 +93,6 @@ class PageAdmin(TranslatableAdmin):
admin.site.register(Media, MediaAdmin)
admin.site.register(Page, PageAdmin)

admin.site.index_title = '{0} {1}'.format(
_('Administration panel for'),
getattr(settings, 'PROJECT_TITLE', 'Camomilla')
admin.site.index_title = "{0} {1}".format(
_("Administration panel for"), getattr(settings, "PROJECT_TITLE", "Camomilla")
)
4 changes: 2 additions & 2 deletions camomilla/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
name = 'api'
class CamomillaConfig(AppConfig):
name = "camomilla"
44 changes: 20 additions & 24 deletions camomilla/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_ROOT = os.path.join(BASE_DIR, "static")

STATICFILES_DIRS = []
if os.path.exists(os.path.join(BASE_DIR, 'build')):
STATICFILES_DIRS.append(os.path.join(BASE_DIR, 'build'))
if os.path.exists(os.path.join(BASE_DIR, 'public')):
STATICFILES_DIRS.append(os.path.join(BASE_DIR, 'public'))
if os.path.exists(os.path.join(BASE_DIR, "build")):
STATICFILES_DIRS.append(os.path.join(BASE_DIR, "build"))
if os.path.exists(os.path.join(BASE_DIR, "public")):
STATICFILES_DIRS.append(os.path.join(BASE_DIR, "public"))

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"

THUMB_FOLDER = 'thumbnails'
THUMB_FOLDER = "thumbnails"

REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser',
"DEFAULT_PARSER_CLASSES": (
"rest_framework.parsers.JSONParser",
"rest_framework.parsers.FormParser",
"rest_framework.parsers.MultiPartParser",
),
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.TokenAuthentication"
"rest_framework.authentication.SessionAuthentication"
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication'
'rest_framework.authentication.SessionAuthentication'
)
}

ADMIN_SITE_HEADER = _("Camomilla advanced panel")
Expand All @@ -35,13 +35,9 @@
CAMOMILLA_THUMBNAIL_HEIGHT = 50


PNG_OPTIMIZATION_COMMAND = "pngquant {0} -f --ext .png"
JPEG_OPTIMIZATION_COMMAND = "jpegoptim {0}"

PNG_OPTIMIZATION_COMMAND = 'pngquant {0} -f --ext .png'
JPEG_OPTIMIZATION_COMMAND = 'jpegoptim {0}'

LANG_ON_PREFERENCE_DISABLED_VIEWS = ['sitemap', 'sitemap_xml']

HVAD = {
'AUTOLOAD_TRANSLATIONS' : True
}
LANG_ON_PREFERENCE_DISABLED_VIEWS = ["sitemap", "sitemap_xml"]

HVAD = {"AUTOLOAD_TRANSLATIONS": True}
Loading

0 comments on commit d2a1d96

Please sign in to comment.