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 | |
cd ~/sandbox/git/moreau/devel/cms_dev/src/storyville | |
vagrant up | |
vagrant ssh -c 'cd ~/devel/cms_dev/src/storyville/medley/ && med rs' |
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
var populate_data_from = 'trainers tags', | |
video_data = { | |
path: 'videos', | |
model: 'Video', | |
select: 'title description legacy_video videofiles.sources.10' | |
}, | |
excludes = '-royalties'; | |
/** | |
* @return {object} A single collection with videos, tags and trainers |
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
// The route | |
var Q = require('q'); | |
module.exports = function(app) { | |
var promise = require('./path/to/promise'), | |
promise.init(app); | |
app.post('someurl/add', function(req, res, next) { | |
Q.fcall(promise.createModel1, req.body) | |
.then(promise.createModel2) |
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
# models.py | |
# Work around the ImportError: cannot import name create_api_key | |
# Issue https://github.com/toastdriven/django-tastypie/issues/937 | |
class User(AbstractUser): | |
field1 | |
... | |
@receiver(post_save, sender=User) | |
def create_user_api_key(sender, **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
# forms.py | |
from django import forms | |
from django.contrib.auth.forms import UserChangeForm, UserCreationForm | |
from .models import User # Your custom user model | |
class CustomUserCreationForm(UserCreationForm): | |
class Meta: | |
model = User |
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
re = /(^(\d{1,2}):(\d{2})\s?(?:am|pm)?)$|^\d{1}(?:am|pm)$/i; | |
var reminder = (attributes.reminder || '').replace(/\./g, '').replace(/\s/g, ''); | |
if (reminder !== '' && !reminder.match(re)) { | |
return "Enter valid time ie 3:30 pm or 5pm"; | |
} | |
/* match result | |
12:00 pm | |
6pm | |
6 pm |
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 get_avatar_url(request, backend, response, *args, **kwargs): | |
"""Pipeline to get user avatar from Twitter/FB via django-social-auth""" | |
avatar_url = '' | |
if isinstance(backend, FacebookBackend): | |
avatar_url = 'http://graph.facebook.com/%s/picture?type=large' \ | |
% response['id'] | |
elif isinstance(backend, TwitterBackend): | |
avatar_url = response.get('profile_image_url', '') | |
request.session['avatar_url'] = avatar_url | |
return |
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
@allow_lazy_user | |
def convert(request, form_class=UserCreationForm, | |
redirect_field_name='redirect_to', | |
anonymous_redirect=settings.LOGIN_URL, | |
template_name='lazysignup/convert.html'): | |
... | |
... | |
... | |
return direct_to_template(request, template_name, { |