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
#!/bin/bash | |
# define a help printout | |
function help { | |
echo "usage: `basename $0` [-h] [--project-dir dir] [--requirements reqfile] [--url git-url]" | |
echo " [--virtualenv-dir venv-dir] <project-name>" | |
echo "" | |
echo "Create a new virtualenv with git cloning and package requirements." | |
echo "" | |
echo "positional arguments:" |
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 direct_download(request): | |
""" | |
Returns a file path via X-Sendfile that the webserver will serve as a regular file (vs a rendered page). | |
Note: The webserver needs to support this header (i.e., Apache + mod_xsendfile)... Django dev server doesn't. | |
""" | |
if request.method == 'GET': | |
song_slug = request.GET.get('slug') | |
if song_slug: | |
song = get_object_or_404(Song, slug=song_slug) |
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 import models | |
from django.utils.translation import ugettext_lazy as _ | |
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin, check_password | |
from model_utils import Choices | |
from model_utils.models import TimeStampedModel | |
class DJManager(BaseUserManager): | |
def create_user(self, email, first_name, last_name, dj_name, user_type, subscription, password=None): |
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
{% extends 'base.html' %} | |
{% block content %} | |
<div id="login-container" class="container-fluid"> | |
<form action="{% url "users_login" %}" id="login-form" method="post" class="ka-form"> | |
{% csrf_token %} | |
<p> | |
{{ form.username.label }} | |
<input type="email" id="{{ form.username.auto_id }}" name="username"> | |
</p> |
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 search_publication_professionals(request, firm_slug, template_name='firms/admin/search-publication-professionals.html'): | |
keywords = request.GET.get('keywords', None) | |
professionals = [] | |
if keywords: | |
keywords_q = Q() | |
for keyword in keywords.split(): | |
keywords_q.add((Q(firm__name__icontains=keyword)), keywords_q.OR) | |
keywords_q.add((Q(user__first_name__icontains=keyword)), keywords_q.OR) |
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 datetime import datetime, timedelta | |
from django.core.management.base import BaseCommand, CommandError | |
from foo.firms.models import Event | |
class Command(BaseCommand): | |
args = '<days days ...>' | |
help = "Check for any Events that start in a given number of days, and execute send_reminder() on them" | |
def handle(self, *args, **kwargs): |
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
class Task(models.Model): | |
REGISTRATION = 0 | |
ATTENDANCE = 1 | |
CLE = 2 | |
TASK_TYPES = ( | |
(REGISTRATION, 'Registration Request'), | |
(ATTENDANCE, 'Attendance Request'), | |
(CLE, 'CLE Request'), |
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 import template | |
register = template.Library() | |
# Utility used like {{ dict|getval:key_name }} to return value even when using variables in dictionary key | |
@register.filter(name='getval') | |
def getval(tupdict, key_name): | |
"""Use this in a template as follows: | |
To retrieve the value of a dict: |
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
#!/bin/bash | |
DATABASE_NAME=##### | |
DATABASE_OWNER=##### | |
USE_POSTGIS=N | |
if [ ! `which psql` ]; then | |
echo 'You must have PostgreSQL installed before running this script.' | |
exit 1 | |
fi |
NewerOlder