Skip to content

Commit 69a0f23

Browse files
committed
Init
0 parents  commit 69a0f23

6 files changed

Lines changed: 152 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.idea/
2+
.webassets-cache/
3+
*.min.css
4+
*.min.js
5+
*.pyc
6+
*.egg-info
7+
*.mo
8+
dist/
9+
build/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 RobotHanzo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# indico-plugin-price-adjustments
2+
3+
This plugin provides registration price adjustment options for non-logged-in users.
4+
5+
## Installation
6+
7+
Install the plugin [package](https://pypi.org/project/indico-plugin-price-adjustments/) from PyPI
8+
```bash
9+
pip install indico-plugin-price-adjustments
10+
```
11+
12+
Open `indico.conf` of your indico installation then add `price-adjustments` on `PLUGIN`.
13+
```python
14+
PLUGINS = { ... , 'price-adjustments'}
15+
```
16+
17+
## Install for development for contributing to this plugin
18+
19+
Clone this repository on `~/dev/indico/plugins`
20+
```bash
21+
git clone https://github.com/RobotHanzo/indico-plugin-price-adjustments.git
22+
```
23+
24+
With python virtual environment of Indico development installation enabled, enter the cloned directory then run following command to install the plugin.
25+
```bash
26+
pip install -e .
27+
```
28+
29+
Open `indico.conf` which should be located in `~/dev/indico/src/indico` then add `price-adjustments` on `PLUGIN`.
30+
```python
31+
PLUGINS = { ... , 'price-adjustments'}
32+
```
33+
34+
You can now test you modification on your development indico environment.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from indico.util.i18n import make_bound_gettext
2+
3+
4+
_ = make_bound_gettext('price_adjustments')

indico_price_adjustments/plugin.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from indico.core.plugins import IndicoPlugin
2+
from indico.modules.events.registration.controllers import RegistrationFormMixin
3+
from indico.modules.events.registration.forms import RegistrationFormEditForm, _check_if_payment_required
4+
from indico_patcher import patch
5+
from wtforms.fields import DecimalField
6+
from wtforms.validators import Optional, NumberRange
7+
from wtforms.widgets import NumberInput
8+
from indico.core.db import db
9+
10+
from indico_price_adjustments import _
11+
12+
13+
@patch(RegistrationFormEditForm)
14+
class _RegistrationFormEditFormMixin:
15+
_price_fields = ('currency', 'base_price', 'extra_fee_for_guests')
16+
extra_fee_for_guests = DecimalField(_('Extra fee for guests'),
17+
[NumberRange(min=-999999999.99, max=999999999.99), Optional(),
18+
_check_if_payment_required],
19+
filters=[lambda x: x if x is not None else 0],
20+
widget=NumberInput(step='0.01'),
21+
description=_(
22+
'An extra fee guests(non-logged-in users) have to pay when registering, negative amounts supported.'))
23+
24+
@patch(RegistrationFormMixin)
25+
class _RegistrationFormMixin:
26+
extra_fee_for_guests = db.Column(
27+
db.Numeric(11, 2), # max. 999999999.99
28+
nullable=False,
29+
default=0
30+
)
31+
32+
33+
class PriceAdjustmentsPlugin(IndicoPlugin):
34+
"""Price Adjustments
35+
36+
Provides registration price adjustment options for non-logged-in users.
37+
"""
38+
configurable = False
39+
40+
def init(self):
41+
super().init()
42+
# self.inject_bundle('main.css', WPManageRegistration)

pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[project]
2+
name = 'indico-price-adjustments'
3+
description = 'Price adjustments for logged in users'
4+
readme = 'README.md'
5+
version = '1.0'
6+
license = {text = "MIT License"}
7+
authors = [{ name = 'RobotHanzo', email = 'admin@robothanzo.dev' }]
8+
classifiers = [
9+
'Environment :: Plugins',
10+
'Environment :: Web Environment',
11+
'Programming Language :: Python :: 3.12',
12+
]
13+
requires-python = '>=3.12, <3.13'
14+
dependencies = ['indico>=3.3', 'pygments>=2.7.2,<3', 'indico-patcher>=0.2.1']
15+
16+
[project.urls]
17+
GitHub = 'https://github.com/indico/indico-plugins'
18+
19+
[project.entry-points.'indico.plugins']
20+
price_adjustments = 'indico_price_adjustments.plugin:PriceAdjustmentsPlugin'
21+
22+
[build-system]
23+
requires = ['hatchling==1.27.0']
24+
build-backend = 'hatchling.build'
25+
26+
[tool.hatch.build]
27+
packages = ['indico_price_adjustments']
28+
exclude = [
29+
'*.no-header',
30+
'.keep',
31+
# exclude original client sources (they are all included in source maps anyway)
32+
'indico_*/client/',
33+
# no need for tests outside development
34+
'test_snapshots/',
35+
'tests/',
36+
'*_test.py',
37+
]
38+
artifacts = [
39+
'indico_*/translations/**/messages-react.json',
40+
'indico_*/translations/**/*.mo',
41+
'indico_*/static/dist/',
42+
]

0 commit comments

Comments
 (0)