fix(Issue-27): Confirmations not triggered on models with validation failures (#30)
* feat(ISSUE-27): Added some validation integration tests * feat(ISSUE-27): Integration tests for validations * feat(ISSUE-27): Unable to select autocomplete with selenium * feat(ISSUE-27): Fix file caching with proper FileCache * feat(ISSUE-27): Some minor tweaks * feat(ISSUE-27): Try reviewdog * feat(ISSUE-27): Remove noisy linting * feat(ISSUE-27): Black format * feat(ISSUE-27): Adding some simple file cache tests * feat(ISSUE-27): Some cleaning up Co-authored-by: Thu Trang Pham <thu@joinmodernhealth.com>
This commit is contained in:
@@ -8,6 +8,9 @@ from ..models import Checkout
|
||||
|
||||
|
||||
class CheckoutForm(ModelForm):
|
||||
search_fields = ["shop", "date"]
|
||||
confirm_change = True
|
||||
|
||||
class Meta:
|
||||
model = Checkout
|
||||
fields = [
|
||||
|
||||
@@ -5,6 +5,7 @@ from admin_confirm.admin import AdminConfirmMixin, confirm_action
|
||||
class ShopAdmin(AdminConfirmMixin, ModelAdmin):
|
||||
confirmation_fields = ["name"]
|
||||
actions = ["show_message", "show_message_no_confirmation"]
|
||||
search_fields = ["name"]
|
||||
|
||||
@confirm_action
|
||||
def show_message(modeladmin, request, queryset):
|
||||
|
||||
@@ -7,39 +7,89 @@ import django.db.models.deletion
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('market', '0009_auto_20210304_0355'),
|
||||
("market", "0009_auto_20210304_0355"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Transaction',
|
||||
name="Transaction",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('timestamp', models.DateField(auto_created=True)),
|
||||
('total', models.DecimalField(decimal_places=2, editable=False, max_digits=5)),
|
||||
('currency', models.CharField(choices=[('CAD', 'CAD'), ('USD', 'USD')], max_length=3)),
|
||||
('shop', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='market.shop')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("timestamp", models.DateField(auto_created=True)),
|
||||
(
|
||||
"total",
|
||||
models.DecimalField(decimal_places=2, editable=False, max_digits=5),
|
||||
),
|
||||
(
|
||||
"currency",
|
||||
models.CharField(
|
||||
choices=[("CAD", "CAD"), ("USD", "USD")], max_length=3
|
||||
),
|
||||
),
|
||||
(
|
||||
"shop",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="market.shop"
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ItemSale',
|
||||
name="ItemSale",
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('total', models.DecimalField(decimal_places=2, editable=False, max_digits=5)),
|
||||
('currency', models.CharField(choices=[('CAD', 'CAD'), ('USD', 'USD')], max_length=3)),
|
||||
('item', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='market.item')),
|
||||
('transaction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='item_sales', to='market.transaction')),
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"total",
|
||||
models.DecimalField(decimal_places=2, editable=False, max_digits=5),
|
||||
),
|
||||
(
|
||||
"currency",
|
||||
models.CharField(
|
||||
choices=[("CAD", "CAD"), ("USD", "USD")], max_length=3
|
||||
),
|
||||
),
|
||||
(
|
||||
"item",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
to="market.item",
|
||||
),
|
||||
),
|
||||
(
|
||||
"transaction",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="item_sales",
|
||||
to="market.transaction",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Checkout',
|
||||
fields=[
|
||||
],
|
||||
name="Checkout",
|
||||
fields=[],
|
||||
options={
|
||||
'proxy': True,
|
||||
'indexes': [],
|
||||
'constraints': [],
|
||||
"proxy": True,
|
||||
"indexes": [],
|
||||
"constraints": [],
|
||||
},
|
||||
bases=('market.transaction',),
|
||||
bases=("market.transaction",),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -6,18 +6,18 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('market', '0011_auto_20210326_0130'),
|
||||
("market", "0011_auto_20210326_0130"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='transaction',
|
||||
name='date',
|
||||
model_name="transaction",
|
||||
name="date",
|
||||
field=models.DateField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='transaction',
|
||||
name='timestamp',
|
||||
model_name="transaction",
|
||||
name="timestamp",
|
||||
field=models.DateTimeField(auto_created=True),
|
||||
),
|
||||
]
|
||||
|
||||
@@ -52,7 +52,7 @@ class Town(models.Model):
|
||||
|
||||
class ShoppingMall(models.Model):
|
||||
name = models.CharField(max_length=120)
|
||||
shops = models.ManyToManyField(Shop, blank=True, null=True)
|
||||
shops = models.ManyToManyField(Shop, blank=True)
|
||||
general_manager = models.OneToOneField(
|
||||
GeneralManager, on_delete=models.CASCADE, null=True, blank=True
|
||||
)
|
||||
|
||||
@@ -23,11 +23,12 @@ SECRET_KEY = "=yddl-40388w3e2hl$e8)revce=n67_idi8pfejtn3!+2%!_qt"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
ADMIN_CONFIRM_DEBUG = True
|
||||
|
||||
USE_DCOKER = os.environ.get("USE_DOCKER", "").lower() == "true"
|
||||
USE_DOCKER = os.environ.get("USE_DOCKER", "").lower() == "true"
|
||||
|
||||
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
|
||||
if USE_DCOKER:
|
||||
if USE_DOCKER:
|
||||
import socket
|
||||
|
||||
ALLOWED_HOSTS += [socket.gethostbyname(socket.gethostname())]
|
||||
|
||||
Reference in New Issue
Block a user