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
| # -*- coding: utf-8 -*- | |
| from django import forms | |
| from crispy_forms.helper import FormHelper | |
| from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field | |
| from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions | |
| class MessageForm(forms.Form): | |
| text_input = forms.CharField() |
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
| # EditorConfig is awesome: http://EditorConfig.org | |
| # top-most EditorConfig file | |
| root = true | |
| # Unix-style newlines with a newline ending every file | |
| [*] | |
| charset = utf-8 | |
| indent_style = space | |
| indent_size = 2 |
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.contrib import admin | |
| from product.forms import EquipmentForm | |
| @admin.register(Equipment) | |
| class EquipmentAdmin(admin.ModelAdmin): | |
| form = EquipmentForm | |
| inlines = [ | |
| EquipmentGalleryInline, |
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 import forms | |
| from menu.models import Ingredient, Diet, FoodPreference | |
| class IngredientForm (forms.ModelForm): | |
| class Meta: | |
| model = Ingredient | |
| exclude = ["franchise"] | |
| def __init__ (self, *args, **kwargs): | |
| brand = kwargs.pop("brand") |
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
| """Add user created_by and modified_by foreign key refs to any model automatically. | |
| Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
| from django.db.models import signals | |
| from django.utils.functional import curry | |
| class WhodidMiddleware(object): | |
| def process_request(self, request): | |
| if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): | |
| if hasattr(request, 'user') and request.user.is_authenticated(): | |
| user = request.user |
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 | |
| import boto | |
| # based on http://www.quora.com/Amazon-S3/What-is-the-fastest-way-to-measure-the-total-size-of-an-S3-bucket | |
| # assumes you've already configured your access id & secret key | |
| s3 = boto.connect_s3() |
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 import models | |
| class Person(models.Model): | |
| name = models.CharField(max_length=200) | |
| groups = models.ManyToManyField('Group', through='GroupMember', related_name='people') | |
| class Meta: | |
| ordering = ['name'] | |
| def __unicode__(self): |