89fR20">20
+{% include "fruit/_searchcenter.html" %}
21
+<hr>
22
+<table class='table table-borded table-striped'>
23
+    <thead>
24
+        <tr>
25
+            <th>ID</th>
26
+            <th>Name</th>
27
+            <th>Products</th>
28
+            <th>Price</th>
29
+            <th>Detail</th>
30
+            <th>Tel</th>
31
+            <th>Email</th>
32
+            <th>LineId</th>
33
+            <th>Created At</th></tr>
34
+    </thead>
35
+    <tbody>
36
+{% for p in page_obj %}
37
+        <tr>
38
+            <td><a href="{% url "fruit:vendor_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.product }}</td>
39
+            <td>{{ p.name }}</td>
40
+            <td>{{ p.products }}</td>
41
+            <td>{{ p.price }}</td>
42
+            <td>{{ p.detail }}</td>
43
+            <td>{{ p.tel }}</td>
44
+            <td>{{ p.email }}</td>
45
+            <td>{{ p.line_id }}</td>
46
+            <td>{{ p.created_at }}</td>
47
+        </tr>
48
+{% endfor %}
49
+    </tbody>
50
+</table>
51
+{% include "fruit/_paging.html" %}
52
+{% endblock %}

+ 25 - 0
app/fruit/templates/fruit/vendororder_form.html

@@ -0,0 +1,25 @@
1
+{% extends "fruit/vendororder_index.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+{% load django_bootstrap_breadcrumbs %}
5
+
6
+{% block header %}            
7
+{{ form.media  }}
8
+{% endblock %}
9
+
10
+{% block breadcrumbs %}
11
+    {{ block.super }}
12
+    {% breadcrumb "Vendor Order Form" "fruit:vendororder_edit" form.instance.pk %}
13
+{% endblock %}
14
+
15
+{% block store_main %}
16
+<h2>Vendor Order Form</h2>
17
+<form  method="post" enctype="multipart/form-data">
18
+    {% csrf_token %}
19
+    {{ form | crispy  }}
20
+    <br>
21
+    <input type='submit' class='btn btn-primary' value="Update" />
22
+
23
+</form>
24
+
25
+{% endblock %}

+ 47 - 0
app/fruit/templates/fruit/vendororder_index.html

@@ -0,0 +1,47 @@
1
+{% extends "fruit/mystore.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+
5
+{% block header %}            
6
+{% endblock %}
7
+
8
+{% load django_bootstrap_breadcrumbs %}
9
+{% block breadcrumbs %}
10
+    {{ block.super }}
11
+    {% breadcrumb "Vendor Orders" "fruit:vendororder_index" %}
12
+{% endblock %}
13
+
14
+{% block store_main %}
15
+
16
+<a  class='btn btn-primary' href="{% url "fruit:vendororder_create" %}">Create Vendor Order</a>
17
+<hr>
18
+<h2>
19
+    Vendor Order Index</h2>
20
+{% include "fruit/_searchcenter.html" %}
21
+<hr>
22
+<table class='table table-borded table-striped'>
23
+    <thead>
24
+        <tr>
25
+            <th>ID</th>
26
+            <th>Vendor</th>
27
+            <th>Product</th>
28
+            <th>Price</th>
29
+            <th>Unit</th>
30
+            <th>Total</th>
31
+            <th>Created At</th></tr>
32
+    </thead>
33
+    <tbody>
34
+{% for p in page_obj %}
35
+        <tr>
36
+            <td><a href="{% url "fruit:vendororder_edit" pk=p.pk %}">{{ p.id }}</a></td><td>{{ p.vendor }}</td>
37
+            <td>{{ p.product }}</td>
38
+            <td>{{ p.price }}</td>
39
+            <td>{{ p.unit }}</td>
40
+            <td>{{ p.total }}</td>
41
+            <td>{{ p.created_at }}</td>
42
+        </tr>
43
+{% endfor %}
44
+    </tbody>
45
+</table>
46
+{% include "fruit/_paging.html" %}
47
+{% endblock %}

+ 27 - 0
app/fruit/templates/fruit/vendorproduct_form.html

@@ -0,0 +1,27 @@
1
+{% extends "fruit/vendor_form.html" %}
2
+{% load static %}
3
+{% load crispy_forms_tags %}
4
+{% load django_bootstrap_breadcrumbs %}
5
+
6
+{% block header %}            
7
+{{ form.media  }}
8
+{{ form2.media }}
9
+{% endblock %}
10
+
11
+{% block breadcrumbs %}
12
+    {{ block.super }}
13
+    {% breadcrumb "Vendor Product Form" "fruit:vendorproduct_edit" form.instance.pk %}
14
+{% endblock %}
15
+
16
+{% block store_main %}
17
+<h2>Vendor Product  Form</h2>
18
+<form  method="post" enctype="multipart/form-data">
19
+    {% csrf_token %}
20
+    {{ form | crispy  }}
21
+    <hr>
22
+    <br>
23
+    <input type='submit' class='btn btn-primary' value="Update" />
24
+
25
+</form>
26
+
27
+{% endblock %}

+ 8 - 0
app/fruit/urls.py

@@ -15,6 +15,14 @@ urlpatterns = [
15 15
     path('sales/<pk>', views.sale_edit, name='sale_edit'),
16 16
     path('inbox/', views.inbox_index, name='inbox_index'),
17 17
     path('inbox/<pk>', views.inbox_edit, name='inbox_edit'),
18
+    path('vendor/', views.vendor_index, name='vendor_index'),
19
+    path('vendor/create', views.vendor_create, name='vendor_create'),
20
+    path('vendor/<pk>', views.vendor_edit, name='vendor_edit'),
21
+    path('vendor/<pk>/product/create', views.vendorproduct_create, name='vendorproduct_create'),
22
+    path('vendorproduct/<pk>', views.vendorproduct_edit, name='vendorproduct_edit'),
23
+    path('vendororder/', views.vendororder_index, name='vendororder_index'),
24
+    path('vendororder/create', views.vendororder_create, name='vendororder_create'),
25
+    path('vendororder/<pk>', views.vendororder_edit, name='vendororder_edit'),
18 26
     path('signup', views.signup, name='signup'),
19 27
 ]
20 28
 

+ 228 - 3
app/fruit/views.py

@@ -6,8 +6,9 @@ from django.contrib.auth.forms import UserCreationForm
6 6
 from django.urls import reverse
7 7
 from django.contrib.auth.decorators import login_required
8 8
 
9
-from fruit.models import Store, Product, Photo, ProductSKU, Sale, Inbox
10
-from .forms import StoreForm, ProductForm, InboxForm, SaleForm,  PhotoFormSet, InlinePhotoFormset, ProductSKUForm, ProductFilter, SaleFilter, InboxFilter
9
+from fruit.models import Store, Product, Photo, ProductSKU, Sale, Inbox, Vendor, VendorProduct
10
+
11
+from .forms import StoreForm, ProductForm, InboxForm, SaleForm,  PhotoFormSet,VendorFilter,  InlinePhotoFormset, ProductSKUForm, ProductFilter, SaleFilter, InboxFilter, VendorForm, VendorOrderForm, VendorOrderFilter, VendorOrder, InlineVendorProductFormset, VendorProductForm
11 12
 from django.contrib import messages
12 13
 from django.core.paginator import Paginator
13 14
 
@@ -115,7 +116,7 @@ def create_sku(request, pk):
115 116
             messages.success(request, "Product Save")
116 117
             return redirect("fruit:edit_sku", pk=i.pk)
117 118
         else:
118
-            message.error(request, "SKU  created failed")
119
+            messages.error(request, form.errors)
119 120
             return redirect("fruit:create_sku", pk=int(pk))
120 121
 
121 122
     return render(request, 'fruit/sku_form.html', {'form': form, 'pid': p.pk})
@@ -245,6 +246,230 @@ def inbox_edit(request, pk):
245 246
 
246 247
     return render(request, 'fruit/inbox_form.html', {'inbox_active': True, 'form': form, 'object': obj})
247 248
 
249
+@login_required
250
+def vendor_index(request):
251
+    stores = request.user.store_created.all().order_by("-created_at")
252
+    o_qs = stores[0].vendor_set.all().order_by("-created_at")
253
+
254
+    f = VendorFilter(request.GET, queryset=o_qs)
255
+
256
+    paginator = Paginator(f.qs, 25)
257
+    page_number = request.GET.get('page')
258
+    page_obj = paginator.get_page(page_number)
259
+
260
+    return render(request, 'fruit/vendor_index.html', {'o_qs': o_qs, 'vendor_active': True, 'page_obj': page_obj, 'filter': f})
261
+
262
+@login_required
263
+def vendor_edit(request, pk):
264
+    stores = request.user.store_created.all().order_by("-created_at")
265
+
266
+    obj = Vendor.objects.get(pk=pk)
267
+    form = VendorForm(instance = obj)
268
+    form2 = InlineVendorProductFormset(instance = obj)
269
+    for f in form2:
270
+        f.fields['product'].queryset = stores[0].product_set.all().order_by("-created_at")
271
+
272
+    if request.method == "POST":
273
+        form = VendorForm(request.POST)
274
+        form2 = InlineVendorProductFormset(request.POST, instance = obj)
275
+        if form.is_valid() and form2.is_valid():
276
+            instance1 = form.save()
277
+            instance2 = form2.save(commit=False)
278
+
279
+            for i in instance2:
280
+                i.created_by = request.user
281
+                i.save()
282
+
283
+            '''
284
+            print(instances)
285
+            for s in instances:
286
+                s.product = instance1
287
+                s.save()
288
+            '''
289
+            messages.success(request, "Vendor Save")
290
+        else:
291
+            print("Invalid ")
292
+            if form.errors:
293
+                messages.error(request, form.errors)
294
+            if form2.errors:
295
+                messages.error(request, form2.errors)
296
+
297
+        return redirect("fruit:vendor_edit", pk =  int(pk))
298
+
299
+    return render(request, 'fruit/vendor_form.html', {'vendor_active': True, 'form': form, 'obj': obj, 'form2': form2})
300
+
301
+@login_required
302
+def vendor_create(request):
303
+    stores = request.user.store_created.all().order_by("-created_at")
304
+
305
+    form = VendorForm()
306
+
307
+    form.fields['products'].queryset = stores[0].product_set.all().order_by("-created_at")
308
+
309
+    if request.method == "POST":
310
+        form = VendorForm(request.POST)
311
+        if form.is_valid():
312
+
313
+            instance1 = form.save(commit=False)
314
+            instance1.store = stores[0]
315
+            instance1.created_by = request.user
316
+            instance1.save()
317
+            '''
318
+            print(instances)
319
+            for s in instances:
320
+                s.product = instance1
321
+                s.save()
322
+            '''
323
+            messages.success(request, "Sale Save")
324
+        else:
325
+            print("Invalid ")
326
+            if form.errors:
327
+                messages.error(request, form.errors)
328
+
329
+        return redirect("fruit:vendor_edit", pk =  instance1.pk)
330
+
331
+    return render(request, 'fruit/vendor_form.html', {'vendor_active': True, 'form': form})
332
+
333
+@login_required
334
+def vendorproduct_create(request, pk):
335
+    stores = request.user.store_created.all().order_by("-created_at")
336
+    print(pk)
337
+    vendor = Vendor.objects.get(pk=pk)
338
+
339
+    form = VendorProductForm()
340
+
341
+    form.fields['product'].queryset = stores[0].product_set.all().order_by("-created_at")
342
+
343
+    if request.method == "POST":
344
+        form = VendorProductForm(request.POST)
345
+        if form.is_valid():
346
+
347
+            instance1 = form.save(commit=False)
348
+            instance1.store = stores[0]
349
+            instance1.vendor = vendor
350
+            instance1.created_by = request.user
351
+            instance1.save()
352
+            '''
353
+            print(instances)
354
+            for s in instances:
355
+                s.product = instance1
356
+                s.save()
357
+            '''
358
+            messages.success(request, "Sale Save")
359
+        else:
360
+            print("Invalid ")
361
+            if form.errors:
362
+                messages.error(request, form.errors)
363
+
364
+        return redirect("fruit:vendorproduct_edit", pk =  instance1.pk)
365
+
366
+    return render(request, 'fruit/vendorproduct_form.html', {'vendor_active': True, 'form': form, 'vendor': vendor})
367
+
368
+@login_required
369
+def vendorproduct_edit(request, pk):
370
+    stores = request.user.store_created.all().order_by("-created_at")
371
+
372
+    obj = VendorProduct.objects.get(pk=pk)
373
+    form = VendorProductForm(instance = obj)
374
+    vendor = obj.vendor
375
+
376
+    form.fields['product'].queryset = stores[0].product_set.all().order_by("-created_at")
377
+
378
+    if request.method == "POST":
379
+        form = VendorProductForm(request.POST)
380
+        if form.is_valid():
381
+            instance1 = form.save()
382
+
383
+            '''
384
+            print(instances)
385
+            for s in instances:
386
+                s.product = instance1
387
+                s.save()
388
+            '''
389
+            messages.success(request, "Vendor Product Save")
390
+        else:
391
+            print("Invalid ")
392
+            if form.errors:
393
+                messages.error(request, form.errors)
394
+
395
+        return redirect("fruit:vendorproduct_edit", pk =  int(pk))
396
+
397
+    return render(request, 'fruit/vendorproduct_form.html', {'vendor_active': True, 'form': form, 'obj': obj, 'vendor': vendor})
398
+
399
+#vendor order
400
+@login_required
401
+def vendororder_index(request):
402
+    stores = request.user.store_created.all().order_by("-created_at")
403
+    o_qs = stores[0].vendororder_set.all().order_by("-created_at")
404
+
405
+    f = VendorOrderFilter(request.GET, queryset=o_qs)
406
+
407
+    paginator = Paginator(f.qs, 25)
408
+    page_number = request.GET.get('page')
409
+    page_obj = paginator.get_page(page_number)
410
+
411
+    return render(request, 'fruit/vendororder_index.html', {'o_qs': o_qs, 'vendor_active': True, 'page_obj': page_obj, 'filter': f})
412
+
413
+
414
+@login_required
415
+def vendororder_edit(request, pk):
416
+    stores = request.user.store_created.all().order_by("-created_at")
417
+
418
+    obj = VendorOrder.objects.get(pk=pk)
419
+    form = VendorOrderForm(instance = obj)
420
+
421
+    #form.fields['product'].queryset = stores[0].product_set.all().order_by("-created_at")
422
+
423
+    if request.method == "POST":
424
+        form = VendorOrderForm(request.POST)
425
+        if form.is_valid():
426
+            instance1 = form.save()
427
+            '''
428
+            print(instances)
429
+            for s in instances:
430
+                s.product = instance1
431
+                s.save()
432
+            '''
433
+            messages.success(request, "Sale Save")
434
+        else:
435
+            print("Invalid ")
436
+            if form.errors:
437
+                messages.error(request, form.errors)
438
+
439
+        return redirect("fruit:vendororder_edit", pk =  int(pk))
440
+
441
+    return render(request, 'fruit/vendororder_form.html', {'vendor_active': True, 'form': form, 'object': obj})
442
+
443
+@login_required
444
+def vendororder_create(request):
445
+    stores = request.user.store_created.all().order_by("-created_at")
446
+
447
+    form = VendorOrderForm()
448
+
449
+
450
+    if request.method == "POST":
451
+        form = VendorOrderForm(request.POST)
452
+        if form.is_valid():
453
+
454
+            instance1 = form.save(commit=False)
455
+            instance1.store = stores[0]
456
+            instance1.save()
457
+            '''
458
+            print(instances)
459
+            for s in instances:
460
+                s.product = instance1
461
+                s.save()
462
+            '''
463
+            messages.success(request, "Vendor Order Save")
464
+            return redirect("fruit:vendororder_edit", pk =  instance1.pk)
465
+        else:
466
+            print("Invalid ")
467
+            if form.errors:
468
+                messages.error(request, form.errors)
469
+
470
+
471
+    return render(request, 'fruit/vendororder_form.html', {'vendororder_active': True, 'form': form})
472
+
248 473
 def signup(request):
249 474
     if request.method == 'POST':
250 475
         form = UserCreationForm(request.POST)

tmt/tiger_frontend - Gogs: Simplico Git Service

Нема описа

golf 77628cf8bf first comm пре 2 година
..
bin 77628cf8bf first comm пре 2 година
man 77628cf8bf first comm пре 2 година
LICENSE-MIT.txt 77628cf8bf first comm пре 2 година
README.md 77628cf8bf first comm пре 2 година
cssesc.js 77628cf8bf first comm пре 2 година
package.json 77628cf8bf first comm пре 2 година

README.md

cssesc Build status Code coverage status

A JavaScript library for escaping CSS strings and identifiers while generating the shortest possible ASCII-only output.

This is a JavaScript library for escaping text for use in CSS strings or identifiers while generating the shortest possible valid ASCII-only output. Here’s an online demo.

A polyfill for the CSSOM CSS.escape() method is available in a separate repository. (In comparison, cssesc is much more powerful.)

Feel free to fork if you see possible improvements!

Installation

Via npm:

npm install cssesc

In a browser:

<script src="cssesc.js"></script>

In Node.js:

const cssesc = require('cssesc');

In Ruby using the ruby-cssesc wrapper gem:

gem install ruby-cssesc
require 'ruby-cssesc'
CSSEsc.escape('I ♥ Ruby', is_identifier: true)

In Sass using sassy-escape:

gem install sassy-escape
body {
  content: escape('I ♥ Sass', $is-identifier: true);
}

API

cssesc(value, options)

This function takes a value and returns an escaped version of the value where any characters that are not printable ASCII symbols are escaped using the shortest possible (but valid) escape sequences for use in CSS strings or identifiers.

cssesc('Ich ♥ Bücher');
// → 'Ich \\2665  B\\FC cher'

cssesc('foo 𝌆 bar');
// → 'foo \\1D306  bar'

By default, cssesc returns a string that can be used as part of a CSS string. If the target is a CSS identifier rather than a CSS string, use the isIdentifier: true setting (see below).

The optional options argument accepts an object with the following options:

isIdentifier

The default value for the isIdentifier option is false. This means that the input text will be escaped for use in a CSS string literal. If you want to use the result as a CSS identifier instead (in a selector, for example), set this option to true.

cssesc('123a2b');
// → '123a2b'

cssesc('123a2b', {
  'isIdentifier': true
});
// → '\\31 23a2b'

quotes

The default value for the quotes option is 'single'. This means that any occurences of ' in the input text will be escaped as \', so that the output can be used in a CSS string literal wrapped in single quotes.

cssesc('Lorem ipsum "dolor" sit \'amet\' etc.');
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."

cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
  'quotes': 'single'
});
// → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.'
// → "Lorem ipsum \"dolor\" sit \\'amet\\' etc."

If you want to use the output as part of a CSS string literal wrapped in double quotes, set the quotes option to 'double'.

cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
  'quotes': 'double'
});
// → 'Lorem ipsum \\"dolor\\" sit \'amet\' etc.'
// → "Lorem ipsum \\\"dolor\\\" sit 'amet' etc."

wrap

The wrap option takes a boolean value (true or false), and defaults to false (disabled). When enabled, the output will be a valid CSS string literal wrapped in quotes. The type of quotes can be specified through the quotes setting.

cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
  'quotes': 'single',
  'wrap': true
});
// → '\'Lorem ipsum "dolor" sit \\\'amet\\\' etc.\''
// → "\'Lorem ipsum \"dolor\" sit \\\'amet\\\' etc.\'"

cssesc('Lorem ipsum "dolor" sit \'amet\' etc.', {
  'quotes': 'double',
  'wrap': true
});
// → '"Lorem ipsum \\"dolor\\" sit \'amet\' etc."'
// → "\"Lorem ipsum \\\"dolor\\\" sit \'amet\' etc.\""

escapeEverything

The escapeEverything option takes a boolean value (true or false), and defaults to false (disabled). When enabled, all the symbols in the output will be escaped, even printable ASCII symbols.

cssesc('lolwat"foo\'bar', {
  'escapeEverything': true
});
// → '\\6C\\6F\\6C\\77\\61\\74\\"\\66\\6F\\6F\\\'\\62\\61\\72'
// → "\\6C\\6F\\6C\\77\\61\\74\\\"\\66\\6F\\6F\\'\\62\\61\\72"

Overriding the default options globally

The global default settings can be overridden by modifying the css.options object. This saves you from passing in an options object for every call to encode if you want to use the non-default setting.

// Read the global default setting for `escapeEverything`:
cssesc.options.escapeEverything;
// → `false` by default

// Override the global default setting for `escapeEverything`:
cssesc.options.escapeEverything = true;

// Using the global default setting for `escapeEverything`, which is now `true`:
cssesc('foo © bar ≠ baz 𝌆 qux');
// → '\\66\\6F\\6F\\ \\A9\\ \\62\\61\\72\\ \\2260\\ \\62\\61\\7A\\ \\1D306\\ \\71\\75\\78'

cssesc.version

A string representing the semantic version number.

Using the cssesc binary

To use the cssesc binary in your shell, simply install cssesc globally using npm:

npm install -g cssesc

After that you will be able to escape text for use in CSS strings or identifiers from the command line:

$ cssesc 'föo ♥ bår 𝌆 baz'
f\F6o \2665  b\E5r \1D306  baz

If the output needs to be a CSS identifier rather than part of a string literal, use the -i/--identifier option:

$ cssesc --identifier 'föo ♥ bår 𝌆 baz'
f\F6o\ \2665\ b\E5r\ \1D306\ baz

See cssesc --help for the full list of options.

Support

This library supports the Node.js and browser versions mentioned in .babelrc. For a version that supports a wider variety of legacy browsers and environments out-of-the-box, see v0.1.0.

Author

twitter/mathias
Mathias Bynens

License

This library is available under the MIT license.