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
$ ./manage.py shell | |
/home/vom/.virtualenvs/vom/local/lib/python2.7/site-packages/IPython/terminal/embed.py:254: DeprecationWarning: With-statements now directly support multiple context managers | |
with nested(self.builtin_trap, self.display_trap): | |
Python 2.7.3 (default, Sep 26 2012, 21:51:14) | |
Type "copyright", "credits" or "license" for more information. | |
IPython 1.1.0 -- An enhanced Interactive Python. | |
? -> Introduction and overview of IPython's features. | |
%quickref -> Quick reference. |
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
function twinkle(target){ | |
var opa = $(target).css("opacity"); | |
if(twinkleSwitch){ | |
$(target).css("opacity", parseFloat(opa) - 0.1); | |
if($(target).css("opacity") < 0.1){ | |
twinkleSwitch = false; | |
} | |
} |
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
Started POST "/users/sign_in.json" for 112.175.135.112 at 2013-11-01 07:31:50 +0000 | |
Processing by Users::SessionsController#create as JSON | |
Parameters: {"email"=>"tester1@bbapi.com", "password"=>"12341234", "session"=>{"email"=>"tester1@bbapi.com", "password"=>"12341234"}} | |
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'tester1@bbapi.com' LIMIT 1 | |
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'tester1@bbapi.com' LIMIT 1 | |
Completed 500 Internal Server Error in 4ms | |
NoMethodError (undefined method `valid_password?' for nil:NilClass): | |
app/controllers/users/sessions_controller.rb:9:in `create' |
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
{ | |
"comments": [ | |
{ | |
"id": 1, | |
"writer_id": 1, | |
"content": "test", | |
"commentable_id": 1, | |
"commentable_type": "Bookkeeping", | |
"created_at": "2013-11-11T14:50:10.085+09:00", | |
"updated_at": "2013-11-11T14:50:10.085+09:00" |
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 CommentsController < ApplicationController | |
before_action :set_commentable | |
before_action :set_comment, only: [:show, :update, :destroy] | |
before_filter :authenticate_user! | |
def index | |
obj = {} | |
params[:page] = (params[:page].to_i.is_a? Integer) ? (params[:page].to_i > 0 ? params[:page].to_i : 1) : 1 |
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 RightDoor(object): | |
def right_open(self): | |
print "RightDoor open complete" | |
self.beep() | |
class LeftDoor(object): | |
def left_open(self): | |
print "LeftDoor open complete" | |
self.beep() | |
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 RightDoor(object): | |
def right_open(self): | |
print "RightDoor open complete" | |
self.beep() | |
class LeftDoor(object): | |
def left_open(self): | |
print "LeftDoor open complete" | |
self.beep() | |
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.contrib.auth.models import User | |
from rest_framework import viewsets | |
from rest_framework import status | |
from rest_framework.decorators import action | |
from rest_framework.response import Response | |
from myapp.serializers import UserSerializer, PasswordSerializer | |
class UserViewSet(viewsets.ModelViewSet): | |
""" | |
A viewset that provides the standard actions |
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
$ ./manage.py shell | |
Python 2.7.3 (default, Sep 26 2013, 20:03:06) | |
[GCC 4.6.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
(InteractiveConsole) | |
>>> from app.serializers import * | |
>>> u=UserSerializer(data={'username':'test1','password':'pass','password2':'pass'}) | |
>>> u.errors | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> |
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.contrib.auth.models import User | |
from django.utils.translation import ugettext as _ | |
from rest_framework import serializers | |
class UserSerializer(serializers.ModelSerializer): | |
password2 = serializers.CharField() | |
class Meta: | |
model = User |