Skip to content

Commit

Permalink
Merge 20240601-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaunonen committed Jun 1, 2024
2 parents b1c60b4 + 477f327 commit 800f5d4
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 72 deletions.
38 changes: 14 additions & 24 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --all-extras --output-file=constraints.txt --strip-extras
Expand All @@ -14,18 +14,16 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via pip-tools
coverage==7.4.4
coverage==7.5.3
# via pytest-cov
django==4.2.11
django==4.2.13
# via kirppu (pyproject.toml)
django-environ==0.11.2
# via kirppu (pyproject.toml)
django-ipware==5.0.2
# via kirppu (pyproject.toml)
django-ratelimit==4.1.0
# via kirppu (pyproject.toml)
exceptiongroup==1.2.0
# via pytest
factory-boy==3.3.0
# via kirppu (pyproject.toml)
faker==19.13.0
Expand All @@ -34,9 +32,9 @@ faker==19.13.0
# kirppu (pyproject.toml)
future==1.0.0
# via pubcode
gunicorn==20.1.0
gunicorn==22.0.0
# via kirppu (pyproject.toml)
idna==3.6
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
Expand All @@ -49,18 +47,19 @@ oauthlib==3.2.2
packaging==24.0
# via
# build
# gunicorn
# pytest
pillow==10.3.0
# via kirppu (pyproject.toml)
pip-tools==7.4.1
# via kirppu (pyproject.toml)
pluggy==1.4.0
pluggy==1.5.0
# via pytest
psycopg==3.1.18
psycopg==3.1.19
# via kirppu (pyproject.toml)
pubcode==1.1.0
# via kirppu (pyproject.toml)
pyproject-hooks==1.0.0
pyproject-hooks==1.1.0
# via
# build
# pip-tools
Expand All @@ -78,27 +77,18 @@ pytest-env==1.0.1
# via kirppu (pyproject.toml)
python-dateutil==2.9.0.post0
# via faker
requests==2.31.0
requests==2.32.3
# via
# kirppu (pyproject.toml)
# requests-oauthlib
requests-oauthlib==1.3.1
requests-oauthlib==2.0.0
# via kirppu (pyproject.toml)
six==1.16.0
# via python-dateutil
sqlparse==0.4.4
sqlparse==0.5.0
# via django
tomli==2.0.1
# via
# build
# coverage
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.11.0
# via
# asgiref
# psycopg
typing-extensions==4.12.0
# via psycopg
urllib3==2.2.1
# via requests
wheel==0.43.0
Expand Down
18 changes: 18 additions & 0 deletions kirppu/migrations/0048_event_min_box_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.13 on 2024-06-01 10:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kirppu', '0047_event_registration_disabled'),
]

operations = [
migrations.AddField(
model_name='event',
name='min_box_size',
field=models.PositiveSmallIntegerField(default=1),
),
]
2 changes: 2 additions & 0 deletions kirppu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class Event(models.Model):
help_text=_("Should a box be considered a single item when counting max brought"
" items instead of considering its contents individually."),
)
min_box_size = models.PositiveSmallIntegerField(null=False, default=1)

# Link to another database.
source_db = models.CharField(blank=True, max_length=250, null=True, unique=True)

Expand Down
3 changes: 2 additions & 1 deletion kirppu/static_src/js/boxes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ parsePositiveInt = (input) ->
s = input.val()
v = Number.parseInt(s)
ni = input.data("nonInitial") ? false
min = Number.parseInt(input.attr("min") or "1")

if Number.isNaN(v) or v <= 0
if Number.isNaN(v) or v < min
if ni or s != (input.attr("value") ? "")
input.addClass("has-error")
null
Expand Down
2 changes: 1 addition & 1 deletion kirppu/templates/kirppu/app_boxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h3 class="panel-title">{% trans "Add new box" %}</h3>
{% trans "Items:" as tlItems %}
<label id="box-add-count-label" for="box-add-count" class="col-sm-2 control-label" data-tl-bundles="{{ tlBundles }}" data-tl-items="{{ tlItems }}">{{ tlItems }}</label>
<div class="col-sm-2">
<input id="box-add-count" type="number" min="1" class="form-control" placeholder="{% trans "10" %}" />
<input id="box-add-count" type="number" min="{{ event.min_box_size }}" class="form-control" placeholder="{{ min_box_size_placeholder }}" />
</div>
<div class="col-sm-3">
<p class="form-control-static" id="box-total-item-count">
Expand Down
4 changes: 4 additions & 0 deletions kirppu/views/monolithic.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ def box_add(request, event):
max_items = settings.KIRPPU_MAX_ITEMS_PER_VENDOR
item_cnt = Item.objects.filter(vendor=vendor).count()
count = data["count"]
if count < event.min_box_size:
error_msg = "Box size must be greater or equal than %(box_size)d."
return HttpResponseBadRequest(error_msg % {"box_size": event.min_box_size})
if item_cnt >= max_items:
error_msg = _(u"You have %(max_items)s items, which is the maximum. No more items can be registered.")
return HttpResponseBadRequest(error_msg % {'max_items': max_items})
Expand Down Expand Up @@ -505,6 +508,7 @@ def get_boxes(request, event_slug):
'source_event': event.get_real_event(),
'boxes': boxes,
'box_name_placeholder': box_name_placeholder,
'min_box_size_placeholder': max(event.min_box_size, 10),

