Skip to content

Commit 4756dd5

Browse files
committed
Init custom pass
1 parent 69a0f23 commit 4756dd5

10 files changed

Lines changed: 171 additions & 58 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
release-build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.x"
28+
29+
- name: Build release distributions
30+
run: |
31+
# NOTE: put your own distribution build steps here.
32+
python -m pip install build
33+
python -m build
34+
35+
- name: Upload distributions
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: release-dists
39+
path: dist/
40+
41+
pypi-publish:
42+
runs-on: ubuntu-latest
43+
needs:
44+
- release-build
45+
permissions:
46+
# IMPORTANT: this permission is mandatory for trusted publishing
47+
id-token: write
48+
49+
# Dedicated environments with protections for publishing are strongly recommended.
50+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51+
environment:
52+
name: pypi
53+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54+
# url: https://pypi.org/p/YOURPROJECT
55+
#
56+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57+
# ALTERNATIVE: exactly, uncomment the following line instead:
58+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59+
60+
steps:
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish release distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist/

.gitignore

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*.mo
88
dist/
99
build/
10+
update.sh

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# indico-plugin-price-adjustments
1+
# indico-custom-pass
22

3-
This plugin provides registration price adjustment options for non-logged-in users.
3+
This plugin grants admins the ability to customize Indico Google Wallet & Apple Pay passes.
44

55
## Installation
66

