lfs-samples 1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lfs_samples/__init__.py +0 -0
- lfs_samples/admin.py +9 -0
- lfs_samples/apps.py +24 -0
- lfs_samples/locale/de/LC_MESSAGES/django.mo +0 -0
- lfs_samples/locale/de/LC_MESSAGES/django.po +68 -0
- lfs_samples/migrations/0001_initial.py +47 -0
- lfs_samples/migrations/0002_issample.py +25 -0
- lfs_samples/migrations/__init__.py +0 -0
- lfs_samples/models.py +38 -0
- lfs_samples/templates/lfs_samples/samples.html +56 -0
- lfs_samples/templates/lfs_samples/samples_inline.html +161 -0
- lfs_samples/templates/manage/products/tabs/_assigned_samples.html +88 -0
- lfs_samples/templates/manage/products/tabs/_available_samples.html +88 -0
- lfs_samples/templates/manage/products/tabs/_samples.html +103 -0
- lfs_samples/templatetags/__init__.py +0 -0
- lfs_samples/templatetags/lfs_samples_tags.py +68 -0
- lfs_samples/tests/__init__.py +0 -0
- lfs_samples/tests/settings.py +44 -0
- lfs_samples/tests/test_manage_tab.py +26 -0
- lfs_samples/tests/urls.py +9 -0
- lfs_samples/urls.py +17 -0
- lfs_samples/utils.py +49 -0
- lfs_samples/views.py +388 -0
- lfs_samples-1.1.dist-info/METADATA +150 -0
- lfs_samples-1.1.dist-info/RECORD +28 -0
- lfs_samples-1.1.dist-info/WHEEL +5 -0
- lfs_samples-1.1.dist-info/licenses/LICENSE.txt +27 -0
- lfs_samples-1.1.dist-info/top_level.txt +1 -0
lfs_samples/__init__.py
ADDED
|
File without changes
|
lfs_samples/admin.py
ADDED
lfs_samples/apps.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""App configuration: registers the samples tab on the product management page."""
|
|
2
|
+
|
|
3
|
+
from django.apps import AppConfig
|
|
4
|
+
from django.utils.translation import gettext_lazy as _
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LfsSamplesConfig(AppConfig):
|
|
8
|
+
"""Adds the "Samples" tab to every product."""
|
|
9
|
+
|
|
10
|
+
name = "lfs_samples"
|
|
11
|
+
verbose_name = _("Samples")
|
|
12
|
+
|
|
13
|
+
def ready(self) -> None:
|
|
14
|
+
"""Register the product tab."""
|
|
15
|
+
from lfs.manage.products.tabs import ProductTab, register_product_tab
|
|
16
|
+
|
|
17
|
+
register_product_tab(
|
|
18
|
+
ProductTab(
|
|
19
|
+
key="samples",
|
|
20
|
+
label=_("Samples"),
|
|
21
|
+
url_name="lfs_manage_product_samples",
|
|
22
|
+
template="manage/products/tabs/_samples.html",
|
|
23
|
+
)
|
|
24
|
+
)
|
|
Binary file
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
|
3
|
+
# This file is distributed under the same license as the PACKAGE package.
|
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
5
|
+
#
|
|
6
|
+
msgid ""
|
|
7
|
+
msgstr ""
|
|
8
|
+
"Project-Id-Version: PACKAGE VERSION\n"
|
|
9
|
+
"Report-Msgid-Bugs-To: \n"
|
|
10
|
+
"POT-Creation-Date: 2016-01-07 11:41+0100\n"
|
|
11
|
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
12
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
13
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
14
|
+
"Language: \n"
|
|
15
|
+
"MIME-Version: 1.0\n"
|
|
16
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
|
17
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
18
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
19
|
+
|
|
20
|
+
#: models.py:28
|
|
21
|
+
msgid "Sample"
|
|
22
|
+
msgstr "Muster"
|
|
23
|
+
|
|
24
|
+
#: templates/lfs_samples/samples.html:5
|
|
25
|
+
msgid "Samples"
|
|
26
|
+
msgstr "Muster"
|
|
27
|
+
|
|
28
|
+
#: templates/lfs_samples/samples.html:14
|
|
29
|
+
#| msgid "Sample"
|
|
30
|
+
msgid "Is sample"
|
|
31
|
+
msgstr "Ist Muster"
|
|
32
|
+
|
|
33
|
+
#: templates/lfs_samples/samples.html:30
|
|
34
|
+
msgid "Active samples"
|
|
35
|
+
msgstr "Muster aktiv"
|
|
36
|
+
|
|
37
|
+
#: templates/lfs_samples/samples_inline.html:33
|
|
38
|
+
msgid "Selectable Samples"
|
|
39
|
+
msgstr "Auswählbare Muster"
|
|
40
|
+
|
|
41
|
+
#: templates/lfs_samples/samples_inline.html:53
|
|
42
|
+
#: templates/lfs_samples/samples_inline.html:116
|
|
43
|
+
msgid "Active"
|
|
44
|
+
msgstr "Muster aktiv"
|
|
45
|
+
|
|
46
|
+
#: templates/lfs_samples/samples_inline.html:92
|
|
47
|
+
msgid "Add to samples"
|
|
48
|
+
msgstr "Zu Muster hinzufügen"
|
|
49
|
+
|
|
50
|
+
#: templates/lfs_samples/samples_inline.html:97
|
|
51
|
+
msgid "Selected Samples"
|
|
52
|
+
msgstr "Ausgewählte Muster"
|
|
53
|
+
|
|
54
|
+
#: templates/lfs_samples/samples_inline.html:156
|
|
55
|
+
msgid "Remove from samples"
|
|
56
|
+
msgstr "Von Muster entfernen"
|
|
57
|
+
|
|
58
|
+
#: views.py:187
|
|
59
|
+
msgid "Samples have been added."
|
|
60
|
+
msgstr "Muster wurden hinzugefügt."
|
|
61
|
+
|
|
62
|
+
#: views.py:214
|
|
63
|
+
msgid "Samples have been removed."
|
|
64
|
+
msgstr "Muster wurden entfernt."
|
|
65
|
+
|
|
66
|
+
#: views.py:241 views.py:268
|
|
67
|
+
msgid "Sample has been updated."
|
|
68
|
+
msgstr "Muster wurde aktualisiert."
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
# The models point to catalog.Product, so the catalog's tables must exist first.
|
|
9
|
+
dependencies = [
|
|
10
|
+
("catalog", "0001_initial"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.CreateModel(
|
|
15
|
+
name="ActivityState",
|
|
16
|
+
fields=[
|
|
17
|
+
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
|
|
18
|
+
(
|
|
19
|
+
"product",
|
|
20
|
+
models.ForeignKey(
|
|
21
|
+
related_name="active_samples",
|
|
22
|
+
verbose_name="Product",
|
|
23
|
+
to="catalog.Product",
|
|
24
|
+
on_delete=models.CASCADE,
|
|
25
|
+
),
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
),
|
|
29
|
+
migrations.CreateModel(
|
|
30
|
+
name="ProductSamplesRelation",
|
|
31
|
+
fields=[
|
|
32
|
+
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
|
|
33
|
+
(
|
|
34
|
+
"product",
|
|
35
|
+
models.ForeignKey(
|
|
36
|
+
related_name="products", verbose_name="Product", to="catalog.Product", on_delete=models.CASCADE
|
|
37
|
+
),
|
|
38
|
+
),
|
|
39
|
+
(
|
|
40
|
+
"sample",
|
|
41
|
+
models.ForeignKey(
|
|
42
|
+
related_name="samples", verbose_name="Sample", to="catalog.Product", on_delete=models.CASCADE
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
],
|
|
46
|
+
),
|
|
47
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import unicode_literals
|
|
3
|
+
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("lfs_samples", "0001_initial"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.CreateModel(
|
|
14
|
+
name="IsSample",
|
|
15
|
+
fields=[
|
|
16
|
+
("id", models.AutoField(verbose_name="ID", serialize=False, auto_created=True, primary_key=True)),
|
|
17
|
+
(
|
|
18
|
+
"product",
|
|
19
|
+
models.ForeignKey(
|
|
20
|
+
related_name="is_sample", verbose_name="Product", to="catalog.Product", on_delete=models.CASCADE
|
|
21
|
+
),
|
|
22
|
+
),
|
|
23
|
+
],
|
|
24
|
+
),
|
|
25
|
+
]
|
|
File without changes
|
lfs_samples/models.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
3
|
+
from lfs.catalog.models import Product
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IsSample(models.Model):
|
|
7
|
+
"""
|
|
8
|
+
Stores whether a product is a sample.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
product = models.ForeignKey(Product, verbose_name=_("Product"), related_name="is_sample", on_delete=models.CASCADE)
|
|
12
|
+
|
|
13
|
+
def __str__(self):
|
|
14
|
+
return "{} / {}".format(self.product.id, self.product.get_name())
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ActivityState(models.Model):
|
|
18
|
+
"""
|
|
19
|
+
Stores whether a variant has activated samples.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
product = models.ForeignKey(
|
|
23
|
+
Product, verbose_name=_("Product"), related_name="active_samples", on_delete=models.CASCADE
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ProductSamplesRelation(models.Model):
|
|
28
|
+
"""
|
|
29
|
+
Relates samples to products.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
product = models.ForeignKey(Product, verbose_name=_("Product"), related_name="products", on_delete=models.CASCADE)
|
|
33
|
+
sample = models.ForeignKey(Product, verbose_name=_("Sample"), related_name="samples", on_delete=models.CASCADE)
|
|
34
|
+
|
|
35
|
+
def __str__(self):
|
|
36
|
+
return "{} / {} <- {} / {}".format(
|
|
37
|
+
self.product.id, self.product.get_name(), self.sample.id, self.sample.get_name()
|
|
38
|
+
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{% load i18n %}
|
|
2
|
+
{% load lfs_manage_tags lfs_samples_tags %}
|
|
3
|
+
|
|
4
|
+
<div id="samples">
|
|
5
|
+
<h2 class="heading-first">{% trans 'Samples' %}</h2>
|
|
6
|
+
|
|
7
|
+
<form id="samples-update-form"
|
|
8
|
+
action="{% url 'lfs_manage_update_is_sample' product.id %}"
|
|
9
|
+
method="post">
|
|
10
|
+
<input type="checkbox"
|
|
11
|
+
name="is_sample"
|
|
12
|
+
{% if is_sample %}checked="checked"{% endif %} />
|
|
13
|
+
<label for="is_sample">
|
|
14
|
+
{% trans 'Is sample' %}
|
|
15
|
+
</label>
|
|
16
|
+
<input class="ajax-save-button"
|
|
17
|
+
type="submit" value="{% trans "Update" %}" />
|
|
18
|
+
</form>
|
|
19
|
+
|
|
20
|
+
{% if not product.is_sample.exists %}
|
|
21
|
+
<hr style="margin: 20px 0" />
|
|
22
|
+
{% if product.is_variant %}
|
|
23
|
+
<form id="samples-update-form"
|
|
24
|
+
action="{% url 'lfs_manage_update_samples_state' product.id %}"
|
|
25
|
+
method="post">
|
|
26
|
+
<input type="checkbox"
|
|
27
|
+
name="samples_activity_state"
|
|
28
|
+
{% if has_active_samples %}checked="checked"{% endif %} />
|
|
29
|
+
<label for="active_samples">
|
|
30
|
+
{% trans 'Active samples' %}
|
|
31
|
+
</label>
|
|
32
|
+
<input class="ajax-save-button"
|
|
33
|
+
type="submit" value="{% trans "Update" %}" />
|
|
34
|
+
</form>
|
|
35
|
+
<div class="separator"></div>
|
|
36
|
+
{% endif %}
|
|
37
|
+
|
|
38
|
+
<form id="filter-samples-form"
|
|
39
|
+
action="{% url 'lfs_manage_samples_inline' product.id %}"
|
|
40
|
+
onsubmit="return false">
|
|
41
|
+
<input class="refresh-on-keyup" type="text" name="filter"/>
|
|
42
|
+
|
|
43
|
+
{% category_filter "refresh-on-change" "samples_category_filter" %}
|
|
44
|
+
|
|
45
|
+
<select class="refresh-on-change"
|
|
46
|
+
name="samples-amount">
|
|
47
|
+
{% for option in amount_options %}
|
|
48
|
+
<option {% if option.selected %}selected="selected"{% endif %}
|
|
49
|
+
value="{{ option.value }}">{{ option.value }}</option>
|
|
50
|
+
{% endfor %}
|
|
51
|
+
</select>
|
|
52
|
+
|
|
53
|
+
</form>
|
|
54
|
+
{{ samples_inline }}
|
|
55
|
+
{% endif %}
|
|
56
|
+
</div>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
{% load i18n lfs_tags static %}
|
|
2
|
+
|
|
3
|
+
<div id="samples-inline">
|
|
4
|
+
<div class="navigation-pages-inline">
|
|
5
|
+
{% if page.has_previous %}
|
|
6
|
+
<a class="ajax-link"
|
|
7
|
+
href="{% url 'lfs_manage_samples_inline' product.id%}?page=1"><img src="{% static 'lfs/icons/resultset_first.png' %}" alt='{% trans "First" %}' /></a>
|
|
8
|
+
<a class="ajax-link"
|
|
9
|
+
href="{% url 'lfs_manage_samples_inline' product.id%}?page={{ page.previous_page_number }}"><img src="{% static 'lfs/icons/resultset_previous.png' %}" alt='{% trans "Previous" %}' /></a>
|
|
10
|
+
{% else %}
|
|
11
|
+
<img src="{% static 'lfs/icons/resultset_first.png' %}" alt='{% trans "First" %}' />
|
|
12
|
+
<img src="{% static 'lfs/icons/resultset_previous.png' %}" alt='{% trans "Previous" %}' /></span>
|
|
13
|
+
{% endif %}
|
|
14
|
+
<span style="position: relative; top:-4px ">
|
|
15
|
+
{{ page.number }} {% trans "of" %} {{ paginator.num_pages }}
|
|
16
|
+
</span>
|
|
17
|
+
{% if page.has_next %}
|
|
18
|
+
<a class="ajax-link"
|
|
19
|
+
href="{% url 'lfs_manage_samples_inline' product.id %}?page={{ page.next_page_number }}"><img src="{% static 'lfs/icons/resultset_next.png' %}" alt="{% trans 'Next' %}" alt="{% trans 'Next' %}" /></a>
|
|
20
|
+
<a class="ajax-link"
|
|
21
|
+
href="{% url 'lfs_manage_samples_inline' product.id %}?page={{ paginator.num_pages }}"><img src="{% static 'lfs/icons/resultset_last.png' %}" alt='{% trans "Last" %}' /></a>
|
|
22
|
+
{% else %}
|
|
23
|
+
<span><img src="{% static 'lfs/icons/resultset_next.png' %}" alt='{% trans "Next" %}' /></span>
|
|
24
|
+
<span><img src="{% static 'lfs/icons/resultset_last.png' %}" alt='{% trans "Last" %}' /></span>
|
|
25
|
+
{% endif %}
|
|
26
|
+
</div>
|
|
27
|
+
<table class="lfs-manage-table" style="margin-top:20px">
|
|
28
|
+
<tr>
|
|
29
|
+
<td width="50%">
|
|
30
|
+
<h2>{% trans "Selectable Samples" %}</h2>
|
|
31
|
+
<form id="add-samples-form"
|
|
32
|
+
action="{% url 'lfs_manage_add_samples' product.id %}"
|
|
33
|
+
method="post">
|
|
34
|
+
|
|
35
|
+
<div id="samples-left" style="padding-bottom:10px">
|
|
36
|
+
<table class="lfs-manage-table">
|
|
37
|
+
<tr>
|
|
38
|
+
<th class="checkbox">
|
|
39
|
+
<input type="checkbox"
|
|
40
|
+
class="select-all"
|
|
41
|
+
value="samples" />
|
|
42
|
+
</th>
|
|
43
|
+
<th class="middle">
|
|
44
|
+
{% trans 'Name' %}
|
|
45
|
+
</th>
|
|
46
|
+
<th>
|
|
47
|
+
{% trans 'SKU' %}
|
|
48
|
+
</th>
|
|
49
|
+
<th class="tiny right-padding">
|
|
50
|
+
{% trans 'Active' %}
|
|
51
|
+
</th>
|
|
52
|
+
</tr>
|
|
53
|
+
{% for product in page.object_list %}
|
|
54
|
+
<tr class="{% cycle 'even' 'odd' %}">
|
|
55
|
+
<td>
|
|
56
|
+
<input type="checkbox"
|
|
57
|
+
name="product-{{ product.id }}"
|
|
58
|
+
class="select-samples" />
|
|
59
|
+
</td>
|
|
60
|
+
<td>
|
|
61
|
+
<a href="{% url 'lfs_manage_product_data' product.id %}">
|
|
62
|
+
{{ product.get_name }}
|
|
63
|
+
</a>
|
|
64
|
+
<div class="product-properties-info">
|
|
65
|
+
{% include "lfs/catalog/products/_product_properties.html" with product=product %}
|
|
66
|
+
</div>
|
|
67
|
+
</td>
|
|
68
|
+
<td>
|
|
69
|
+
{{ product.get_sku }}
|
|
70
|
+
</td>
|
|
71
|
+
<td class="right-padding">
|
|
72
|
+
{% if product.is_active %}
|
|
73
|
+
<img src="{% static 'lfs/icons/tick.png' %}" />
|
|
74
|
+
{% else %}
|
|
75
|
+
<img src="{% static 'lfs/icons/cross.png' %}" />
|
|
76
|
+
{% endif %}
|
|
77
|
+
</td>
|
|
78
|
+
</tr>
|
|
79
|
+
{% endfor %}
|
|
80
|
+
</table>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<input type="hidden"
|
|
84
|
+
name="keep-filters"
|
|
85
|
+
value="1" />
|
|
86
|
+
|
|
87
|
+
<input type="submit"
|
|
88
|
+
class="ajax-save-button button"
|
|
89
|
+
value="{% trans 'Add to samples' %}" />
|
|
90
|
+
|
|
91
|
+
</form>
|
|
92
|
+
</td>
|
|
93
|
+
<td width="50%">
|
|
94
|
+
<h2>{% trans "Selected Samples" %}</h2>
|
|
95
|
+
<form id="remove-samples-form"
|
|
96
|
+
action="{% url 'lfs_manage_remove_samples' product.id %}"
|
|
97
|
+
method="post">
|
|
98
|
+
<div id="samples-right" style="padding-bottom:10px">
|
|
99
|
+
<table class="lfs-manage-table">
|
|
100
|
+
<tr>
|
|
101
|
+
<th class="checkbox">
|
|
102
|
+
<input type="checkbox"
|
|
103
|
+
class="select-all"
|
|
104
|
+
value="selected-samples" />
|
|
105
|
+
</th>
|
|
106
|
+
<th class="middle">
|
|
107
|
+
{% trans 'Name' %}
|
|
108
|
+
</th>
|
|
109
|
+
<th>
|
|
110
|
+
{% trans 'SKU' %}
|
|
111
|
+
</th>
|
|
112
|
+
<th class="tiny right-padding">
|
|
113
|
+
{% trans 'Active' %}
|
|
114
|
+
</th>
|
|
115
|
+
</tr>
|
|
116
|
+
|
|
117
|
+
{% for sample in samples %}
|
|
118
|
+
<tr class="{% cycle 'even' 'odd' %}">
|
|
119
|
+
<td>
|
|
120
|
+
<input type="checkbox"
|
|
121
|
+
name="product-{{ sample.id }}"
|
|
122
|
+
class="select-selected-samples" />
|
|
123
|
+
</td>
|
|
124
|
+
<td>
|
|
125
|
+
<a href="{% url 'lfs_manage_product_data' sample.id %}">
|
|
126
|
+
{{ sample.get_name }}
|
|
127
|
+
</a>
|
|
128
|
+
<div class="product-properties-info">
|
|
129
|
+
{% include "lfs/catalog/products/_product_properties.html" with product=sample %}
|
|
130
|
+
</div>
|
|
131
|
+
</td>
|
|
132
|
+
<td>
|
|
133
|
+
{{ sample.get_sku }}
|
|
134
|
+
</td>
|
|
135
|
+
<td class="right-padding">
|
|
136
|
+
{% if sample.is_active %}
|
|
137
|
+
<img src="{% static 'lfs/icons/tick.png' %}" />
|
|
138
|
+
{% else %}
|
|
139
|
+
<img src="{% static 'lfs/icons/cross.png' %}" />
|
|
140
|
+
{% endif %}
|
|
141
|
+
</td>
|
|
142
|
+
</tr>
|
|
143
|
+
{% endfor %}
|
|
144
|
+
</table>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<input type="hidden"
|
|
148
|
+
name="keep-filters"
|
|
149
|
+
value="1" />
|
|
150
|
+
|
|
151
|
+
<input type="submit"
|
|
152
|
+
class="ajax-save-button button"
|
|
153
|
+
value="{% trans 'Remove from samples' %}" />
|
|
154
|
+
</form>
|
|
155
|
+
</td>
|
|
156
|
+
</tr>
|
|
157
|
+
</table>
|
|
158
|
+
</div>
|
|
159
|
+
<script>
|
|
160
|
+
align_buttons("#samples");
|
|
161
|
+
</script>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{% load i18n static %}
|
|
2
|
+
|
|
3
|
+
<!-- Assigned Samples Form -->
|
|
4
|
+
<form id="remove-samples-form"
|
|
5
|
+
hx-post="{% url 'lfs_manage_product_samples' product.id %}"
|
|
6
|
+
hx-target="#samples-tables"
|
|
7
|
+
hx-select="#samples-tables"
|
|
8
|
+
hx-swap="outerHTML">
|
|
9
|
+
{% csrf_token %}
|
|
10
|
+
<input type="hidden" name="action" value="remove">
|
|
11
|
+
<input type="hidden" name="keep-filters" value="1">
|
|
12
|
+
<input type="hidden" name="filter" value="{{ filter }}">
|
|
13
|
+
<input type="hidden" name="category_filter" value="{{ category_filter }}">
|
|
14
|
+
<input type="hidden" name="amount" value="{{ amount }}">
|
|
15
|
+
|
|
16
|
+
<div id="assigned-samples-list" class="card shadow" style="height: calc(100vh - 450px);">
|
|
17
|
+
<div class="card-header bg-primary-subtle d-flex justify-content-between align-items-center">
|
|
18
|
+
<h2 class="h4 mb-0">
|
|
19
|
+
<i class="bi bi-check-circle me-2"></i>
|
|
20
|
+
{% trans 'Selected Samples' %}
|
|
21
|
+
</h2>
|
|
22
|
+
<i class="bi bi-question-circle text-muted me-2"
|
|
23
|
+
data-bs-toggle="popover"
|
|
24
|
+
data-bs-placement="top"
|
|
25
|
+
data-bs-content="{% trans 'Samples are products that are offered as samples for this product.' %}"
|
|
26
|
+
data-bs-trigger="hover"
|
|
27
|
+
style="cursor: help; font-size: 1.25rem;"></i>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="card-body overflow-y-auto">
|
|
30
|
+
{% if samples %}
|
|
31
|
+
<div class="table-responsive">
|
|
32
|
+
<table class="table table-sm table-hover">
|
|
33
|
+
<thead>
|
|
34
|
+
<tr>
|
|
35
|
+
<th class="checkbox" style="width: 40px;">
|
|
36
|
+
<input type="checkbox" class="form-check-input select-all-assigned-samples" />
|
|
37
|
+
</th>
|
|
38
|
+
<th>{% trans 'Name' %}</th>
|
|
39
|
+
<th class="small">{% trans 'SKU' %}</th>
|
|
40
|
+
<th class="small">{% trans 'Active' %}</th>
|
|
41
|
+
</tr>
|
|
42
|
+
</thead>
|
|
43
|
+
<tbody>
|
|
44
|
+
{% for sample in samples %}
|
|
45
|
+
<tr>
|
|
46
|
+
<td>
|
|
47
|
+
<input type="checkbox"
|
|
48
|
+
name="sample-{{ sample.id }}"
|
|
49
|
+
class="form-check-input select-assigned-sample" />
|
|
50
|
+
</td>
|
|
51
|
+
<td>
|
|
52
|
+
<a href="{% url 'lfs_manage_product_data' sample.id %}" class="text-decoration-none">
|
|
53
|
+
{{ sample.get_name }}
|
|
54
|
+
</a>
|
|
55
|
+
</td>
|
|
56
|
+
<td class="small text-muted">
|
|
57
|
+
{{ sample.get_sku|default:"---" }}
|
|
58
|
+
</td>
|
|
59
|
+
<td class="text-center align-middle">
|
|
60
|
+
{% if sample.is_active %}
|
|
61
|
+
<i class="bi bi-check-circle-fill text-success"></i>
|
|
62
|
+
{% else %}
|
|
63
|
+
<i class="bi bi-x-circle-fill text-danger"></i>
|
|
64
|
+
{% endif %}
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
{% endfor %}
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
</div>
|
|
71
|
+
{% else %}
|
|
72
|
+
<div class="text-center text-muted py-4">
|
|
73
|
+
<i class="bi bi-tag fs-1 d-block mb-3"></i>
|
|
74
|
+
<p>{% trans "No samples assigned." %}</p>
|
|
75
|
+
<p class="small">{% trans "Select products from the left panel and add them as samples." %}</p>
|
|
76
|
+
</div>
|
|
77
|
+
{% endif %}
|
|
78
|
+
</div>
|
|
79
|
+
<div class="card-footer" style="min-height: 60px;">
|
|
80
|
+
{% if samples %}
|
|
81
|
+
<button type="submit" class="btn btn-danger">
|
|
82
|
+
<i class="bi bi-trash me-1"></i>
|
|
83
|
+
{% trans 'Remove from samples' %}
|
|
84
|
+
</button>
|
|
85
|
+
{% endif %}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</form>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{% load i18n static %}
|
|
2
|
+
|
|
3
|
+
<!-- Available Samples Form -->
|
|
4
|
+
<form id="add-samples-form"
|
|
5
|
+
hx-post="{% url 'lfs_manage_product_samples' product.id %}"
|
|
6
|
+
hx-target="#samples-tables"
|
|
7
|
+
hx-select="#samples-tables"
|
|
8
|
+
hx-swap="outerHTML">
|
|
9
|
+
{% csrf_token %}
|
|
10
|
+
<input type="hidden" name="action" value="add">
|
|
11
|
+
<input type="hidden" name="keep-filters" value="1">
|
|
12
|
+
<input type="hidden" name="filter" value="{{ filter }}">
|
|
13
|
+
<input type="hidden" name="category_filter" value="{{ category_filter }}">
|
|
14
|
+
<input type="hidden" name="amount" value="{{ amount }}">
|
|
15
|
+
|
|
16
|
+
<div id="available-samples-list" class="card shadow" style="height: calc(100vh - 450px);">
|
|
17
|
+
<div class="card-header bg-primary-subtle">
|
|
18
|
+
<div class="d-flex justify-content-between align-items-center">
|
|
19
|
+
<h2 class="h4 mb-0">
|
|
20
|
+
<i class="bi bi-box me-2"></i>
|
|
21
|
+
{% trans 'Selectable Samples' %}
|
|
22
|
+
</h2>
|
|
23
|
+
<!-- Pagination -->
|
|
24
|
+
{% if available_page and available_page.has_other_pages %}
|
|
25
|
+
{% include 'manage/snippets/pagination.html' with page_obj=available_page url_name='lfs_manage_product_samples' url_params=product.id page_info_position='beside' %}
|
|
26
|
+
{% endif %}
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="card-body overflow-y-auto">
|
|
30
|
+
{% if available_page and available_page.object_list %}
|
|
31
|
+
<div class="table-responsive">
|
|
32
|
+
<table class="table table-sm table-hover">
|
|
33
|
+
<thead>
|
|
34
|
+
<tr>
|
|
35
|
+
<th class="checkbox" style="width: 40px;">
|
|
36
|
+
<input type="checkbox" class="form-check-input select-all-available-samples" />
|
|
37
|
+
</th>
|
|
38
|
+
<th>{% trans 'Name' %}</th>
|
|
39
|
+
<th class="small">{% trans 'SKU' %}</th>
|
|
40
|
+
<th class="small">{% trans 'Active' %}</th>
|
|
41
|
+
</tr>
|
|
42
|
+
</thead>
|
|
43
|
+
<tbody>
|
|
44
|
+
{% for p in available_page.object_list %}
|
|
45
|
+
<tr>
|
|
46
|
+
<td>
|
|
47
|
+
<input type="checkbox"
|
|
48
|
+
name="product-{{ p.id }}"
|
|
49
|
+
class="form-check-input select-available-sample" />
|
|
50
|
+
</td>
|
|
51
|
+
<td>
|
|
52
|
+
<a href="{% url 'lfs_manage_product_data' p.id %}" class="text-decoration-none">
|
|
53
|
+
{{ p.get_name }}
|
|
54
|
+
</a>
|
|
55
|
+
</td>
|
|
56
|
+
<td class="small text-muted">
|
|
57
|
+
{{ p.get_sku|default:"---" }}
|
|
58
|
+
</td>
|
|
59
|
+
<td class="text-center align-middle">
|
|
60
|
+
{% if p.is_active %}
|
|
61
|
+
<i class="bi bi-check-circle-fill text-success"></i>
|
|
62
|
+
{% else %}
|
|
63
|
+
<i class="bi bi-x-circle-fill text-danger"></i>
|
|
64
|
+
{% endif %}
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
{% endfor %}
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
</div>
|
|
71
|
+
{% else %}
|
|
72
|
+
<div class="text-center text-muted py-4">
|
|
73
|
+
<i class="bi bi-search fs-1 d-block mb-3"></i>
|
|
74
|
+
<p>{% trans "No products found." %}</p>
|
|
75
|
+
<p class="small">{% trans "Only products marked as sample can be assigned." %}</p>
|
|
76
|
+
</div>
|
|
77
|
+
{% endif %}
|
|
78
|
+
</div>
|
|
79
|
+
<div class="card-footer" style="min-height: 60px;">
|
|
80
|
+
{% if available_page and available_page.object_list %}
|
|
81
|
+
<button type="submit" class="btn btn-primary">
|
|
82
|
+
<i class="bi bi-plus-circle me-1"></i>
|
|
83
|
+
{% trans 'Add to samples' %}
|
|
84
|
+
</button>
|
|
85
|
+
{% endif %}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</form>
|