'profile_url': settings.PROFILE_URL,
'terms_accepted': vendor.terms_accepted if vendor is not None else False,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ dependencies = [
[project.optional-dependencies]
oauth = [
"requests~=2.30",
"requests-oauthlib~=1.3.0",
"requests-oauthlib~=2.0.0",
"oauthlib~=3.2.0",
]
production = [
"gunicorn~=20.1.0",
"gunicorn~=22.0",
"psycopg~=3.1.0",
]
dev = [
Expand Down
17 changes: 4 additions & 13 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# scripts/generate-dep-set.py --extra dev -o 'requirements-dev.txt'
Expand All @@ -22,8 +22,6 @@ django-ipware
# via kirppu (pyproject.toml)
django-ratelimit
# via kirppu (pyproject.toml)
exceptiongroup
# via pytest
factory-boy
# via kirppu (pyproject.toml)
faker
Expand All @@ -49,7 +47,9 @@ pluggy
pubcode
# via kirppu (pyproject.toml)
pyproject-hooks
# via build
# via
# build
# pip-tools
pytest
# via
# kirppu (pyproject.toml)
Expand All @@ -68,15 +68,6 @@ six
# via python-dateutil
sqlparse
# via django
tomli
# via
# build
# coverage
# pip-tools
# pyproject-hooks
# pytest
typing-extensions
# via asgiref
wheel
# via pip-tools
whitenoise
Expand Down
38 changes: 14 additions & 24 deletions requirements-github.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --all-extras --output-file=constraints.txt --strip-extras
Expand All @@ -14,18 +14,16 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via pip-tools
coverage==7.4.4
coverage==7.5.3
# via pytest-cov
django==4.2.11
django==4.2.13
# via kirppu (pyproject.toml)
django-environ==0.11.2
# via kirppu (pyproject.toml)
django-ipware==5.0.2
# via kirppu (pyproject.toml)
django-ratelimit==4.1.0
# via kirppu (pyproject.toml)
exceptiongroup==1.2.0
# via pytest
factory-boy==3.3.0
# via kirppu (pyproject.toml)
faker==19.13.0
Expand All @@ -34,9 +32,9 @@ faker==19.13.0
# kirppu (pyproject.toml)
future==1.0.0
# via pubcode
gunicorn==20.1.0
gunicorn==22.0.0
# via kirppu (pyproject.toml)
idna==3.6
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
Expand All @@ -49,18 +47,19 @@ oauthlib==3.2.2
packaging==24.0
# via
# build
# gunicorn
# pytest
pillow==10.3.0
# via kirppu (pyproject.toml)
pip-tools==7.4.1
# via kirppu (pyproject.toml)
pluggy==1.4.0
pluggy==1.5.0
# via pytest
psycopg==3.1.18
psycopg==3.1.19
# via kirppu (pyproject.toml)
pubcode==1.1.0
# via kirppu (pyproject.toml)
pyproject-hooks==1.0.0
pyproject-hooks==1.1.0
# via
# build
# pip-tools
Expand All @@ -78,27 +77,18 @@ pytest-env==1.0.1
# via kirppu (pyproject.toml)
python-dateutil==2.9.0.post0
# via faker
requests==2.31.0
requests==2.32.3
# via
# kirppu (pyproject.toml)
# requests-oauthlib
requests-oauthlib==1.3.1
requests-oauthlib==2.0.0
# via kirppu (pyproject.toml)
six==1.16.0
# via python-dateutil
sqlparse==0.4.4
sqlparse==0.5.0
# via django
tomli==2.0.1
# via
# build
# coverage
# pip-tools
# pyproject-hooks
# pytest
typing-extensions==4.11.0
# via
# asgiref
# psycopg
typing-extensions==4.12.0
# via psycopg
urllib3==2.2.1
# via requests
wheel==0.43.0
Expand Down
11 changes: 4 additions & 7 deletions requirements-production.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# scripts/generate-dep-set.py --extra oauth --extra production -o 'requirements-production.txt'
Expand Down Expand Up @@ -32,6 +32,8 @@ oauthlib
# via
# kirppu (pyproject.toml)
# requests-oauthlib
packaging
# via gunicorn
pillow
# via kirppu (pyproject.toml)
psycopg
Expand All @@ -47,14 +49,9 @@ requests-oauthlib
sqlparse
# via django
typing-extensions
# via
# asgiref
# psycopg
# via psycopg
urllib3
# via requests
whitenoise
# via kirppu (pyproject.toml)

# The following packages are considered to be unsafe in a requirements file:
# setuptools

0 comments on commit 800f5d4

Please sign in to comment.