7-
Install the plugin [package](https://pypi.org/project/indico-plugin-price-adjustments/) from PyPI
7+
Install the plugin [package](https://pypi.org/project/indico-custom-pass/) from PyPI
88
```bash
9-
pip install indico-plugin-price-adjustments
9+
pip install indico-custom-pass
1010
```
1111

12-
Open `indico.conf` of your indico installation then add `price-adjustments` on `PLUGIN`.
12+
Open `indico.conf` of your indico installation then add `custom_pass` on `PLUGIN`.
1313
```python
14-
PLUGINS = { ... , 'price-adjustments'}
14+
PLUGINS = { ... , 'custom_pass'}
1515
```
1616

1717
## Install for development for contributing to this plugin
1818

1919
Clone this repository on `~/dev/indico/plugins`
2020
```bash
21-
git clone https://github.com/RobotHanzo/indico-plugin-price-adjustments.git
21+
git clone https://github.com/RobotHanzo/IndicoCustomPass.git
2222
```
2323

2424
With python virtual environment of Indico development installation enabled, enter the cloned directory then run following command to install the plugin.
2525
```bash
2626
pip install -e .
2727
```
2828

29-
Open `indico.conf` which should be located in `~/dev/indico/src/indico` then add `price-adjustments` on `PLUGIN`.
29+
Open `indico.conf` which should be located in `~/dev/indico/src/indico` then add `custom_pass` on `PLUGIN`.
3030
```python
31-
PLUGINS = { ... , 'price-adjustments'}
31+
PLUGINS = { ... , 'custom_pass'}
3232
```
3333

3434
You can now test you modification on your development indico environment.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from indico.util.i18n import make_bound_gettext
22

33

4-
_ = make_bound_gettext('price_adjustments')
4+
_ = make_bound_gettext('custom_pass')

indico_custom_pass/migrations/.no-header

Whitespace-only changes.

indico_custom_pass/plugin.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from indico.core.plugins import IndicoPlugin
2+
from indico.modules.events.registration import GoogleWalletManager
3+
from indico.modules.events.registration.wallets.apple import AppleWalletManager
4+
from indico_patcher import patch
5+
6+
from indico_custom_pass.settings import CustomPassSettingsForm
7+
8+
class CustomPassPlugin(IndicoPlugin):
9+
"""Custom Pass
10+
11+
Grants admins the ability to customize Indico Google Wallet & Apple Pay passes.
12+
"""
13+
configurable = True
14+
settings_form = CustomPassSettingsForm
15+
default_settings = {
16+
'apple_pass_background_color': '#007cac',
17+
'apple_pass_foreground_color': '#ffffff',
18+
'apple_pass_label_color': '#ffffff',
19+
'apple_pass_organization_name': 'Indico',
20+
'google_pass_background_color': '#007cac'
21+
}
22+
23+
def init(self):
24+
super().init()
25+
26+
27+
@patch(AppleWalletManager)
28+
class AppleWalletManagerMixin(AppleWalletManager):
29+
def build_pass_object(self, registration):
30+
p = super().build_pass_object(registration)
31+
p.backgroundColor = CustomPassPlugin.settings.get('apple_pass_background_color')
32+
p.foregroundColor = CustomPassPlugin.settings.get('apple_pass_foreground_color')
33+
p.labelColor = CustomPassPlugin.settings.get('apple_pass_label_color')
34+
p.organizationName = CustomPassPlugin.settings.get('apple_pass_organization_name')
35+
return p
36+
37+
38+
@patch(GoogleWalletManager)
39+
class GoogleWalletManagerMixin(GoogleWalletManager):
40+
def build_ticket_object_data(self, registration):
41+
data = super().build_ticket_object_data(registration)
42+
data['hexBackgroundColor'] = CustomPassPlugin.settings.get('google_pass_background_color')
43+
return data

indico_custom_pass/settings.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from indico.web.forms.base import IndicoForm
2+
from wtforms import StringField, ColorField
3+
from wtforms.validators import Regexp
4+
5+
from indico_custom_pass import _
6+
7+
8+
class CustomPassSettingsForm(IndicoForm):
9+
apple_pass_background_color = ColorField(
10+
_('Apple Wallet pass background color'),
11+
description=_(
12+
'The background color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
13+
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
14+
default='#000000'
15+
)
16+
apple_pass_foreground_color = ColorField(
17+
_('Apple Wallet pass foreground color'),
18+
description=_(
19+
'The foreground color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
20+
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
21+
default='#ffffff'
22+
)
23+
apple_pass_label_color = ColorField(
24+
_('Apple Wallet pass label color'),
25+
description=_(
26+
'The label color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
27+
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
28+
default='#ffffff'
29+
)
30+
apple_pass_organization_name = StringField(
31+
_('Apple Wallet pass organization name'),
32+
description=_('The organization name displayed on the Apple Wallet pass.'),
33+
default='Indico',
34+
)
35+
google_pass_background_color = ColorField(
36+
_('Google Wallet pass background color'),
37+
description=_(
38+
'The background color of the Google Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
39+
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
40+
default='#007cac'
41+
)

indico_price_adjustments/plugin.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

pyproject.toml

100644100755
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[project]
2-
name = 'indico-price-adjustments'
3-
description = 'Price adjustments for logged in users'
2+
name = 'indico-custom-pass'
3+
description = 'Grants admins the ability to customize Indico Google Wallet & Apple Pay passes.'
44
readme = 'README.md'
5-
version = '1.0'
5+
version = '1.0.3'
66
license = {text = "MIT License"}
77
authors = [{ name = 'RobotHanzo', email = 'admin@robothanzo.dev' }]
88
classifiers = [
@@ -14,17 +14,17 @@ requires-python = '>=3.12, <3.13'
1414
dependencies = ['indico>=3.3', 'pygments>=2.7.2,<3', 'indico-patcher>=0.2.1']
1515

1616
[project.urls]
17-
GitHub = 'https://github.com/indico/indico-plugins'
17+
GitHub = 'https://github.com/RobotHanzo/IndicoCustomPass'
1818

1919
[project.entry-points.'indico.plugins']
20-
price_adjustments = 'indico_price_adjustments.plugin:PriceAdjustmentsPlugin'
20+
custom_pass = 'indico_custom_pass.plugin:CustomPassPlugin'
2121

2222
[build-system]
2323
requires = ['hatchling==1.27.0']
2424
build-backend = 'hatchling.build'
2525

2626
[tool.hatch.build]
27-
packages = ['indico_price_adjustments']
27+
packages = ['indico_custom_pass']
2828
exclude = [
2929
'*.no-header',
3030
'.keep',

0 commit comments

Comments
 (0)