new tag v3.1.0
Fix: Company references left after the field was removed
This commit is contained in:
parent
969b774a25
commit
4108040cdd
@ -33,7 +33,7 @@ def save(
|
||||
user: UserToken = Security(get_user, scopes=["customers"]),
|
||||
):
|
||||
try:
|
||||
item = Customer(company=data.company, name=data.name, phone=data.phone, address=data.address)
|
||||
item = Customer(name=data.name, phone=data.phone, address=data.address)
|
||||
db.add(item)
|
||||
db.commit()
|
||||
return customer_info(item)
|
||||
@ -57,7 +57,6 @@ def update(
|
||||
):
|
||||
try:
|
||||
item: Customer = db.query(Customer).filter(Customer.id == id_).first()
|
||||
item.company = data.company
|
||||
item.name = data.name
|
||||
item.phone = data.phone
|
||||
item.address = data.address
|
||||
@ -119,10 +118,9 @@ def show_id(
|
||||
|
||||
def customer_info(item: Optional[Customer]):
|
||||
if item is None:
|
||||
return {"name": "", "company": "", "address": "", "phone": ""}
|
||||
return {"name": "", "address": "", "phone": ""}
|
||||
return {
|
||||
"id": item.id,
|
||||
"company": item.company,
|
||||
"name": item.name,
|
||||
"address": item.address,
|
||||
"phone": item.phone,
|
||||
|
@ -39,7 +39,6 @@ def save(
|
||||
customer: Customer = db.query(Customer).filter(Customer.phone == data.phone).first()
|
||||
if customer is None:
|
||||
customer = Customer(
|
||||
company=data.company,
|
||||
name=data.name,
|
||||
phone=data.phone,
|
||||
address=data.address,
|
||||
@ -47,7 +46,6 @@ def save(
|
||||
db.add(customer)
|
||||
else:
|
||||
customer.name = data.name or customer.name
|
||||
customer.company = data.company or customer.company
|
||||
customer.address = data.address or customer.address
|
||||
item = GuestBook(pax=data.pax, customer=customer)
|
||||
db.add(item)
|
||||
@ -73,7 +71,6 @@ def update(
|
||||
):
|
||||
try:
|
||||
item: GuestBook = db.query(GuestBook).filter(GuestBook.id == id_).first()
|
||||
item.customer.company = data.company
|
||||
item.customer.name = data.name
|
||||
item.customer.phone = data.phone
|
||||
item.customer.address = data.address
|
||||
@ -155,7 +152,6 @@ def show_list(
|
||||
{
|
||||
"id": item.id,
|
||||
"serial": i + 1,
|
||||
"company": item.customer.company,
|
||||
"name": item.customer.name,
|
||||
"phone": item.customer.phone,
|
||||
"pax": item.pax,
|
||||
@ -180,7 +176,6 @@ def guest_book_info(item: Optional[GuestBook]):
|
||||
if item is not None:
|
||||
return {
|
||||
"id": item.id,
|
||||
"company": item.customer.company,
|
||||
"name": item.customer.name,
|
||||
"phone": item.customer.phone,
|
||||
"pax": item.pax,
|
||||
@ -188,4 +183,4 @@ def guest_book_info(item: Optional[GuestBook]):
|
||||
"date": item.date.strftime("%d-%b-%Y %H:%M"),
|
||||
}
|
||||
else:
|
||||
return {"company": "", "name": "", "phone": "", "pax": 0, "address": ""}
|
||||
return {"name": "", "phone": "", "pax": 0, "address": ""}
|
||||
|
@ -9,7 +9,6 @@ from . import to_camel
|
||||
|
||||
class CustomerIn(BaseModel):
|
||||
name: str = Field(..., min_length=1)
|
||||
company: str
|
||||
phone: str = Field(..., min_length=1)
|
||||
address: str
|
||||
|
||||
|
@ -44,18 +44,6 @@
|
||||
<input matInput placeholder="Pax" type="number" formControlName="pax" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Company</mat-label>
|
||||
<input matInput placeholder="Company" formControlName="company" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
|
@ -28,7 +28,6 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
company: null,
|
||||
name: [null, Validators.required],
|
||||
phone: [null, Validators.required],
|
||||
pax: ['0', Validators.required],
|
||||
@ -51,7 +50,6 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
showItem(item: GuestBook) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
company: item.company,
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
pax: `${item.pax}`,
|
||||
@ -73,7 +71,6 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
getItem(): GuestBook {
|
||||
const formModel = this.form.value;
|
||||
this.item.company = formModel.company;
|
||||
this.item.name = formModel.name;
|
||||
this.item.phone = formModel.phone;
|
||||
this.item.pax = parseInt(formModel.pax, 10);
|
||||
|
@ -1,7 +1,6 @@
|
||||
export class GuestBook {
|
||||
id: string;
|
||||
serial: number;
|
||||
company: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
pax: number;
|
||||
|
Loading…
Reference in New Issue
Block a user