Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrliu committed Oct 9, 2024
0 parents commit c521dfb
Show file tree
Hide file tree
Showing 24 changed files with 536 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -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: .
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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/
16 changes: 16 additions & 0 deletions .install-hooks.sh
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .update-locales.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.

5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions pretix_email_template_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
Loading

0 comments on commit c521dfb

Please sign in to comment.