Skip to content

Instantly share code, notes, and snippets.

View bencleary's full-sized avatar
💭
I may be slow to respond.

Ben Cleary bencleary

💭
I may be slow to respond.
View GitHub Profile
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
from crunchy_waffles_app.models import *
from crunchy_waffles_ops.models import ManagementLog
from crunchy_waffles_ops.crunchy_classes_ops.management_log import Management
import time
class Command(BaseCommand):
title = "Process Emails"
@bencleary
bencleary / details.html
Created December 13, 2017 12:10
Fixes to your project
# Added img tag to view picture
<img src="{{object.image.url}}">
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'crunchy_waffles.settings')
app = Celery('crunchy_waffles')
app.config_from_object('django.conf:settings', namespace='CELERY')
@bencleary
bencleary / tasks.py
Last active December 16, 2017 15:10
from __future__ import absolute_import, unicode_literals
from celery import shared_task
@shared_task
def add(x, y):
return x + y
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from django.utils import timezone
from .models import *
@shared_task
def add(x, y):
return x + y
class ObjectOwnerMixin:
def get_queryset(self):
return self.model.objects.filter(author=self.request.user)
from django.conf import settings
from crunchy_waffles_app.errors import *
import requests
class EmailService:
subject = None
body = None
to = None
class NetworkMangaer {
static let shared = NetworkManager()
func sendEmail() {
// send email function
}
}
@bencleary
bencleary / admin.py
Created January 11, 2018 12:19
Setup initial App for HTML to PDF tutorial
from django.contrib import admin
from .models import *
admin.site.register(Sales)
admin.site.register(Products)
@bencleary
bencleary / seeds.py
Last active January 11, 2018 12:25
DB Seeder
from .models import *
from random import *
from decimal import Decimal
class Seeder:
def __init__(self):
self.products = ["Orange Ball", "Chew Toy 1", "Cat Bowl", "Dog Bed", "Cat Food", "Dog Food"]