Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pole-Web
Website
Commits
d4a491da
Commit
d4a491da
authored
Jan 20, 2021
by
HEVELINE Thomas
Committed by
HEVELINE Thomas
Sep 02, 2021
Browse files
(44): sell customization popup
parent
e7e9564b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
boutique/forms.py
View file @
d4a491da
...
...
@@ -101,8 +101,8 @@ class SellForm(forms.Form):
mean
=
forms
.
ChoiceField
(
choices
=
settings
.
PAYMENT_MEANS
)
customization
=
forms
.
CharField
(
label
=
"Perso"
,
required
=
False
)
option
=
forms
.
Ch
oice
Field
(
label
=
"Option 1"
,
required
=
False
)
second_option
=
forms
.
Ch
oice
Field
(
label
=
"Option 2"
,
required
=
False
)
option
=
forms
.
Ch
ar
Field
(
label
=
"Option 1"
,
required
=
False
)
second_option
=
forms
.
Ch
ar
Field
(
label
=
"Option 2"
,
required
=
False
)
def
__init__
(
self
,
*
args
,
instance
:
Optional
[
OrderItem
]
=
None
,
**
kwargs
)
->
None
:
# adds `instance` parameter to emulate ModelForm interface
...
...
@@ -113,11 +113,14 @@ class SellForm(forms.Form):
user
=
self
.
cleaned_data
[
"user"
]
mean
:
str
=
self
.
cleaned_data
[
"mean"
]
quantity
:
int
=
self
.
cleaned_data
[
"quantity"
]
customization
:
str
=
self
.
cleaned_data
[
"customization"
]
option
:
str
=
self
.
cleaned_data
[
"option"
]
second_option
:
str
=
self
.
cleaned_data
[
"second_option"
]
with
transaction
.
atomic
():
order
=
Order
.
objects
.
create
(
user
=
user
,
ordered
=
True
)
Payment
.
objects
.
create
(
mean
=
mean
,
paid
=
True
,
order
=
order
)
order_item
=
item
.
add_to_order
(
order
,
quantity
)
order_item
=
item
.
add_to_order
(
order
,
quantity
,
customization
,
option
,
second_option
)
order
.
compute_price
()
order
.
save
()
order
.
post_payment
()
...
...
boutique/static/boutique/js/item_sell.js
View file @
d4a491da
window
.
addEventListener
(
"
load
"
,
function
()
{
const
list
=
document
.
querySelector
(
"
.item-sell-list
"
);
window
.
addEventListener
(
"
load
"
,
function
()
{
const
list
=
document
.
querySelector
(
"
.item-sell-list
"
);
const
items
=
list
.
getElementsByTagName
(
'
li
'
);
const
items
=
list
.
getElementsByTagName
(
'
li
'
);
for
(
var
i
=
items
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
item
=
items
[
i
];
const
item_id
=
item
.
dataset
.
pk
;
for
(
var
i
=
items
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
item
=
items
[
i
];
const
item_id
=
item
.
dataset
.
pk
;
console
.
log
(
item
.
dataset
);
const
button
=
item
.
lastElementChild
;
button
.
addEventListener
(
"
click
"
,
function
()
{
let
data
=
{
"
item
"
:
item_id
,
"
user
"
:
0
,
"
quantity
"
:
1
,
"
mean
"
:
null
,
"
customization
"
:
''
,
"
option
"
:
''
,
"
second_option
"
:
''
};
const
button
=
item
.
lastElementChild
;
button
.
addEventListener
(
"
click
"
,
function
()
{
let
user_id
=
0
;
let
customization_popup
=
new
CustomizationPopup
(
"
Options et personalisation
"
,
item
,
function
(
quantity
,
customization
,
option
,
second_option
)
{
data
.
quantity
=
quantity
;
data
.
customization
=
customization
;
data
.
option
=
option
;
data
.
second_option
=
second_option
;
mean_popup
.
pop
();
let
mean_popup
=
new
SelectionPopup
(
"
Moyen de paiement
"
,
{
"
card
"
:
"
Carte
"
,
"
online
"
:
"
Lydia
"
,
"
cash
"
:
"
Espèces
"
,
"
check
"
:
"
Chèque
"
},
function
(
mean
)
{
const
data
=
{
"
item
"
:
item_id
,
"
user
"
:
user_id
,
"
quantity
"
:
1
,
"
mean
"
:
mean
};
queryJson
(
""
,
data
,
function
(
response
)
{
add_message
(
response
[
"
status
"
],
response
[
"
message
"
]);
},
"
PUT
"
);
});
});
let
user_popup
=
new
UserSelectionPopup
(
"
Client
"
,
function
(
uid
)
{
user_id
=
uid
;
mean_popup
.
pop
();
});
user_popup
.
pop
();
});
}
let
mean_popup
=
new
SelectionPopup
(
"
Moyen de paiement
"
,
{
"
card
"
:
"
Carte
"
,
"
online
"
:
"
Lydia
"
,
"
cash
"
:
"
Espèces
"
,
"
check
"
:
"
Chèque
"
},
function
(
mean
)
{
data
.
mean
=
mean
;
console
.
log
(
data
);
queryJson
(
""
,
data
,
function
(
response
)
{
add_message
(
response
[
"
status
"
],
response
[
"
message
"
]);
},
"
PUT
"
);
});
list
.
style
.
removeProperty
(
"
display
"
);
let
user_popup
=
new
UserSelectionPopup
(
"
Client
"
,
function
(
uid
,
dname
)
{
console
.
log
(
uid
);
data
.
user
=
uid
;
customization_popup
.
pop
();
});
user_popup
.
pop
();
});
}
list
.
style
.
removeProperty
(
"
display
"
);
});
boutique/templates/boutique/item_sell.html
View file @
d4a491da
...
...
@@ -23,7 +23,15 @@
<ul
class=
"item-sell-list"
style=
"display: none;"
>
{% for item in form.fields.item.queryset %}
<li
data-pk=
"{{ item.pk }}"
>
<li
data-pk=
"{{ item.pk }}"
data-customization=
"{{ item.customization }}"
data-optionLabel=
"{{ item.option_label }}"
data-optionChoices=
"{{ item.option }}"
data-secondOptionLabel=
"{{ item.second_option_label }}"
data-secondOptionChoices=
"{{ item.second_option }}"
data-customizable=
"{{ item.customizable }}"
data-special=
"{{ item.special }}"
>
<h3>
{{ item.name }}
</h3>
<span>
Prix: {{ item.price }}
€
</span>
<span>
Prix cotisant: {{ item.price_contributor }}
€
</span>
...
...
static/js/popup.js
View file @
d4a491da
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment