This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="dashboard-container columns_2 cf"> | |
| <div class="dashboard-column-wrapper"> | |
| <div class="dashboard-column ui-droppable ui-sortable"> | |
| <div class="dashboard-item collapsible "> | |
| <div class="dashboard-item-header ui-sortable-handle"> | |
| <span class="dashboard-item-header-buttons"></span> | |
| <span class="dashboard-item-header-title">test</span> | |
| <div class="cf"></div> | |
| </div> | |
| <div class="dashboard-item-content" style="height: auto;"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| order_item_ids = [q.get('id') for q in queryset] | |
| kitpart_orderitem_ids = [oid.get('item') for oid in OrderItemDetail.objects.values('item').filter(name='kitparent', id__in=order_item_ids)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Entity value belonging to multiple entities. caesar = food_dressing, food_salad_special. | |
| App should recognizes that we want the salad | |
| Expected flow: | |
| user: "large caesar" | |
| alexa: "Ok, I added one large caesar" | |
| 2. "ambiguous" entity asks for clarification | |
| Expected flow: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| client = boto3.client( | |
| 's3', | |
| aws_access_key_id = settings.AWS_ACCESS_KEY_ID, | |
| aws_secret_access_key = settings.AWS_SECRET_ACCESS_KEY, | |
| ) | |
| dst = 'media/temp_pdf/somefile.jpg' # This is the destination path inside the bucket | |
| client.upload_file('/my/local/somefile.jpg', 'mybucketname', dst) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from django.contrib.auth.management import _get_all_permissions | |
| from django.contrib.auth.models import Permission | |
| from django.contrib.contenttypes.models import ContentType | |
| from django.core.management.base import BaseCommand | |
| from django.apps import apps | |
| from django.utils.encoding import smart_unicode | |
| class Command(BaseCommand): | |
| help = "Fix permissions for proxy models." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT 'postgresql' AS dbms,t.table_catalog,t.table_schema,t.table_name,c.column_name,c.ordinal_position,c.data_type,c.character_maximum_length,n.constraint_type,k2.table_schema,k2.table_name,k2.column_name FROM information_schema.tables t NATURAL LEFT JOIN information_schema.columns c LEFT JOIN(information_schema.key_column_usage k NATURAL JOIN information_schema.table_constraints n NATURAL LEFT JOIN information_schema.referential_constraints r)ON c.table_catalog=k.table_catalog AND c.table_schema=k.table_schema AND c.table_name=k.table_name AND c.column_name=k.column_name LEFT JOIN information_schema.key_column_usage k2 ON k.position_in_unique_constraint=k2.ordinal_position AND r.unique_constraint_catalog=k2.constraint_catalog AND r.unique_constraint_schema=k2.constraint_schema AND r.unique_constraint_name=k2.constraint_name WHERE t.TABLE_TYPE='BASE TABLE' AND t.table_schema NOT IN('information_schema','pg_catalog') \g /tmp/er.txt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mc(): | |
| from mailchimp3 import MailChimp | |
| api_key = settings.MAILCHIMP_API_KEY | |
| data = { | |
| "id": "store_001", | |
| "list_id": "3dae751fe9", | |
| "name": "Jordan Local", | |
| "domain": "larue.ngrok.io", | |
| "email_address": "[email protected]", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db.models.signals import post_save | |
| import mailchimp3 | |
| @receiver(post_save, sender=Cart) | |
| def send_cart_data_to_mailchimp(sender, instance, raw, created, using, **kwargs): | |
| # https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/ | |
| if not created: | |
| return | |
| data = { | |
| 'id':instance.id, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import geocoder | |
| def get_shop_coordinates(shop): | |
| if len(shop.postalcode) and len(shop.street) > 1: | |
| address_to_check = '%s %s' % (shop.street, shop.postalcode) | |
| g = geocoder.google(address_to_check) | |
| ret = {} | |
| if g.lat <> 0 and g.lng <> 0: | |
| ret['latitude'] = g.lat | |
| ret['longitude'] = g.lng | |
| return ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from product.modules.configurable.models import ConfigurableProduct, ProductVariation | |
| from satchmo_store.shop.models import OrderItem | |
| def pending_orderitem_options(request, product_id): | |
| cp = ConfigurableProduct.objects.get(pk=product_id) # this is the url argument | |
| child_ids = [v.product_id for v in cp.productvariation_set.all()] # find the cp's child product ids | |
| orderitems = OrderItem.objects.filter(product_id__in=child_ids) # find the order items that match any of the children product ids | |
| data = {} # The table in the view will be built from this dictionary | |
| for oi in orderitems: # we step through the order items and build the needed data broken down by variation | |
| v = ProductVariation.objects.get(pk=oi.product_id) |