-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
473 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
text: DS.attr('string'), | ||
user: DS.belongsTo('user'), | ||
created_at: DS.attr('date'), | ||
updated_at: DS.attr('date'), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.Model.extend({ | ||
username: DS.attr('string'), | ||
email: DS.attr('string'), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.findAll('comment'); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.findAll('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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,43 @@ | ||
<h1>chit chat</h1> | ||
<div class="container"> | ||
<!-- Static navbar --> | ||
<nav class="navbar navbar-default"> | ||
<div class="container-fluid"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a class="navbar-brand" href="#">Chitter Chatter</a> | ||
</div> | ||
{{!-- | ||
<div id="navbar" class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li class="active"><a href="#">Home</a></li> | ||
<li><a href="#">About</a></li> | ||
<li><a href="#">Contact</a></li> | ||
<li class="dropdown"> | ||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> | ||
<ul class="dropdown-menu"> | ||
<li><a href="#">Action</a></li> | ||
<li><a href="#">Another action</a></li> | ||
<li><a href="#">Something else here</a></li> | ||
<li role="separator" class="divider"></li> | ||
<li class="dropdown-header">Nav header</li> | ||
<li><a href="#">Separated link</a></li> | ||
<li><a href="#">One more separated link</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<ul class="nav navbar-nav navbar-right"> | ||
<li class="active"><a href="./">Default <span class="sr-only">(current)</span></a></li> | ||
<li><a href="../navbar-static-top/">Static top</a></li> | ||
<li><a href="../navbar-fixed-top/">Fixed top</a></li> | ||
</ul> | ||
</div><!--/.nav-collapse --> | ||
--}} | ||
</div><!--/.container-fluid --> | ||
</nav> | ||
{{outlet}} | ||
</div><!-- .container --> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{outlet}} | ||
|
||
{{#each model as |comment|}} | ||
<p> | ||
{{comment.text}} | ||
{{comment.createdAt}} | ||
{{comment.updatedAt}} | ||
{{comment.user.username}} | ||
{{comment.user.email}} | ||
</p> | ||
{{/each}} | ||
{{bs-input}} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
moduleFor('controller:users', 'Unit | Controller | users', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let controller = this.subject(); | ||
assert.ok(controller); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { moduleForModel, test } from 'ember-qunit'; | ||
|
||
moduleForModel('comment', 'Unit | Model | comment', { | ||
// Specify the other units that are required for this test. | ||
needs: [] | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
let model = this.subject(); | ||
// let store = this.store(); | ||
assert.ok(!!model); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { moduleForModel, test } from 'ember-qunit'; | ||
|
||
moduleForModel('user', 'Unit | Model | user', { | ||
// Specify the other units that are required for this test. | ||
needs: [] | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
let model = this.subject(); | ||
// let store = this.store(); | ||
assert.ok(!!model); | ||
}); | ||
|
||
test('has usernname and email', function(assert){ | ||
let model = this.suject(); | ||
assert.ok(model.username); | ||
assert.ok(model.email); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { moduleForModel, test } from 'ember-qunit'; | ||
|
||
moduleForModel('users', 'Unit | Model | users', { | ||
// Specify the other units that are required for this test. | ||
needs: [] | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
let model = this.subject(); | ||
// let store = this.store(); | ||
assert.ok(!!model); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
moduleFor('route:root', 'Unit | Route | root', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
let route = this.subject(); | ||
assert.ok(route); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
moduleFor('route:users', 'Unit | Route | users', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
let route = this.subject(); | ||
assert.ok(route); | ||
}); |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.contrib import admin | ||
from chat.models import Comment | ||
|
||
# Register your models here. | ||
class CommentAdmin(admin.ModelAdmin): | ||
list_display = ('text', 'user', 'created_at', 'updated_at') | ||
|
||
admin.site.register(Comment, CommentAdmin) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ChatConfig(AppConfig): | ||
name = 'chat' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.4 on 2016-03-23 10:39 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='DateMixin', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('updated_at', models.DateTimeField(auto_now=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Comment', | ||
fields=[ | ||
('datemixin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='chat.DateMixin')), | ||
('text', models.CharField(max_length=255)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
bases=('chat.datemixin',), | ||
), | ||
] |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class DateMixin(models.Model): | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
|
||
class Comment(DateMixin): | ||
text = models.CharField(max_length=255) | ||
user = models.ForeignKey(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from chat.models import Comment | ||
from rest_framework import serializers | ||
|
||
|
||
class CommentSerializer(serializers.HyperlinkedModelSerializer): | ||
class Meta: | ||
model = Comment | ||
fields = ('text', 'user', 'created_at', 'updated_at') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from chat.models import Comment | ||
from rest_framework import viewsets | ||
|
||
from chat.serializers import CommentSerializer | ||
|
||
|
||
class CommentViewSet(viewsets.ModelViewSet): | ||
""" | ||
API endpoint that allows comments to be viewed or edited. | ||
""" | ||
queryset = Comment.objects.all().order_by('-created_at') | ||
serializer_class = CommentSerializer |
Empty file.
Oops, something went wrong.