From c521dfb622d4d5d4861c43c5fa931c6f2721dee5 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Tue, 8 Oct 2024 21:04:30 -0700 Subject: [PATCH] initial commit --- .github/workflows/style.yml | 108 ++++++++++++++++++ .github/workflows/tests.yml | 36 ++++++ .gitignore | 63 ++++++++++ .gitlab-ci.yml | 42 +++++++ .install-hooks.sh | 16 +++ .update-locales.sh | 37 ++++++ LICENSE | 15 +++ MANIFEST.in | 5 + Makefile | 10 ++ README.rst | 53 +++++++++ pretix_email_template_plugin/__init__.py | 1 + pretix_email_template_plugin/apps.py | 26 +++++ .../locale/de/LC_MESSAGES/django.po | 12 ++ .../locale/de_Informal/.gitkeep | 0 .../locale/de_Informal/LC_MESSAGES/django.po | 12 ++ pretix_email_template_plugin/signals.py | 1 + .../pretix_email_template_plugin/.gitkeep | 0 .../pretix_email_template_plugin/.gitkeep | 0 pretixplugin.toml | 5 + pyproject.toml | 42 +++++++ setup.cfg | 44 +++++++ setup.py | 4 + tests/conftest.py | 1 + tests/test_main.py | 3 + 24 files changed, 536 insertions(+) create mode 100644 .github/workflows/style.yml create mode 100644 .github/workflows/tests.yml create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100755 .install-hooks.sh create mode 100755 .update-locales.sh create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst create mode 100644 pretix_email_template_plugin/__init__.py create mode 100644 pretix_email_template_plugin/apps.py create mode 100644 pretix_email_template_plugin/locale/de/LC_MESSAGES/django.po create mode 100644 pretix_email_template_plugin/locale/de_Informal/.gitkeep create mode 100644 pretix_email_template_plugin/locale/de_Informal/LC_MESSAGES/django.po create mode 100644 pretix_email_template_plugin/signals.py create mode 100644 pretix_email_template_plugin/static/pretix_email_template_plugin/.gitkeep create mode 100644 pretix_email_template_plugin/templates/pretix_email_template_plugin/.gitkeep create mode 100644 pretixplugin.toml create mode 100644 pyproject.toml create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/conftest.py create mode 100644 tests/test_main.py diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000..3d0d38c --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,108 @@ +name: Code Style + +on: + push: + branches: [ main, master ] + paths-ignore: + - 'pretix_email_template_plugin/locale/**' + - 'pretix_email_template_plugin/static/**' + pull_request: + branches: [ main, master ] + paths-ignore: + - 'pretix_email_template_plugin/locale/**' + - 'pretix_email_template_plugin/static/**' + +jobs: + isort: + name: isort + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretix + run: pip3 install pretix + - name: Install Dependencies + run: pip3 install isort -Ue . + - name: Run isort + run: isort -c . + flake: + name: flake8 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretix + run: pip3 install pretix + - name: Install Dependencies + run: pip3 install flake8 -Ue . + - name: Run flake8 + run: flake8 . + working-directory: . + black: + name: black + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretix + run: pip3 install pretix + - name: Install Dependencies + run: pip3 install black -Ue . + - name: Run black + run: black --check . + working-directory: . + packaging: + name: packaging + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretix + run: pip3 install pretix + - name: Install Dependencies + run: pip3 install twine check-manifest pretix-plugin-build setuptools build -Ue . + - name: Run check-manifest + run: check-manifest . + working-directory: . + - name: Build package + run: python setup.py sdist + working-directory: . + - name: Check package + run: twine check dist/* + working-directory: . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2b5b59e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: + push: + branches: [ main, master ] + paths-ignore: + - 'pretix_email_template_plugin/locale/**' + pull_request: + branches: [ main, master ] + paths-ignore: + - 'pretix_email_template_plugin/locale/**' + +jobs: + test: + runs-on: ubuntu-latest + name: Tests + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.11 + uses: actions/setup-python@v1 + with: + python-version: 3.11 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install system dependencies + run: sudo apt update && sudo apt install gettext + - name: Install pretix + run: pip3 install pretix + - name: Install Dependencies + run: pip3 install pytest pytest-django -Ue . + - name: Run checks + run: py.test tests diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f6b8f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,63 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +.ropeproject/ + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo + +# Django stuff: +*.log +data/ + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a953868 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,42 @@ +test: + image: + name: pretix/ci-image + before_script: + - pip install -U pip uv + - uv pip install --system -U wheel setuptools pytest pytest-django coverage + - uv pip install --system -U git+https://github.com/pretix/pretix.git@master#egg=pretix + script: + - uv pip install --system -e . + - make + - coverage run -m pytest tests + - coverage report +style: + image: + name: pretix/ci-image + before_script: + - pip install -U pip uv + - uv pip install --system -U wheel setuptools isort black flake8 check-manifest + - uv pip install --system -U git+https://github.com/pretix/pretix.git@master#egg=pretix + script: + - uv pip install --system -e . + - black --check . + - isort -c --gitignore . + - flake8 --extend-exclude .cache . + - check-manifest --ignore .cache . +pypi: + image: + name: pretix/ci-image + before_script: + - cat $PYPIRC > ~/.pypirc + - pip install -U pip uv + - uv pip install --system -U wheel setuptools twine build pretix-plugin-build check-manifest + script: + - python -m build + - check-manifest . + - twine check dist/* + - twine upload dist/* + only: + - pypi + artifacts: + paths: + - dist/ diff --git a/.install-hooks.sh b/.install-hooks.sh new file mode 100755 index 0000000..2e423ff --- /dev/null +++ b/.install-hooks.sh @@ -0,0 +1,16 @@ +#!/bin/sh +REPO_DIR=$(git rev-parse --show-toplevel) +GIT_DIR=$REPO_DIR/.git +VENV_ACTIVATE=$VIRTUAL_ENV/bin/activate +if [[ ! -f $VENV_ACTIVATE ]] +then + echo "Could not find your virtual environment" +fi + +echo "#!/bin/sh" >> $GIT_DIR/hooks/pre-commit +echo "set -e" >> $GIT_DIR/hooks/pre-commit +echo "source $VENV_ACTIVATE" >> $GIT_DIR/hooks/pre-commit +echo "black --check ." >> $GIT_DIR/hooks/pre-commit +echo "isort -c ." >> $GIT_DIR/hooks/pre-commit +echo "flake8 ." >> $GIT_DIR/hooks/pre-commit +chmod +x $GIT_DIR/hooks/pre-commit diff --git a/.update-locales.sh b/.update-locales.sh new file mode 100755 index 0000000..7d60519 --- /dev/null +++ b/.update-locales.sh @@ -0,0 +1,37 @@ +#!/bin/sh +COMPONENTS=pretix/pretix-plugin-pretix-email-template-plugin +DIR=pretix_email_template_plugin/locale +# Renerates .po files used for translating the plugin +set -e +set -x + +# Lock Weblate +for c in $COMPONENTS; do + wlc lock $c; +done + +# Push changes from Weblate to GitHub +for c in $COMPONENTS; do + wlc commit $c; +done + +# Pull changes from GitHub +git pull --rebase + +# Update po files itself +make localegen + +# Commit changes +git add $DIR/*/*/*.po +git add $DIR/*.pot + +git commit -s -m "Update po files +[CI skip]" + +# Push changes +git push + +# Unlock Weblate +for c in $COMPONENTS; do + wlc unlock $c; +done diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b644dd4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ + +Copyright 2024 Your name + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d178a39 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +recursive-include pretix_email_template_plugin/static * +recursive-include pretix_email_template_plugin/templates * +recursive-include pretix_email_template_plugin/locale * +include LICENSE +exclude .gitlab-ci.yml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f96babc --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: localecompile +LNGS:=`find pretix_email_template_plugin/locale/ -mindepth 1 -maxdepth 1 -type d -printf "-l %f "` + +localecompile: + django-admin compilemessages + +localegen: + django-admin makemessages --keep-pot -i build -i dist -i "*egg*" $(LNGS) + +.PHONY: all localecompile localegen diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..518ff69 --- /dev/null +++ b/README.rst @@ -0,0 +1,53 @@ +Email Template +========================== + +This is a plugin for `pretix`_. + +Short description + +Development setup +----------------- + +1. Make sure that you have a working `pretix development setup`_. + +2. Clone this repository. + +3. Activate the virtual environment you use for pretix development. + +4. Execute ``python setup.py develop`` within this directory to register this application with pretix's plugin registry. + +5. Execute ``make`` within this directory to compile translations. + +6. Restart your local pretix server. You can now use the plugin from this repository for your events by enabling it in + the 'plugins' tab in the settings. + +This plugin has CI set up to enforce a few code style rules. To check locally, you need these packages installed:: + + pip install flake8 isort black + +To check your plugin for rule violations, run:: + + black --check . + isort -c . + flake8 . + +You can auto-fix some of these issues by running:: + + isort . + black . + +To automatically check for these issues before you commit, you can run ``.install-hooks``. + + +License +------- + + +Copyright 2024 Your name + +Released under the terms of the Apache License 2.0 + + + +.. _pretix: https://github.com/pretix/pretix +.. _pretix development setup: https://docs.pretix.eu/en/latest/development/setup.html diff --git a/pretix_email_template_plugin/__init__.py b/pretix_email_template_plugin/__init__.py new file mode 100644 index 0000000..5becc17 --- /dev/null +++ b/pretix_email_template_plugin/__init__.py @@ -0,0 +1 @@ +__version__ = "1.0.0" diff --git a/pretix_email_template_plugin/apps.py b/pretix_email_template_plugin/apps.py new file mode 100644 index 0000000..ef1ea52 --- /dev/null +++ b/pretix_email_template_plugin/apps.py @@ -0,0 +1,26 @@ +from django.utils.translation import gettext_lazy + +from . import __version__ + +try: + from pretix.base.plugins import PluginConfig +except ImportError: + raise RuntimeError("Please use pretix 2.7 or above to run this plugin!") + + +class PluginApp(PluginConfig): + default = True + name = "pretix_email_template_plugin" + verbose_name = "Email Template" + + class PretixPluginMeta: + name = gettext_lazy("Email Template") + author = "Your name" + description = gettext_lazy("Short description") + visible = True + version = __version__ + category = "FEATURE" + compatibility = "pretix>=2.7.0" + + def ready(self): + from . import signals # NOQA diff --git a/pretix_email_template_plugin/locale/de/LC_MESSAGES/django.po b/pretix_email_template_plugin/locale/de/LC_MESSAGES/django.po new file mode 100644 index 0000000..216f67e --- /dev/null +++ b/pretix_email_template_plugin/locale/de/LC_MESSAGES/django.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-07 19:01+0100\n" +"PO-Revision-Date: \n" +"Last-Translator: Your name\n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/pretix_email_template_plugin/locale/de_Informal/.gitkeep b/pretix_email_template_plugin/locale/de_Informal/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretix_email_template_plugin/locale/de_Informal/LC_MESSAGES/django.po b/pretix_email_template_plugin/locale/de_Informal/LC_MESSAGES/django.po new file mode 100644 index 0000000..216f67e --- /dev/null +++ b/pretix_email_template_plugin/locale/de_Informal/LC_MESSAGES/django.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-07 19:01+0100\n" +"PO-Revision-Date: \n" +"Last-Translator: Your name\n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/pretix_email_template_plugin/signals.py b/pretix_email_template_plugin/signals.py new file mode 100644 index 0000000..a025794 --- /dev/null +++ b/pretix_email_template_plugin/signals.py @@ -0,0 +1 @@ +# Register your receivers here diff --git a/pretix_email_template_plugin/static/pretix_email_template_plugin/.gitkeep b/pretix_email_template_plugin/static/pretix_email_template_plugin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretix_email_template_plugin/templates/pretix_email_template_plugin/.gitkeep b/pretix_email_template_plugin/templates/pretix_email_template_plugin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretixplugin.toml b/pretixplugin.toml new file mode 100644 index 0000000..4c28f8b --- /dev/null +++ b/pretixplugin.toml @@ -0,0 +1,5 @@ +[plugin] +package = "pretix-email-template-plugin" +modules = [ "pretix_email_template_plugin" ] +marketplace_name = "email-template-plugin" + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..48de8f6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[project] +name = "pretix-email-template-plugin" +dynamic = ["version"] +description = "Short description" +readme = "README.rst" +license = {text = "Apache"} +keywords = ["pretix"] +authors = [ + {name = "Your name", email = "your-email@example.org"}, +] +maintainers = [ + {name = "Your name", email = "your-email@example.org"}, +] + +dependencies = [ +] + +[project.entry-points."pretix.plugin"] +pretix_email_template_plugin = "pretix_email_template_plugin:PretixPluginMeta" + +[project.entry-points."distutils.commands"] +build = "pretix_plugin_build.build:CustomBuild" + +[build-system] +requires = [ + "setuptools", + "pretix-plugin-build", +] + +[project.urls] +homepage = "GitHub repository URL" +repository = "GitHub repository URL" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.dynamic] +version = {attr = "pretix_email_template_plugin.__version__"} + +[tool.setuptools.packages.find] +include = ["pretix*"] +namespaces = false diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c8e4e67 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,44 @@ +[flake8] +ignore = N802,W503,E402 +max-line-length = 160 +exclude = migrations,.ropeproject,static,_static,build + +[isort] +profile = black +combine_as_imports = true +default_section = THIRDPARTY +include_trailing_comma = true +known_third_party = pretix +known_standard_library = typing +skip = setup.py +use_parentheses = True +force_grid_wrap = 0 +line_length = 88 +known_first_party = pretix_email_template_plugin + +[tool:pytest] +DJANGO_SETTINGS_MODULE = pretix.testutils.settings + +[coverage:run] +source = pretix_email_template_plugin +omit = */migrations/*,*/urls.py,*/tests/* + +[coverage:report] +exclude_lines = + pragma: no cover + def __str__ + der __repr__ + if settings.DEBUG + NOQA + NotImplementedError + +[check-manifest] +ignore = + .update-locales.sh + .install-hooks.sh + pretixplugin.toml + Makefile + manage.py + tests/* + *.po + .gitkeep diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b024da8 --- /dev/null +++ b/setup.py @@ -0,0 +1,4 @@ +from setuptools import setup + + +setup() diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..3163d84 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +# put your pytest fixtures here diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..8030fb8 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,3 @@ +def test_empty(): + # put your first tests here + assert 1 + 1 == 2