This file contains 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 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 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 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 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 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) |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" /> | |
<title>New Test</title> | |
</head> | |
<body> | |
<table cellpadding="1" cellspacing="1" border="1"> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" /> | |
<title>New Test</title> | |
</head> | |
<body> | |
<table cellpadding="1" cellspacing="1" border="1"> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" /> | |
<title>New Test</title> | |
</head> | |
<body> | |
<table cellpadding="1" cellspacing="1" border="1"> |
NewerOlder