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
""" | |
Version 0.3.8 - Ed Menendez - [email protected] | |
Add to any Django Model definition and you will have a instance.as_json() function). | |
For example >> class Customer(models.Model, JSONHelper): | |
Latest at https://gist.github.com/edmenendez/06bcd4ff56a70d2de3fd | |
""" | |
import copy | |
import json |
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
""" | |
Interface to the FreshDesk API. | |
Author: Ed Menendez ([email protected]) | |
Company: Digital Haiku | |
Created: September 1, 2014 | |
Example settings: | |
FRESHDESK_URL = 'https://wpt.freshdesk.com' |
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 datetime | |
import random | |
from django.db import models | |
from django.db.models import Count | |
class RandomManager(models.Manager): | |
def __init__(self, *args, **kwargs): | |
self.when_last_cached = datetime.datetime.now() - datetime.timedelta(minutes=10) |
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.conf import settings | |
from django.contrib.auth.models import User, Permission | |
from django.core.mail import EmailMessage, mail_admins, send_mail, EmailMultiAlternatives | |
from django.db.models import Q | |
from django.utils.html import strip_tags | |
def mail_group(codename, subject, message=None, debug=False, html_message=None): | |
perm = Permission.objects.get(codename=codename) # 'get_billing_emails' | |
users = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm)).distinct() |