├── server
├── __init__.py
├── test_settings.py
├── templates
│ ├── include
│ │ ├── jquery.html
│ │ ├── ember.html
│ │ ├── csrf.html
│ │ └── head.html
│ └── application.html
├── wsgi.py
├── urls.py
└── settings.py
├── users
├── __init__.py
├── views.py
├── serializers.py
├── fixtures
│ └── initial_data.json
└── tests.py
├── session
├── __init__.py
├── views.py
└── tests.py
├── circle.yml
├── assets
├── js
│ ├── templates
│ │ ├── application.handlebars
│ │ └── session.handlebars
│ └── app.js
├── tests
│ ├── integration_test_helper.js
│ └── integration_tests.js
└── vendor
│ ├── adapter.js
│ ├── jquery.mockjax.js
│ └── handlebars.js
├── package.json
├── requirements.txt
├── .gitignore
├── manage.py
├── Makefile
├── karma.conf.js
└── README.md
/server/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/users/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/session/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/test_settings.py:
--------------------------------------------------------------------------------
1 | from server.settings import *
2 |
3 |
4 | DATABASES['default']['NAME'] = ':memory:'
5 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | override:
3 | - make develop
4 |
5 | test:
6 | override:
7 | - make test
8 |
--------------------------------------------------------------------------------
/server/templates/include/jquery.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
--------------------------------------------------------------------------------
/assets/js/templates/application.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
Django/Ember Authentication
3 | {{render 'session'}}
4 | {{outlet}}
5 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "django-ember-precompile": "1.0.9",
4 | "karma-ember-preprocessor": "*",
5 | "karma-qunit": "*",
6 | "karma": "0.10.2"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | -e git+https://github.com/django/django.git@1.6b4#egg=django
2 | djangorestframework==2.3.8
3 | -e git+https://github.com/jezdez/django_compressor.git@9cf68a04e473b0bccf7e#egg=django_compressor
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.db
2 | *.swp
3 | *.pyc
4 | *.pyo
5 | *.tar
6 | *.tgz
7 | *.tar.gz
8 | *.bak
9 | *.log
10 | .DS_Store
11 | .coverage
12 | env
13 | venv
14 | /media/
15 | /static/
16 | /node_modules/
17 | *.sqlite3
18 | /vendor/
19 |
--------------------------------------------------------------------------------
/users/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.models import User
2 | from rest_framework import viewsets
3 |
4 | from users import serializers
5 |
6 |
7 | class UserViewSet(viewsets.ModelViewSet):
8 | model = User
9 | serializer_class = serializers.UserSerializer
10 |
--------------------------------------------------------------------------------
/users/serializers.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.models import User
2 | from rest_framework import serializers
3 |
4 |
5 | class UserSerializer(serializers.ModelSerializer):
6 | class Meta:
7 | model = User
8 | fields = ('id', 'username', 'first_name', 'last_name')
9 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
7 |
8 | from django.core.management import execute_from_command_line
9 |
10 | execute_from_command_line(sys.argv)
11 |
--------------------------------------------------------------------------------
/server/templates/include/ember.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/server/templates/include/csrf.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/users/fixtures/initial_data.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "pk": 1,
4 | "model": "auth.user",
5 | "fields": {
6 | "username": "dustin",
7 | "first_name": "Dustin",
8 | "last_name": "Farris",
9 | "is_active": true,
10 | "password": "pbkdf2_sha256$10000$FxH0AVklG2MS$dmRkwyW/mFunUykRypX/X7K8k5CF8zSxrdxXPlwXqfQ="
11 | }
12 | }
13 | ]
14 |
--------------------------------------------------------------------------------
/server/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for server project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
12 |
13 | from django.core.wsgi import get_wsgi_application
14 | application = get_wsgi_application()
15 |
--------------------------------------------------------------------------------
/assets/tests/integration_test_helper.js:
--------------------------------------------------------------------------------
1 | document.write('');
2 |
3 | App.rootElement = '#ember-testing';
4 | App.setupForTesting();
5 | App.injectTestHelpers();
6 |
7 | function exists(selector) {
8 | return !!find(selector).length;
9 | }
10 |
11 | function httpStub(url, json) {
12 | $.mockjax({
13 | url: url,
14 | dataType: 'json',
15 | responseText: json
16 | });
17 | }
18 |
19 | $.mockjaxSettings.logging = false;
20 | $.mockjaxSettings.responseTime = 0;
--------------------------------------------------------------------------------
/server/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import include, patterns, url
2 | from django.views.generic import TemplateView
3 | from rest_framework.routers import DefaultRouter
4 |
5 | from session.views import SessionView
6 | from users.views import UserViewSet
7 |
8 |
9 | router = DefaultRouter()
10 | router.register(r'users', UserViewSet)
11 |
12 |
13 | urlpatterns = patterns(
14 | '',
15 |
16 | # Authentication
17 | url(r'^session/$', SessionView.as_view()),
18 |
19 | # API
20 | url(r'api/', include(router.urls)),
21 |
22 | # Application
23 | url(r'^$', TemplateView.as_view(template_name='application.html'))
24 | )
25 |
--------------------------------------------------------------------------------
/assets/js/templates/session.handlebars:
--------------------------------------------------------------------------------
1 | {{#if isAuthenticated}}
2 | Welcome back, {{first_name}}!
3 |
4 | {{else}}
5 |
14 | {{#if errorMessage}}{{errorMessage}}{{/if}}
15 | {{/if}}
--------------------------------------------------------------------------------
/server/templates/application.html:
--------------------------------------------------------------------------------
1 | {% load compress static %}
2 |
3 | {% include "head.html" %}
4 |
5 |
6 |
7 |
8 |
9 |
10 | {# Vendor javascripts #}
11 | {% include "jquery.html" %}
12 | {% include "csrf.html" %}
13 | {% include "ember.html" %}
14 |
15 | {# Application #}
16 |
17 |
18 | {# Handlebars templates #}
19 | {% compress js %}
20 |
21 |
22 | {% endcompress js %}
23 |
24 |