mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-25 09:11:13 +00:00
Apply review comments
This commit is contained in:
parent
6f003ffa53
commit
139221dd22
@ -1,6 +1,6 @@
|
|||||||
import { exportToHtml } from "#core:utils/globals";
|
import { exportToHtml } from "#core:utils/globals";
|
||||||
import { BasketItem } from "#counter:counter/basket";
|
import { BasketItem } from "#counter:counter/basket";
|
||||||
import type { CounterConfig } from "#counter:counter/types";
|
import type { CounterConfig, ErrorMessage } from "#counter:counter/types";
|
||||||
|
|
||||||
exportToHtml("loadCounter", (config: CounterConfig) => {
|
exportToHtml("loadCounter", (config: CounterConfig) => {
|
||||||
document.addEventListener("alpine:init", () => {
|
document.addEventListener("alpine:init", () => {
|
||||||
@ -38,7 +38,7 @@ exportToHtml("loadCounter", (config: CounterConfig) => {
|
|||||||
delete this.basket[id];
|
delete this.basket[id];
|
||||||
},
|
},
|
||||||
|
|
||||||
addToBasket(id: string, quantity: number): string {
|
addToBasket(id: string, quantity: number): ErrorMessage {
|
||||||
const item: BasketItem =
|
const item: BasketItem =
|
||||||
this.basket[id] || new BasketItem(config.products[id], 0);
|
this.basket[id] || new BasketItem(config.products[id], 0);
|
||||||
|
|
||||||
|
2
counter/static/bundled/counter/types.d.ts
vendored
2
counter/static/bundled/counter/types.d.ts
vendored
@ -1,3 +1,5 @@
|
|||||||
|
type ErrorMessage = string;
|
||||||
|
|
||||||
export interface InitialFormData {
|
export interface InitialFormData {
|
||||||
/* Used to refill the form when the backend raises an error */
|
/* Used to refill the form when the backend raises an error */
|
||||||
id?: keyof Record<string, Product>;
|
id?: keyof Record<string, Product>;
|
||||||
|
@ -30,7 +30,7 @@ from freezegun import freeze_time
|
|||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
|
|
||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
from core.baker_recipes import board_user, subscriber_user
|
from core.baker_recipes import board_user, subscriber_user, very_old_subscriber_user
|
||||||
from core.models import Group, User
|
from core.models import Group, User
|
||||||
from counter.baker_recipes import product_recipe
|
from counter.baker_recipes import product_recipe
|
||||||
from counter.models import (
|
from counter.models import (
|
||||||
@ -43,7 +43,7 @@ from counter.models import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FullClickSetup:
|
class TestFullClickBase(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
cls.customer = subscriber_user.make()
|
cls.customer = subscriber_user.make()
|
||||||
@ -54,8 +54,7 @@ class FullClickSetup:
|
|||||||
cls.subscriber = subscriber_user.make()
|
cls.subscriber = subscriber_user.make()
|
||||||
|
|
||||||
cls.counter = baker.make(Counter, type="BAR")
|
cls.counter = baker.make(Counter, type="BAR")
|
||||||
cls.counter.sellers.add(cls.barmen)
|
cls.counter.sellers.add(cls.barmen, cls.board_admin)
|
||||||
cls.counter.sellers.add(cls.board_admin)
|
|
||||||
|
|
||||||
cls.other_counter = baker.make(Counter, type="BAR")
|
cls.other_counter = baker.make(Counter, type="BAR")
|
||||||
cls.other_counter.sellers.add(cls.barmen)
|
cls.other_counter.sellers.add(cls.barmen)
|
||||||
@ -67,10 +66,7 @@ class FullClickSetup:
|
|||||||
sub.subscription_end = localdate() - timedelta(days=89)
|
sub.subscription_end = localdate() - timedelta(days=89)
|
||||||
sub.save()
|
sub.save()
|
||||||
|
|
||||||
cls.customer_old_can_not_buy = subscriber_user.make()
|
cls.customer_old_can_not_buy = very_old_subscriber_user.make()
|
||||||
sub = cls.customer_old_can_not_buy.subscriptions.first()
|
|
||||||
sub.subscription_end = localdate() - timedelta(days=90)
|
|
||||||
sub.save()
|
|
||||||
|
|
||||||
cls.customer_can_not_buy = baker.make(User)
|
cls.customer_can_not_buy = baker.make(User)
|
||||||
|
|
||||||
@ -89,7 +85,7 @@ class FullClickSetup:
|
|||||||
return user.customer.amount
|
return user.customer.amount
|
||||||
|
|
||||||
|
|
||||||
class TestRefilling(FullClickSetup, TestCase):
|
class TestRefilling(TestFullClickBase):
|
||||||
def login_in_bar(self, barmen: User | None = None):
|
def login_in_bar(self, barmen: User | None = None):
|
||||||
used_barman = barmen if barmen is not None else self.board_admin
|
used_barman = barmen if barmen is not None else self.board_admin
|
||||||
self.client.post(
|
self.client.post(
|
||||||
@ -218,7 +214,7 @@ class BasketItem:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestCounterClick(FullClickSetup, TestCase):
|
class TestCounterClick(TestFullClickBase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
super().setUpTestData()
|
super().setUpTestData()
|
||||||
@ -257,16 +253,11 @@ class TestCounterClick(FullClickSetup, TestCase):
|
|||||||
limit_age=0, selling_price="1.5", special_selling_price="1"
|
limit_age=0, selling_price="1.5", special_selling_price="1"
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.counter.products.add(cls.beer)
|
cls.counter.products.add(cls.beer, cls.beer_tap, cls.snack)
|
||||||
cls.counter.products.add(cls.beer_tap)
|
|
||||||
cls.counter.products.add(cls.snack)
|
|
||||||
cls.counter.save()
|
|
||||||
|
|
||||||
cls.other_counter.products.add(cls.snack)
|
cls.other_counter.products.add(cls.snack)
|
||||||
cls.other_counter.save()
|
|
||||||
|
|
||||||
cls.club_counter.products.add(cls.stamps)
|
cls.club_counter.products.add(cls.stamps)
|
||||||
cls.club_counter.save()
|
|
||||||
|
|
||||||
def login_in_bar(self, barmen: User | None = None):
|
def login_in_bar(self, barmen: User | None = None):
|
||||||
used_barman = barmen if barmen is not None else self.barmen
|
used_barman = barmen if barmen is not None else self.barmen
|
||||||
|
Loading…
Reference in New Issue
Block a user